diff --git a/Changelog.md b/Changelog.md index 6918ccc0..41ce3607 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +**V1.13.14 - Updates** +- Improved Serial command handling (made it less 'blocking'), which should improve general performance +- Guide pulses are ignored when tracking is disabled (for example, when at the limits) + **V1.13.13 - Updates** - Improved Meade command documentation - Fixed a bug that was not correctly showing the stepper direction in the :GX# command reply./ @@ -44,7 +48,6 @@ NOTE: Make sure to do a Factory Reset when using this version. - Lowered ESP32 second core priority - Added support for informational display - You must upgrade to OATControl V1.1.2.0 to use with this version (at least if you want to use teh DEC park/unpark feature) - **V1.13.2 - Updates** - Fix for RA steps being incorrectly set on every boot. diff --git a/Version.h b/Version.h index 7d49180c..d7ea4141 100644 --- a/Version.h +++ b/Version.h @@ -3,4 +3,4 @@ // Also, numbers are interpreted as simple numbers. _ __ _ // So 1.8 is actually 1.08, meaning that 1.12 is a later version than 1.8. \_(..)_/ -#define VERSION "V1.13.13" +#define VERSION "V1.13.14" diff --git a/src/HallSensorHoming.cpp b/src/HallSensorHoming.cpp index a53704b4..57a289a9 100644 --- a/src/HallSensorHoming.cpp +++ b/src/HallSensorHoming.cpp @@ -210,6 +210,7 @@ void HallSensorHoming::processHomingProgress() { // First time the pin has triggered, record that position _homingData.position[HOMING_START_PIN_POSITION] = _pMount->getCurrentStepperPosition(_axis); + LOG(DEBUG_STEPPERS, "[HOMING]: Potentially found start of sensor at %l", _homingData.position[HOMING_START_PIN_POSITION]); @@ -230,6 +231,10 @@ void HallSensorHoming::processHomingProgress() // Make sure we continue moving far enough to reach end long distance = _homingData.initialDir * _stepsPerDegree * _homingData.searchDistance; _pMount->moveStepperBy(_axis, distance); + LOG(DEBUG_STEPPERS, + "[HOMING]: Making sure stepper keeps going by another %l steps. New target is %l", + distance, + _pMount->getCurrentStepperPosition(_axis) + distance); _homingData.lastPinState = homingPinState; _homingData.pinChangeCount = 0; @@ -289,6 +294,10 @@ void HallSensorHoming::processHomingProgress() // Make sure we continue moving far enough to reach end long distance = -_homingData.initialDir * _stepsPerDegree * _homingData.searchDistance; _pMount->moveStepperBy(_axis, distance); + LOG(DEBUG_STEPPERS, + "[HOMING]: Making sure stepper keeps going by another %l steps. New target is %l", + distance, + _pMount->getCurrentStepperPosition(_axis) + distance); _homingData.lastPinState = homingPinState; _homingData.pinChangeCount = 0; diff --git a/src/MeadeCommandProcessor.cpp b/src/MeadeCommandProcessor.cpp index f3c27d94..e06b984e 100644 --- a/src/MeadeCommandProcessor.cpp +++ b/src/MeadeCommandProcessor.cpp @@ -626,7 +626,7 @@ bool gpsAqcuisitionComplete(int &indicator); // defined in c72_menuHA_GPS.hpp // Information: // This stops all motors, including tracking. Note that deceleration curves are still followed. // Returns: -// "1" when all motors have stopped +// nothing // // :Qd# // Description: @@ -1521,6 +1521,7 @@ String MeadeCommandProcessor::handleMeadeSetInfo(String inCmd) ///////////////////////////// String MeadeCommandProcessor::handleMeadeMovement(String inCmd) { + LOG(DEBUG_MEADE, "[MEADE]: Process Move command: [%s]", inCmd.c_str()); if (inCmd[0] == 'S') // :MS# { _mount->startSlewingToTarget(); @@ -2203,7 +2204,7 @@ String MeadeCommandProcessor::processCommand(String inCmd) { if (inCmd[0] == ':') { - LOG(DEBUG_MEADE, "[MEADE]: Received command '%s'", inCmd.c_str()); + LOG(DEBUG_MEADE, "[MEADE]: Received command '%s'", inCmd.c_str()); // Apparently some LX200 implementations put spaces in their commands..... remove them with impunity. int spacePos; diff --git a/src/Mount.cpp b/src/Mount.cpp index 7b82cbf4..6ff13987 100644 --- a/src/Mount.cpp +++ b/src/Mount.cpp @@ -1566,11 +1566,9 @@ void Mount::stopGuiding(bool ra, bool dec) // Stop RA guide first, since it's just a speed change back to tracking speed if (ra && (_mountStatus & STATUS_GUIDE_PULSE_RA)) { - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, - "[GUIDE]: stopGuide: RA set speed : %f (at %l)", - _trackingSpeed, - _stepperTRK->currentPosition()); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: stopGuide: TRK stop guide at : %l", _stepperTRK->currentPosition()); _stepperTRK->setSpeed(_trackingSpeed); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: stopGuide: TRK speed set to : %f", _trackingSpeed); _mountStatus &= ~STATUS_GUIDE_PULSE_RA; } @@ -1586,8 +1584,6 @@ void Mount::stopGuiding(bool ra, bool dec) _stepperGUIDE->run(); _stepperTRK->runSpeed(); } - - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: stopGuide: DEC stopped at : %l", _stepperGUIDE->currentPosition()); _mountStatus &= ~STATUS_GUIDE_PULSE_DEC; } @@ -1613,84 +1609,95 @@ void Mount::guidePulse(byte direction, int duration) #if (DEBUG_LEVEL != DEBUG_NONE) const char *directionName = "-NE-S---W"; #endif - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: > Guide Pulse %c for %dms", directionName[direction], duration); - if ((direction == NORTH) || (direction == SOUTH)) + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: > Guide Pulse %c for %dms requested", directionName[direction], duration); + if (!isSlewingTRK()) { - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC current steps : %l", _stepperGUIDE->currentPosition()); - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC steps/deg : %f", _stepsPerDECDegree); - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, - "[GUIDE]: guidePulse: DEC Microstep ratio : %f", - (DEC_GUIDE_MICROSTEPPING / DEC_SLEW_MICROSTEPPING)); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: Not tracking (at limit?), ignoring guide pulse"); } else { - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA current steps : %l", _stepperTRK->currentPosition()); - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA steps/deg : %f", _stepsPerRADegree); - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, - "[GUIDE]: guidePulse: RA Microstep ratio : %f", - (RA_TRACKING_MICROSTEPPING / RA_SLEW_MICROSTEPPING)); - } + if ((direction == NORTH) || (direction == SOUTH)) + { + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC current steps : %l", _stepperGUIDE->currentPosition()); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC steps/deg : %f", _stepsPerDECDegree); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, + "[GUIDE]: guidePulse: DEC Microstep ratio : %f", + (1.0 * DEC_GUIDE_MICROSTEPPING / DEC_SLEW_MICROSTEPPING)); + } + else + { + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA current steps : %l", _stepperTRK->currentPosition()); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA steps/deg : %f", _stepsPerRADegree); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, + "[GUIDE]: guidePulse: RA Microstep ratio : %f", + (1.0 * RA_TRACKING_MICROSTEPPING / RA_SLEW_MICROSTEPPING)); + } - // DEC stepper moves at sidereal rate in both directions - // RA stepper moves at either 2.5x sidereal rate or 0.5x sidereal rate. - // Also compensate for microstepping mode change between slew & guiding/tracking - float decGuidingSpeed = _stepsPerDECDegree * (DEC_GUIDE_MICROSTEPPING / DEC_SLEW_MICROSTEPPING) * siderealDegreesInHour - / 3600.0f; // u-steps/deg * deg/hr / sec/hr = u-steps/sec - float raGuidingSpeed = _stepsPerRADegree * (RA_TRACKING_MICROSTEPPING / RA_SLEW_MICROSTEPPING) * siderealDegreesInHour - / 3600.0f; // u-steps/deg * deg/hr / sec/hr = u-steps/sec + // DEC stepper moves at sidereal rate in both directions + // RA stepper moves at either 2.5x sidereal rate or 0.5x sidereal rate. + // Also compensate for microstepping mode change between slew & guiding/tracking + float decGuidingSpeed = _stepsPerDECDegree * (1.0 * DEC_GUIDE_MICROSTEPPING / DEC_SLEW_MICROSTEPPING) * siderealDegreesInHour + / 3600.0f; // u-steps/deg * deg/hr / sec/hr = u-steps/sec + float raGuidingSpeed = _stepsPerRADegree * (1.0 * RA_TRACKING_MICROSTEPPING / RA_SLEW_MICROSTEPPING) * siderealDegreesInHour + / 3600.0f; // u-steps/deg * deg/hr / sec/hr = u-steps/sec - // TODO: Do we need to track how many steps the steppers took and add them to the GoHome calculation? - // If so, we need to remember where we were when we started the guide pulse. Then at the end, - // we can calculate the difference. Ignore DEC Guide for now. - // TODO: Take guide pulses on DEC into account + // TODO: Do we need to track how many steps the steppers took and add them to the GoHome calculation? + // If so, we need to remember where we were when we started the guide pulse. Then at the end, + // we can calculate the difference. Ignore DEC Guide for now. + // TODO: Take guide pulses on DEC into account - switch (direction) - { - case NORTH: - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC base speed : %f", decGuidingSpeed); - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC guide speed : %f", DEC_PULSE_MULTIPLIER * decGuidingSpeed); - _stepperGUIDE->setSpeed(DEC_PULSE_MULTIPLIER * decGuidingSpeed); - _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC; - _guideDecEndTime = millis() + duration; - break; + switch (direction) + { + case NORTH: + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC base speed : %f", decGuidingSpeed); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, + "[GUIDE]: guidePulse: DEC guide speed : %f", + DEC_PULSE_MULTIPLIER * decGuidingSpeed); + _stepperGUIDE->setSpeed(DEC_PULSE_MULTIPLIER * decGuidingSpeed); + _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC; + _guideDecEndTime = millis() + duration; + break; - case SOUTH: - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC base speed : %f", decGuidingSpeed); - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC guide speed : %f", -DEC_PULSE_MULTIPLIER * decGuidingSpeed); - _stepperGUIDE->setSpeed(-DEC_PULSE_MULTIPLIER * decGuidingSpeed); - _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC; - _guideDecEndTime = millis() + duration; - break; + case SOUTH: + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC base speed : %f", decGuidingSpeed); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, + "[GUIDE]: guidePulse: DEC guide speed : %f", + -DEC_PULSE_MULTIPLIER * decGuidingSpeed); + _stepperGUIDE->setSpeed(-DEC_PULSE_MULTIPLIER * decGuidingSpeed); + _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC; + _guideDecEndTime = millis() + duration; + break; - case WEST: - // We were in tracking mode before guiding, so no need to update microstepping mode on RA driver - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA base speed : %f", raGuidingSpeed); - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA speed factor : %f", _trackingSpeedCalibration); - raGuidingSpeed *= _trackingSpeedCalibration; - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA adjusted speed : %f", raGuidingSpeed); - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, - "[GUIDE]: guidePulse: RA guide speed : %f (%f x adjusted speed)", - (RA_PULSE_MULTIPLIER * raGuidingSpeed), - RA_PULSE_MULTIPLIER); - _stepperTRK->setSpeed(RA_PULSE_MULTIPLIER * raGuidingSpeed); // Faster than siderael - _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA; - _guideRaEndTime = millis() + duration; - break; + case WEST: + // We were in tracking mode before guiding, so no need to update microstepping mode on RA driver + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA base speed : %f", raGuidingSpeed); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA speed factor : %f", _trackingSpeedCalibration); + raGuidingSpeed *= _trackingSpeedCalibration; + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA adjusted speed : %f", raGuidingSpeed); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, + "[GUIDE]: guidePulse: RA guide speed : %f (%f x adjusted speed)", + (RA_PULSE_MULTIPLIER * raGuidingSpeed), + RA_PULSE_MULTIPLIER); + _stepperTRK->setSpeed(RA_PULSE_MULTIPLIER * raGuidingSpeed); // Faster than siderael + _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA; + _guideRaEndTime = millis() + duration; + break; - case EAST: - // We were in tracking mode before guiding, so no need to update microstepping mode on RA driver - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA base speed : %f", raGuidingSpeed); - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA speed factor : %f", _trackingSpeedCalibration); - raGuidingSpeed *= _trackingSpeedCalibration; - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA adjusted speed : %f", raGuidingSpeed); - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, - "[GUIDE]: guidePulse: RA guide speed : %f (%f x adjusted speed)", - (2.0 - RA_PULSE_MULTIPLIER * raGuidingSpeed), - (2.0 - RA_PULSE_MULTIPLIER)); - _stepperTRK->setSpeed(raGuidingSpeed * (2.0f - RA_PULSE_MULTIPLIER)); // Slower than siderael - _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA; - _guideRaEndTime = millis() + duration; - break; + case EAST: + // We were in tracking mode before guiding, so no need to update microstepping mode on RA driver + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA base speed : %f", raGuidingSpeed); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA speed factor : %f", _trackingSpeedCalibration); + raGuidingSpeed *= _trackingSpeedCalibration; + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: RA adjusted speed : %f", raGuidingSpeed); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, + "[GUIDE]: guidePulse: RA guide speed : %f (%f x adjusted speed)", + (2.0 - RA_PULSE_MULTIPLIER * raGuidingSpeed), + (2.0 - RA_PULSE_MULTIPLIER)); + _stepperTRK->setSpeed(raGuidingSpeed * (2.0f - RA_PULSE_MULTIPLIER)); // Slower than siderael + _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA; + _guideRaEndTime = millis() + duration; + break; + } } // Since we will not be updating the display during a guide pulse, update the display here. #if INFO_DISPLAY_TYPE != INFO_DISPLAY_TYPE_NONE @@ -2992,6 +2999,7 @@ void Mount::loop() bool stopDecGuiding = (now > _guideDecEndTime) && (_mountStatus & STATUS_GUIDE_PULSE_DEC); if (stopRaGuiding || stopDecGuiding) { + LOG(DEBUG_GUIDE, "[MOUNT]: Loop: StopGuiding. Now: %l, RA End: %l, DEC End: %l", now, _guideRaEndTime, _guideDecEndTime); stopGuiding(stopRaGuiding, stopDecGuiding); } else diff --git a/src/b_setup.hpp b/src/b_setup.hpp index f2b5dac7..cd99525e 100644 --- a/src/b_setup.hpp +++ b/src/b_setup.hpp @@ -357,7 +357,6 @@ void setup() // Set the stepper motor parameters #if (RA_STEPPER_TYPE != STEPPER_TYPE_NONE) LOG(DEBUG_ANY, "[STEPPERS]: Configure RA stepper NEMA."); - LOG(DEBUG_ANY, "[STEPPERS]: Stepper SPR : %d", RA_STEPPER_SPR); LOG(DEBUG_ANY, "[STEPPERS]: Slew Microsteps : %d", RA_SLEW_MICROSTEPPING); LOG(DEBUG_ANY, "[STEPPERS]: Trk Microsteps : %d", RA_TRACKING_MICROSTEPPING); LOG(DEBUG_ANY, "[STEPPERS]: Stepper SPR : %d", RA_STEPPER_SPR); @@ -381,17 +380,18 @@ void setup() #if (DEC_STEPPER_TYPE != STEPPER_TYPE_NONE) LOG(DEBUG_ANY, "[STEPPERS]: Configure DEC stepper NEMA."); - LOG(DEBUG_ANY, "[STEPPERS]: Slew Microsteps : %d", DEC_SLEW_MICROSTEPPING); - LOG(DEBUG_ANY, "[STEPPERS]: Stepper SPR : %d", DEC_STEPPER_SPR); - LOG(DEBUG_ANY, "[STEPPERS]: Transmission : %f", DEC_TRANSMISSION); + LOG(DEBUG_ANY, "[STEPPERS]: Slew Microsteps : %d", DEC_SLEW_MICROSTEPPING); + LOG(DEBUG_ANY, "[STEPPERS]: Guide Microsteps : %d", DEC_GUIDE_MICROSTEPPING); + LOG(DEBUG_ANY, "[STEPPERS]: Stepper SPR : %d", DEC_STEPPER_SPR); + LOG(DEBUG_ANY, "[STEPPERS]: Transmission : %f", DEC_TRANSMISSION); #ifdef NEW_STEPPER_LIB - LOG(DEBUG_ANY, "[STEPPERS]: Driver Slew SPR : %l", config::Dec::DRIVER_SPR_SLEW); - LOG(DEBUG_ANY, "[STEPPERS]: Driver Trk SPR : %l", config::Dec::DRIVER_SPR_TRK); - LOG(DEBUG_ANY, "[STEPPERS]: SPR Slew : %f", config::Dec::SPR_SLEW); - LOG(DEBUG_ANY, "[STEPPERS]: SPR Trk : %f", config::Dec::SPR_TRK); - LOG(DEBUG_ANY, "[STEPPERS]: Speed Slew : %f", config::Dec::SPEED_SLEW); - LOG(DEBUG_ANY, "[STEPPERS]: Accel Slew : %f", config::Dec::ACCEL_SLEW); - LOG(DEBUG_ANY, "[STEPPERS]: Speed Trk : %f", config::Dec::SPEED_TRK); + LOG(DEBUG_ANY, "[STEPPERS]: Driver Slew SPR : %l", config::Dec::DRIVER_SPR_SLEW); + LOG(DEBUG_ANY, "[STEPPERS]: Driver Trk SPR : %l", config::Dec::DRIVER_SPR_TRK); + LOG(DEBUG_ANY, "[STEPPERS]: SPR Slew : %f", config::Dec::SPR_SLEW); + LOG(DEBUG_ANY, "[STEPPERS]: SPR Trk : %f", config::Dec::SPR_TRK); + LOG(DEBUG_ANY, "[STEPPERS]: Speed Slew : %f", config::Dec::SPEED_SLEW); + LOG(DEBUG_ANY, "[STEPPERS]: Accel Slew : %f", config::Dec::ACCEL_SLEW); + LOG(DEBUG_ANY, "[STEPPERS]: Speed Trk : %f", config::Dec::SPEED_TRK); LOG(DEBUG_ANY, "[STEPPERS]: Configure DEC stepper NEMA..."); mount.configureDECStepper(DECmotorPin1, DECmotorPin2, config::Dec::SPEED_SLEW, config::Dec::ACCEL_SLEW); #else diff --git a/src/f_serial.hpp b/src/f_serial.hpp index ba4283f4..ad3741a7 100644 --- a/src/f_serial.hpp +++ b/src/f_serial.hpp @@ -109,12 +109,13 @@ void processSerialData() // ESP needs to call this in a loop :_( void processSerialData() { - char buffer[2]; + static char buffer[20]; + static unsigned int index = 0; while (Serial.available() > 0) { - if (Serial.readBytes(buffer, 1) == 1) + if (Serial.readBytes((buffer + index), 1) == 1) { - if (buffer[0] == 0x06) + if (buffer[index] == 0x06) { LOG(DEBUG_SERIAL, "[SERIAL]: Received: ACK request, replying P"); // When not debugging, print the result to the serial port . @@ -122,13 +123,16 @@ void processSerialData() #if (DEBUG_LEVEL == DEBUG_NONE) || (DEBUG_SEPARATE_SERIAL == 1) Serial.print('P'); #endif + index = 0; } - else + else if (buffer[index] == '#') { - String inCmd = String(buffer[0]) + Serial.readStringUntil('#'); + // Ignoring trailing hash + buffer[index] = '\0'; + const String inCmd = String(buffer); LOG(DEBUG_SERIAL, "[SERIAL]: ReceivedCommand(%d chars): [%s]", inCmd.length(), inCmd.c_str()); - String retVal = MeadeCommandProcessor::instance()->processCommand(inCmd); + const String retVal = MeadeCommandProcessor::instance()->processCommand(inCmd); if (retVal != "") { LOG(DEBUG_SERIAL, "[SERIAL]: RepliedWith: [%s]", retVal.c_str()); @@ -138,9 +142,16 @@ void processSerialData() Serial.print(retVal); #endif } - else + // Wait for next command + index = 0; + } + else if (buffer[index] >= ' ') + { + index++; + if (index >= sizeof(buffer)) { - LOG(DEBUG_SERIAL, "[SERIAL]: NoReply"); + LOG(DEBUG_SERIAL, "[SERIAL]: Command buffer overflow! Ignoring received data."); + index = 0; } } }