@@ -16,7 +16,6 @@ void processSerialData();
16
16
// The main loop when under serial control
17
17
void serialLoop ()
18
18
{
19
- // Serial.print('.');
20
19
mount.loop ();
21
20
mount.displayStepperPositionThrottled ();
22
21
@@ -126,36 +125,33 @@ void processSerialData()
126
125
#endif
127
126
index = 0 ;
128
127
}
129
- else
128
+ else if (buffer[index] == ' # ' )
130
129
{
131
- if (buffer[index] == ' #' )
132
- {
133
- // Ignoring trailing hash
134
- buffer[index] = 0 ;
135
- String inCmd = String (buffer);
136
- LOG (DEBUG_SERIAL, " [SERIAL]: ReceivedCommand(%d chars): [%s]" , inCmd.length (), inCmd.c_str ());
130
+ // Ignoring trailing hash
131
+ buffer[index] = ' \0 ' ;
132
+ const String inCmd = String (buffer);
133
+ LOG (DEBUG_SERIAL, " [SERIAL]: ReceivedCommand(%d chars): [%s]" , inCmd.length (), inCmd.c_str ());
137
134
138
- String retVal = MeadeCommandProcessor::instance ()->processCommand (inCmd);
139
- if (retVal != " " )
140
- {
141
- LOG (DEBUG_SERIAL, " [SERIAL]: RepliedWith: [%s]" , retVal.c_str ());
142
- // When not debugging, print the result to the serial port .
143
- // When debugging, only print the result to Serial if we're on seperate ports.
135
+ const String retVal = MeadeCommandProcessor::instance ()->processCommand (inCmd);
136
+ if (retVal != " " )
137
+ {
138
+ LOG (DEBUG_SERIAL, " [SERIAL]: RepliedWith: [%s]" , retVal.c_str ());
139
+ // When not debugging, print the result to the serial port .
140
+ // When debugging, only print the result to Serial if we're on seperate ports.
144
141
#if (DEBUG_LEVEL == DEBUG_NONE) || (DEBUG_SEPARATE_SERIAL == 1)
145
- Serial.print (retVal);
142
+ Serial.print (retVal);
146
143
#endif
147
- }
148
- // Wait for next command
149
- index = 0 ;
150
144
}
151
- else if (buffer[index] > 31 )
145
+ // Wait for next command
146
+ index = 0 ;
147
+ }
148
+ else if (buffer[index] >= ' ' )
149
+ {
150
+ index++;
151
+ if (index >= sizeof (buffer))
152
152
{
153
- index++;
154
- if (index >= sizeof (buffer))
155
- {
156
- LOG (DEBUG_SERIAL, " [SERIAL]: Command buffer overflow! Ignoring received data." );
157
- index = 0 ;
158
- }
153
+ LOG (DEBUG_SERIAL, " [SERIAL]: Command buffer overflow! Ignoring received data." );
154
+ index = 0 ;
159
155
}
160
156
}
161
157
}
0 commit comments