Skip to content

Commit f038a7a

Browse files
authored
Merge pull request #356 from synthetos/issue-354-set-status-reports
Fix for issues #298 and #354 - changing of status report not working
2 parents 51f93aa + 876d19e commit f038a7a

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

g2core/g2core.cppproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<InterfaceName>SWD</InterfaceName>
7474
</ToolOptions>
7575
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
76-
<ToolNumber>J41800004259</ToolNumber>
76+
<ToolNumber>J41800019454</ToolNumber>
7777
<ToolName>Atmel-ICE</ToolName>
7878
</com_atmel_avrdbg_tool_atmelice>
7979
<UseGdb>True</UseGdb>
@@ -100,7 +100,7 @@
100100
<HWProgramCounterSampling>True</HWProgramCounterSampling>
101101
</PercepioTrace>
102102
<preserveEEPROM>true</preserveEEPROM>
103-
<avrtoolserialnumber>J41800004259</avrtoolserialnumber>
103+
<avrtoolserialnumber>J41800019454</avrtoolserialnumber>
104104
<avrdeviceexpectedsignature>0x284E0A60</avrdeviceexpectedsignature>
105105
<avrtoolinterfaceclock>2000000</avrtoolinterfaceclock>
106106
<custom>

g2core/json_parser.cpp

+13-5
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,21 @@ void json_parse_for_exec(char *str, bool execute)
115115
static stat_t _json_parser_execute(nvObj_t *nv) {
116116

117117
do {
118-
if (nv->valuetype == TYPE_PARENT) {
119-
// anything?
120-
} else if (nv->valuetype == TYPE_NULL) { // means GET the value
118+
if (nv->valuetype == TYPE_PARENT) { // added as partial fix for Issue #298:
119+
// Reading values with nested JSON changes values in inches mode
120+
if (strcmp(nv->token, "sr") == 0) { // Hack to execute Set Status Report (SR parent) See end note (*)
121+
return (nv_set(nv));
122+
}
123+
124+
} else if (nv->valuetype == TYPE_NULL) { // means run the GET function to get the value
121125
ritorno(nv_get(nv)); // ritorno returns w/status on any errors
122126
if (nv->valuetype == TYPE_PARENT) { // This will be true if you read a group. Exit now
123127
return (STAT_OK);
124128
}
125-
} else {
129+
} else { // otherwise, run the SET function
126130
cm_parse_clear(*nv->stringp); // parse Gcode and clear alarms if M30 or M2 is found
127131
ritorno(cm_is_alarmed()); // return error status if in alarm, shutdown or panic
128-
ritorno(nv_set(nv)); // set value or call a function (e.g. gcode)
132+
ritorno(nv_set(nv)); // run the SET function to set value or execute something (e.g. gcode)
129133
nv_persist(nv);
130134
}
131135
if ((nv = nv->nx) == NULL) {
@@ -136,6 +140,10 @@ static stat_t _json_parser_execute(nvObj_t *nv) {
136140
return (STAT_OK); // only successful commands exit through this point
137141
}
138142

143+
// (*) Note: The JSON / token system is essentially flat, as it was derived from a command-line flat-ASCII approach
144+
// If the JSON objects had proper recursive descent handlers that just passed the remaining string (at that level)
145+
// off for further processing, we would not need to do this hack. A fix is in the works. For now, this is OK.
146+
139147
static stat_t _json_parser_kernal(nvObj_t *nv, char *str)
140148
{
141149
stat_t status;

0 commit comments

Comments
 (0)