From 5a0d99a40af2c0c64a9529da0c29f10c7f3a38fc Mon Sep 17 00:00:00 2001 From: Alden Hart Date: Sat, 24 Dec 2016 10:03:19 -0500 Subject: [PATCH] Fixed $$ lockup problem. Root cause was mis-handling of stale NV lists. --- g2core/config_app.cpp | 8 ++++---- g2core/error.h | 2 +- g2core/g2core.cppproj | 12 ++++++------ g2core/json_parser.cpp | 7 +++++-- 4 files changed, 16 insertions(+), 13 deletions(-) mode change 100755 => 100644 g2core/json_parser.cpp diff --git a/g2core/config_app.cpp b/g2core/config_app.cpp index 9ddff796..6ff570b0 100644 --- a/g2core/config_app.cpp +++ b/g2core/config_app.cpp @@ -1117,7 +1117,7 @@ static stat_t _do_outputs(nvObj_t *nv) // print parameters for all output group } return (STAT_COMPLETE); } -/* + static stat_t _do_heaters(nvObj_t *nv) // print parameters for all heater groups { char group[GROUP_LEN]; @@ -1127,7 +1127,7 @@ static stat_t _do_heaters(nvObj_t *nv) // print parameters for all heater group } return (STAT_COMPLETE); } -*/ + static stat_t _do_all(nvObj_t *nv) // print all parameters { _do_group(nv, (char *)"sys"); // System group @@ -1135,10 +1135,10 @@ static stat_t _do_all(nvObj_t *nv) // print all parameters _do_axes(nv); _do_inputs(nv); _do_outputs(nv); -// _do_heaters(nv); // there are no text mode prints for heaters + _do_heaters(nv); // there are no text mode prints for heaters _do_group(nv, (char *)"p1"); // PWM group _do_offsets(nv); // coordinate system offsets - return (STAT_OK); + return (STAT_COMPLETE); // STAT_COMPLETE suppresses a second JSON write that would cause a fault } /*********************************************************************************** diff --git a/g2core/error.h b/g2core/error.h index 5c802261..ff8ec5a0 100644 --- a/g2core/error.h +++ b/g2core/error.h @@ -204,7 +204,7 @@ char *get_status_message(stat_t status); #define STAT_MAX_DEPTH_EXCEEDED 115 // JSON exceeded maximum nesting depth #define STAT_VALUE_TYPE_ERROR 116 // JSON value does not agree with variable type -#define STAT_INPUT_FROM_MUTED_CHANNEL_ERROR 117 // input from a muted channel was ignored +#define STAT_INPUT_FROM_MUTED_CHANNEL_ERROR 117 // input from a muted channel was ignored #define STAT_ERROR_118 118 #define STAT_ERROR_119 119 diff --git a/g2core/g2core.cppproj b/g2core/g2core.cppproj index f6402809..591d31b0 100644 --- a/g2core/g2core.cppproj +++ b/g2core/g2core.cppproj @@ -5,7 +5,7 @@ 7.0 com.Atmel.ARMGCC.CPP {44ea8fec-55d7-4149-8a78-a574fc26bf51} - ATSAMS70N19 + ATSAM3X8C none Executable CPP @@ -68,12 +68,12 @@ - 2000000 + 10000000 SWD com.atmel.avrdbg.tool.atmelice - J41800019454 + J41800036434 Atmel-ICE True @@ -100,9 +100,9 @@ True true - J41800019454 - 0xA11D0A00 - 2000000 + J41800036434 + 0x284E0A60 + 10000000 diff --git a/g2core/json_parser.cpp b/g2core/json_parser.cpp old mode 100755 new mode 100644 index 7a8859a9..cd9a05d0 --- a/g2core/json_parser.cpp +++ b/g2core/json_parser.cpp @@ -568,10 +568,13 @@ void json_print_response(uint8_t status, const bool only_to_muted /*= false*/) nv->valuetype = TYPE_EMPTY; } } - } while ((nv = nv->nx) != NULL); + } while ((nv = nv->nx) != NULL); // Emergency escape } - // Footer processing + // Footer processing - wind to the end of the populated blocks + if (nv == NULL) { // this can happen when processing a stale list + return; //...that already has a null-terminated footer + } while(nv->valuetype != TYPE_EMPTY) { // find a free nvObj at end of the list... if ((nv = nv->nx) == NULL) { // oops! No free nvObj! rpt_exception(STAT_JSON_OUTPUT_TOO_LONG, "json_print_response() json too long"); // report this as an exception