Skip to content

Commit

Permalink
V3.3.8 AlaMode and no longer require opening serial port to trigger G…
Browse files Browse the repository at this point in the history
…rbl reset. We now send Ctrl-X if no response to force Grbl version string response
  • Loading branch information
zapmaker committed May 16, 2013
1 parent dd7446f commit c4465ad
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 14 deletions.
2 changes: 1 addition & 1 deletion definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define OPEN_BUTTON_TEXT "Open"
#define CLOSE_BUTTON_TEXT "Close / Reset"

#define GRBL_CONTROLLER_NAME_AND_VERSION "Grbl Controller 3.3.7"
#define GRBL_CONTROLLER_NAME_AND_VERSION "Grbl Controller 3.3.8"

#define LOG_MSG_TYPE_DIAG "DIAG"
#define LOG_MSG_TYPE_STATUS "STATUS"
Expand Down
55 changes: 43 additions & 12 deletions gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,33 @@ void GCode::sendGcode(QString line)
resetState.set(false);

QString result;
if (!waitForStartupBanner(result, SHORT_WAIT_SEC))
return;
if (!waitForStartupBanner(result, SHORT_WAIT_SEC, false))
{
if (shutdownState.get() || resetState.get())
return;
// it is possible that we are already connected and missed the
// signon banner. Force a reset (is this ok?) to get the banner

emit addListOut("(CTRL-X)");

char buf[2] = {0};

buf[0] = CTRL_X;

diag("SENDING: 0x%02X (CTRL-X) to check presence of Grbl\n", buf[0]);

if (!port.SendBuf(buf, 1))
{
QString msg = "Sending to port failed";
err("%s", msg.toLocal8Bit().constData());
emit addList(msg);
emit sendMsg(msg);
return;
}

if (!waitForStartupBanner(result, SHORT_WAIT_SEC, true))
return;
}

checkMeasurementUnits = true;
}
Expand Down Expand Up @@ -613,7 +638,7 @@ bool GCode::waitForOk(QString& result, int waitSec, bool sentReqForLocation, boo
return status;
}

bool GCode::waitForStartupBanner(QString& result, int waitSec)
bool GCode::waitForStartupBanner(QString& result, int waitSec, bool failOnNoFound)
{
char tmp[BUF_SIZE + 1] = {0};
int count = 0;
Expand Down Expand Up @@ -647,11 +672,14 @@ bool GCode::waitForStartupBanner(QString& result, int waitSec)
{
if (!checkGrbl(tmpTrim))
{
QString msg("Expecting Grbl version string. Unable to parse response.");
emit addList(msg);
emit sendMsg(msg);
if (failOnNoFound)
{
QString msg("Expecting Grbl version string. Unable to parse response.");
emit addList(msg);
emit sendMsg(msg);

closePort(false);
closePort(false);
}
}
else
{
Expand All @@ -665,13 +693,16 @@ bool GCode::waitForStartupBanner(QString& result, int waitSec)

if (count > waitCount)
{
// waited too long for a response, fail
if (failOnNoFound)
{
// waited too long for a response, fail

QString msg("No data from COM port after connect. Expecting Grbl version string.");
emit addList(msg);
emit sendMsg(msg);
QString msg("No data from COM port after connect. Expecting Grbl version string.");
emit addList(msg);
emit sendMsg(msg);

closePort(false);
closePort(false);
}

status = false;
break;
Expand Down
2 changes: 1 addition & 1 deletion gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public slots:
private:
bool sendGcodeLocal(QString line, bool recordResponseOnFail = false, int waitSec = -1, bool aggressive = false);
bool waitForOk(QString& result, int waitCount, bool sentReqForLocation, bool sentReqForParserState, bool aggressive);
bool waitForStartupBanner(QString& result, int waitSec);
bool waitForStartupBanner(QString& result, int waitSec, bool failOnNoFound);
bool sendGcodeInternal(QString line, QString& result, bool recordResponseOnFail, int waitSec, bool aggressive);
QString removeUnsupportedCommands(QString line);
bool isGCommandValid(float value);
Expand Down

0 comments on commit c4465ad

Please sign in to comment.