Show error number when move fails

pull/118/head
Tim Evers 2019-10-16 22:41:06 +02:00
parent 21e89ec419
commit 0e5179f87f
5 changed files with 31 additions and 10 deletions

View File

@ -2,8 +2,8 @@
//#define RAMPS_V14
//#define FARMDUINO_V10
//#define FARMDUINO_V14
#define FARMDUINO_EXP_V20
#define FARMDUINO_V14
//#define FARMDUINO_EXP_V20
#else

View File

@ -10,6 +10,18 @@
#include "Arduino.h"
#include "pins.h"
enum ErrorListEnum
{
ERR_NO_ERROR = 0,
ERR_EMERGENCY_STOP = 1,
ERR_TIMEOUT = 2,
ERR_STALL_DETECTED = 3,
ERR_INVALID_COMMAND = 14,
ERR_PARAMS_NOT_OK = 15,
};
class CurrentState
{
public:
@ -54,6 +66,8 @@ private:
long stepsPerMmY;
long stepsPerMmZ;
int errorCode = 0;
bool emergencyStop = false;
};

View File

@ -84,6 +84,7 @@ int GCodeProcessor::execute(Command *command)
{
Serial.print(COMM_REPORT_NO_CONFIG);
CurrentState::getInstance()->printQAndNewLine();
CurrentState::getInstance()->setLastError(ERR_PARAMS_NOT_OK);
return -1;
}
}
@ -95,6 +96,7 @@ int GCodeProcessor::execute(Command *command)
Serial.print(COMM_REPORT_BAD_CMD);
CurrentState::getInstance()->printQAndNewLine();
CurrentState::getInstance()->setLastError(ERR_INVALID_COMMAND);
if (LOGGING)
{
@ -107,6 +109,7 @@ int GCodeProcessor::execute(Command *command)
{
Serial.print(COMM_REPORT_BAD_CMD);
CurrentState::getInstance()->printQAndNewLine();
CurrentState::getInstance()->setLastError(ERR_INVALID_COMMAND);
if (LOGGING)
{
@ -123,6 +126,7 @@ int GCodeProcessor::execute(Command *command)
{
Serial.print(COMM_REPORT_BAD_CMD);
CurrentState::getInstance()->printQAndNewLine();
CurrentState::getInstance()->setLastError(ERR_INVALID_COMMAND);
Serial.println("R99 handler == NULL\r\n");
return -1;
@ -197,6 +201,8 @@ int GCodeProcessor::execute(Command *command)
else
{
Serial.print(COMM_REPORT_CMD_ERROR);
Serial.print(" V");
Serial.print(CurrentState::getInstance()->getLastError());
CurrentState::getInstance()->printQAndNewLine();
}

View File

@ -484,7 +484,7 @@ int StepperControl::moveToCoords(double xDestScaled, double yDestScaled, double
}
else
{
error = 1;
error = ERR_STALL_DETECTED;
}
}
@ -502,7 +502,7 @@ int StepperControl::moveToCoords(double xDestScaled, double yDestScaled, double
}
else
{
error = 1;
error = ERR_STALL_DETECTED;
}
}
@ -521,7 +521,7 @@ int StepperControl::moveToCoords(double xDestScaled, double yDestScaled, double
}
else
{
error = 1;
error = ERR_STALL_DETECTED;
}
}
@ -563,21 +563,21 @@ int StepperControl::moveToCoords(double xDestScaled, double yDestScaled, double
serialBuffer += COMM_REPORT_TIMEOUT_X;
serialBuffer += "\r\n";
serialBuffer += "R99 timeout X axis\r\n";
error = 2;
error = ERR_TIMEOUT;
}
if (axisActive[1] == true && ((millis() >= timeStart && millis() - timeStart > timeOut[1] * 1000) || (millis() < timeStart && millis() > timeOut[1] * 1000)))
{
serialBuffer += COMM_REPORT_TIMEOUT_Y;
serialBuffer += "\r\n";
serialBuffer += "R99 timeout Y axis\r\n";
error = 2;
error = ERR_TIMEOUT;
}
if (axisActive[2] == true && ((millis() >= timeStart && millis() - timeStart > timeOut[2] * 1000) || (millis() < timeStart && millis() > timeOut[2] * 1000)))
{
serialBuffer += COMM_REPORT_TIMEOUT_Z;
serialBuffer += "\r\n";
serialBuffer += "R99 timeout Z axis\r\n";
error = 2;
error = ERR_TIMEOUT;
}
// Check if there is an emergency stop command
@ -601,7 +601,7 @@ int StepperControl::moveToCoords(double xDestScaled, double yDestScaled, double
axisActive[1] = false;
axisActive[2] = false;
error = 1;
error = ERR_EMERGENCY_STOP;
}
}
@ -751,6 +751,7 @@ int StepperControl::moveToCoords(double xDestScaled, double yDestScaled, double
if (emergencyStop)
{
CurrentState::getInstance()->setEmergencyStop();
error = ERR_EMERGENCY_STOP;
}
Serial.print("R99 error ");

View File

@ -63,7 +63,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\src;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\hardware\avr\1.6.19\libraries\SPI\src;$(ProjectDir)..\..\..\..\Users\Bro\Documents\Arduino\libraries\TMC2130Stepper\src;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\hardware\avr\1.6.19\libraries\EEPROM\src;$(ProjectDir)..\..\..\..\Program Files (x86)\Arduino\libraries\Servo\src;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\hardware\avr\1.6.19\cores\arduino;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\hardware\avr\1.6.19\variants\mega;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\avr\include;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\avr\include\avr;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\lib\gcc\avr\4.8.1\include;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\lib\gcc\avr\4.9.2\include;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\lib\gcc\avr\4.9.3\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\src;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\hardware\avr\1.6.19\libraries\SPI\src;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\hardware\avr\1.6.19\libraries\EEPROM\src;$(ProjectDir)..\..\..\..\Program Files (x86)\Arduino\libraries\Servo\src;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\hardware\avr\1.6.19\cores\arduino;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\hardware\avr\1.6.19\variants\mega;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\avr\include;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\avr\include\avr;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\lib\gcc\avr\4.8.1\include;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\lib\gcc\avr\4.9.2\include;$(ProjectDir)..\..\..\..\Users\Bro\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\lib\gcc\avr\4.9.3\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>$(ProjectDir)__vm\.farmbot-arduino-controller.vsarduino.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PreprocessorDefinitions>__AVR_atmega2560__;__AVR_ATmega2560__;F_CPU=16000000L;ARDUINO=10802;ARDUINO_AVR_MEGA2560;ARDUINO_ARCH_AVR;__cplusplus=201103L;_VMICRO_INTELLISENSE;%(PreprocessorDefinitions)</PreprocessorDefinitions>