Skip to content

Commit 9d372ec

Browse files
authored
Merge pull request #207 from synthetos/dev-204-dollar-dollar-fix
Fixed $$ lockup problem. Root cause was mis-handling of stale NV lists.
2 parents 295d7ba + 5a0d99a commit 9d372ec

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

g2core/config_app.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ static stat_t _do_outputs(nvObj_t *nv) // print parameters for all output group
11171117
}
11181118
return (STAT_COMPLETE);
11191119
}
1120-
/*
1120+
11211121
static stat_t _do_heaters(nvObj_t *nv) // print parameters for all heater groups
11221122
{
11231123
char group[GROUP_LEN];
@@ -1127,18 +1127,18 @@ static stat_t _do_heaters(nvObj_t *nv) // print parameters for all heater group
11271127
}
11281128
return (STAT_COMPLETE);
11291129
}
1130-
*/
1130+
11311131
static stat_t _do_all(nvObj_t *nv) // print all parameters
11321132
{
11331133
_do_group(nv, (char *)"sys"); // System group
11341134
_do_motors(nv);
11351135
_do_axes(nv);
11361136
_do_inputs(nv);
11371137
_do_outputs(nv);
1138-
// _do_heaters(nv); // there are no text mode prints for heaters
1138+
_do_heaters(nv); // there are no text mode prints for heaters
11391139
_do_group(nv, (char *)"p1"); // PWM group
11401140
_do_offsets(nv); // coordinate system offsets
1141-
return (STAT_OK);
1141+
return (STAT_COMPLETE); // STAT_COMPLETE suppresses a second JSON write that would cause a fault
11421142
}
11431143

11441144
/***********************************************************************************

g2core/error.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ char *get_status_message(stat_t status);
204204
#define STAT_MAX_DEPTH_EXCEEDED 115 // JSON exceeded maximum nesting depth
205205
#define STAT_VALUE_TYPE_ERROR 116 // JSON value does not agree with variable type
206206

207-
#define STAT_INPUT_FROM_MUTED_CHANNEL_ERROR 117 // input from a muted channel was ignored
207+
#define STAT_INPUT_FROM_MUTED_CHANNEL_ERROR 117 // input from a muted channel was ignored
208208
#define STAT_ERROR_118 118
209209
#define STAT_ERROR_119 119
210210

g2core/g2core.cppproj

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ProjectVersion>7.0</ProjectVersion>
66
<ToolchainName>com.Atmel.ARMGCC.CPP</ToolchainName>
77
<ProjectGuid>{44ea8fec-55d7-4149-8a78-a574fc26bf51}</ProjectGuid>
8-
<avrdevice>ATSAMS70N19</avrdevice>
8+
<avrdevice>ATSAM3X8C</avrdevice>
99
<avrdeviceseries>none</avrdeviceseries>
1010
<OutputType>Executable</OutputType>
1111
<Language>CPP</Language>
@@ -68,12 +68,12 @@
6868
<com_atmel_avrdbg_tool_atmelice>
6969
<ToolOptions>
7070
<InterfaceProperties>
71-
<SwdClock>2000000</SwdClock>
71+
<SwdClock>10000000</SwdClock>
7272
</InterfaceProperties>
7373
<InterfaceName>SWD</InterfaceName>
7474
</ToolOptions>
7575
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
76-
<ToolNumber>J41800019454</ToolNumber>
76+
<ToolNumber>J41800036434</ToolNumber>
7777
<ToolName>Atmel-ICE</ToolName>
7878
</com_atmel_avrdbg_tool_atmelice>
7979
<UseGdb>True</UseGdb>
@@ -100,9 +100,9 @@
100100
<HWProgramCounterSampling>True</HWProgramCounterSampling>
101101
</PercepioTrace>
102102
<preserveEEPROM>true</preserveEEPROM>
103-
<avrtoolserialnumber>J41800019454</avrtoolserialnumber>
104-
<avrdeviceexpectedsignature>0xA11D0A00</avrdeviceexpectedsignature>
105-
<avrtoolinterfaceclock>2000000</avrtoolinterfaceclock>
103+
<avrtoolserialnumber>J41800036434</avrtoolserialnumber>
104+
<avrdeviceexpectedsignature>0x284E0A60</avrdeviceexpectedsignature>
105+
<avrtoolinterfaceclock>10000000</avrtoolinterfaceclock>
106106
<custom>
107107
<ToolOptions xmlns="">
108108
<InterfaceProperties>

g2core/json_parser.cpp

100755100644
+5-2
Original file line numberDiff line numberDiff line change
@@ -568,10 +568,13 @@ void json_print_response(uint8_t status, const bool only_to_muted /*= false*/)
568568
nv->valuetype = TYPE_EMPTY;
569569
}
570570
}
571-
} while ((nv = nv->nx) != NULL);
571+
} while ((nv = nv->nx) != NULL); // Emergency escape
572572
}
573573

574-
// Footer processing
574+
// Footer processing - wind to the end of the populated blocks
575+
if (nv == NULL) { // this can happen when processing a stale list
576+
return; //...that already has a null-terminated footer
577+
}
575578
while(nv->valuetype != TYPE_EMPTY) { // find a free nvObj at end of the list...
576579
if ((nv = nv->nx) == NULL) { // oops! No free nvObj!
577580
rpt_exception(STAT_JSON_OUTPUT_TOO_LONG, "json_print_response() json too long"); // report this as an exception

0 commit comments

Comments
 (0)