@@ -115,17 +115,21 @@ void json_parse_for_exec(char *str, bool execute)
115
115
static stat_t _json_parser_execute (nvObj_t *nv) {
116
116
117
117
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
121
125
ritorno (nv_get (nv)); // ritorno returns w/status on any errors
122
126
if (nv->valuetype == TYPE_PARENT) { // This will be true if you read a group. Exit now
123
127
return (STAT_OK);
124
128
}
125
- } else {
129
+ } else { // otherwise, run the SET function
126
130
cm_parse_clear (*nv->stringp ); // parse Gcode and clear alarms if M30 or M2 is found
127
131
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)
129
133
nv_persist (nv);
130
134
}
131
135
if ((nv = nv->nx ) == NULL ) {
@@ -136,6 +140,10 @@ static stat_t _json_parser_execute(nvObj_t *nv) {
136
140
return (STAT_OK); // only successful commands exit through this point
137
141
}
138
142
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
+
139
147
static stat_t _json_parser_kernal (nvObj_t *nv, char *str)
140
148
{
141
149
stat_t status;
0 commit comments