Skip to content

Commit 07231ad

Browse files
PR Feedback
1 parent 8697620 commit 07231ad

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

src/HallSensorHoming.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ void HallSensorHoming::processHomingProgress()
210210
{
211211
// First time the pin has triggered, record that position
212212
_homingData.position[HOMING_START_PIN_POSITION] = _pMount->getCurrentStepperPosition(_axis);
213+
213214
LOG(DEBUG_STEPPERS,
214215
"[HOMING]: Potentially found start of sensor at %l",
215216
_homingData.position[HOMING_START_PIN_POSITION]);
@@ -230,6 +231,10 @@ void HallSensorHoming::processHomingProgress()
230231
// Make sure we continue moving far enough to reach end
231232
long distance = _homingData.initialDir * _stepsPerDegree * _homingData.searchDistance;
232233
_pMount->moveStepperBy(_axis, distance);
234+
LOG(DEBUG_STEPPERS,
235+
"[HOMING]: Making sure stepper keeps going by another %l steps. New target is %l",
236+
distance,
237+
_pMount->getCurrentStepperPosition(_axis) + distance);
233238

234239
_homingData.lastPinState = homingPinState;
235240
_homingData.pinChangeCount = 0;
@@ -289,6 +294,10 @@ void HallSensorHoming::processHomingProgress()
289294
// Make sure we continue moving far enough to reach end
290295
long distance = -_homingData.initialDir * _stepsPerDegree * _homingData.searchDistance;
291296
_pMount->moveStepperBy(_axis, distance);
297+
LOG(DEBUG_STEPPERS,
298+
"[HOMING]: Making sure stepper keeps going by another %l steps. New target is %l",
299+
distance,
300+
_pMount->getCurrentStepperPosition(_axis) + distance);
292301

293302
_homingData.lastPinState = homingPinState;
294303
_homingData.pinChangeCount = 0;

src/f_serial.hpp

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ void processSerialData();
1616
// The main loop when under serial control
1717
void serialLoop()
1818
{
19-
//Serial.print('.');
2019
mount.loop();
2120
mount.displayStepperPositionThrottled();
2221

@@ -126,36 +125,33 @@ void processSerialData()
126125
#endif
127126
index = 0;
128127
}
129-
else
128+
else if (buffer[index] == '#')
130129
{
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());
137134

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.
144141
#if (DEBUG_LEVEL == DEBUG_NONE) || (DEBUG_SEPARATE_SERIAL == 1)
145-
Serial.print(retVal);
142+
Serial.print(retVal);
146143
#endif
147-
}
148-
// Wait for next command
149-
index = 0;
150144
}
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))
152152
{
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;
159155
}
160156
}
161157
}

0 commit comments

Comments
 (0)