Skip to content

Commit

Permalink
Merge pull request #356 from synthetos/issue-354-set-status-reports
Browse files Browse the repository at this point in the history
Fix for issues #298 and #354 - changing of status report not working
  • Loading branch information
aldenhart authored May 30, 2018
2 parents 51f93aa + 876d19e commit f038a7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions g2core/g2core.cppproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<InterfaceName>SWD</InterfaceName>
</ToolOptions>
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
<ToolNumber>J41800004259</ToolNumber>
<ToolNumber>J41800019454</ToolNumber>
<ToolName>Atmel-ICE</ToolName>
</com_atmel_avrdbg_tool_atmelice>
<UseGdb>True</UseGdb>
Expand All @@ -100,7 +100,7 @@
<HWProgramCounterSampling>True</HWProgramCounterSampling>
</PercepioTrace>
<preserveEEPROM>true</preserveEEPROM>
<avrtoolserialnumber>J41800004259</avrtoolserialnumber>
<avrtoolserialnumber>J41800019454</avrtoolserialnumber>
<avrdeviceexpectedsignature>0x284E0A60</avrdeviceexpectedsignature>
<avrtoolinterfaceclock>2000000</avrtoolinterfaceclock>
<custom>
Expand Down
18 changes: 13 additions & 5 deletions g2core/json_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,21 @@ void json_parse_for_exec(char *str, bool execute)
static stat_t _json_parser_execute(nvObj_t *nv) {

do {
if (nv->valuetype == TYPE_PARENT) {
// anything?
} else if (nv->valuetype == TYPE_NULL) { // means GET the value
if (nv->valuetype == TYPE_PARENT) { // added as partial fix for Issue #298:
// Reading values with nested JSON changes values in inches mode
if (strcmp(nv->token, "sr") == 0) { // Hack to execute Set Status Report (SR parent) See end note (*)
return (nv_set(nv));
}

} else if (nv->valuetype == TYPE_NULL) { // means run the GET function to get the value
ritorno(nv_get(nv)); // ritorno returns w/status on any errors
if (nv->valuetype == TYPE_PARENT) { // This will be true if you read a group. Exit now
return (STAT_OK);
}
} else {
} else { // otherwise, run the SET function
cm_parse_clear(*nv->stringp); // parse Gcode and clear alarms if M30 or M2 is found
ritorno(cm_is_alarmed()); // return error status if in alarm, shutdown or panic
ritorno(nv_set(nv)); // set value or call a function (e.g. gcode)
ritorno(nv_set(nv)); // run the SET function to set value or execute something (e.g. gcode)
nv_persist(nv);
}
if ((nv = nv->nx) == NULL) {
Expand All @@ -136,6 +140,10 @@ static stat_t _json_parser_execute(nvObj_t *nv) {
return (STAT_OK); // only successful commands exit through this point
}

// (*) Note: The JSON / token system is essentially flat, as it was derived from a command-line flat-ASCII approach
// If the JSON objects had proper recursive descent handlers that just passed the remaining string (at that level)
// off for further processing, we would not need to do this hack. A fix is in the works. For now, this is OK.

static stat_t _json_parser_kernal(nvObj_t *nv, char *str)
{
stat_t status;
Expand Down

0 comments on commit f038a7a

Please sign in to comment.