Added proper JSON handling for read-only parameters; fixed string overflow in hw_get_id(). Now passes regressions in g2-0.99/002-config/02-settings/settings-version.json

This commit is contained in:
Alden Hart
2016-12-30 10:39:49 -05:00
parent c4fdc3205f
commit 245e32ae1d
11 changed files with 27 additions and 20 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ using Motate::OutputPin;
#define MILLISECONDS_PER_TICK 1 // MS for system tick (systick * N)
#define SYS_ID_DIGITS 12 // actual digits in system ID (up to 16)
#define SYS_ID_LEN 16 // total length including dashes and NUL
#define SYS_ID_LEN 24 // total length including dashes and NUL
/************************************************************************************
**** ARM SAM3X8E SPECIFIC HARDWARE *************************************************
+1 -1
View File
@@ -87,7 +87,7 @@ using Motate::OutputPin;
#define MILLISECONDS_PER_TICK 1 // MS for system tick (systick * N)
#define SYS_ID_DIGITS 12 // actual digits in system ID (up to 16)
#define SYS_ID_LEN 16 // total length including dashes and NUL
#define SYS_ID_LEN 24 // total length including dashes and NUL
/************************************************************************************
**** ARM SAM3X8E SPECIFIC HARDWARE *************************************************
+1 -1
View File
@@ -87,7 +87,7 @@ using Motate::OutputPin;
#define MILLISECONDS_PER_TICK 1 // MS for system tick (systick * N)
#define SYS_ID_DIGITS 12 // actual digits in system ID (up to 16)
#define SYS_ID_LEN 16 // total length including dashes and NUL
#define SYS_ID_LEN 24 // total length including dashes and NUL
/************************************************************************************
**** ARM SAM3X8E SPECIFIC HARDWARE *************************************************
+1 -1
View File
@@ -87,7 +87,7 @@ using Motate::OutputPin;
#define MILLISECONDS_PER_TICK 1 // MS for system tick (systick * N)
#define SYS_ID_DIGITS 12 // actual digits in system ID (up to 16)
#define SYS_ID_LEN 16 // total length including dashes and NUL
#define SYS_ID_LEN 24 // total length including dashes and NUL
/************************************************************************************
**** ARM SAM3X8E SPECIFIC HARDWARE *************************************************
+1 -1
View File
@@ -86,7 +86,7 @@ using Motate::OutputPin;
#define MILLISECONDS_PER_TICK 1 // MS for system tick (systick * N)
#define SYS_ID_DIGITS 12 // actual digits in system ID (up to 16)
#define SYS_ID_LEN 16 // total length including dashes and NUL
#define SYS_ID_LEN 24 // total length including dashes and NUL
/************************************************************************************
**** ARM SAM3X8E SPECIFIC HARDWARE *************************************************
+1 -1
View File
@@ -85,7 +85,7 @@ using Motate::OutputPin;
#define MILLISECONDS_PER_TICK 1 // MS for system tick (systick * N)
#define SYS_ID_DIGITS 12 // actual digits in system ID (up to 16)
#define SYS_ID_LEN 16 // total length including dashes and NUL
#define SYS_ID_LEN 24 // total length including dashes and NUL
/************************************************************************************
**** ARM SAM3X8E SPECIFIC HARDWARE *************************************************
+1 -1
View File
@@ -84,7 +84,7 @@ using Motate::OutputPin;
#define MILLISECONDS_PER_TICK 1 // MS for system tick (systick * N)
#define SYS_ID_DIGITS 12 // actual digits in system ID (up to 16)
#define SYS_ID_LEN 16 // total length including dashes and NUL
#define SYS_ID_LEN 24 // total length including dashes and NUL
/************************************************************************************
**** ARM SAM3X8E SPECIFIC HARDWARE *************************************************
+9 -3
View File
@@ -239,7 +239,8 @@ stat_t get_flt(nvObj_t *nv)
}
/* Generic sets()
* set_nul() - set nothing
* set_nul() - set nothing, return OK
* set_ro() - set nothing, return read-only error
* set_ui8() - set value as 8 bit uint8_t value
* set_int8() - set value as an 8 bit int8_t value
* set_01() - set a 0 or 1 uint8_t value with validation
@@ -249,8 +250,13 @@ stat_t get_flt(nvObj_t *nv)
* set_data() - set value as 32 bit integer blind cast
* set_flt() - set value as float
*/
//stat_t set_nul(nvObj_t *nv) { return (STAT_PARAMETER_IS_READ_ONLY); }
stat_t set_nul(nvObj_t *nv) { return (STAT_OK); } // hack until JSON is refactored
stat_t set_nul(nvObj_t *nv) { return (STAT_OK); }
stat_t set_ro(nvObj_t *nv) {
nv->valuetype = TYPE_NULL;
return (STAT_PARAMETER_IS_READ_ONLY);
}
stat_t set_ui8(nvObj_t *nv)
{
Executable → Regular
+2 -1
View File
@@ -317,7 +317,8 @@ bool nv_index_lt_groups(index_t index); // (see config_app.c)
bool nv_group_is_prefixed(char *group);
// generic internal functions and accessors
stat_t set_nul(nvObj_t *nv); // set nothing
stat_t set_nul(nvObj_t *nv); // set nothing, return OK
stat_t set_ro(nvObj_t *nv); // set nothing, return read-only error
stat_t set_ui8(nvObj_t *nv); // set uint8_t value
stat_t set_int8(nvObj_t *nv); // set signed 8 bit integer
stat_t set_01(nvObj_t *nv); // set a 0 or 1 value with validation
+8 -8
View File
@@ -102,14 +102,14 @@ static stat_t get_tick(nvObj_t *nv); // get system tick count
* the %f in the corresponding format string to set text mode display precision
*/
const cfgItem_t cfgArray[] = {
// group token flags p, print_func, get_func, set_func, target for get/set, default value
{ "sys", "fb", _fipn,2, hw_print_fb, get_flt, set_nul, (float *)&cs.fw_build, G2CORE_FIRMWARE_BUILD }, // MUST BE FIRST!
{ "sys", "fbs",_fn, 2, hw_print_fbs,hw_get_fbs,set_nul, (float *)&cs.null, 0 },
{ "sys", "fbc",_fn, 2, hw_print_fbc,hw_get_fbc,set_nul, (float *)&cs.null, 0 },
{ "sys", "fv", _fipn,2, hw_print_fv, get_flt, set_nul, (float *)&cs.fw_version, G2CORE_FIRMWARE_VERSION },
{ "sys", "hp", _fipn,0, hw_print_hp, get_flt, set_flt, (float *)&cs.hw_platform, G2CORE_HARDWARE_PLATFORM },
{ "sys", "hv", _fipn,0, hw_print_hv, get_flt, hw_set_hv,(float *)&cs.hw_version, G2CORE_HARDWARE_VERSION },
{ "sys", "id", _fn, 0, hw_print_id, hw_get_id, set_nul, (float *)&cs.null, 0 }, // device ID (ASCII signature)
// group token flags p, print_func, get_func, set_func, target for get/set, default value
{ "sys", "fb", _fipn,2, hw_print_fb, get_flt, set_ro, (float *)&cs.fw_build, G2CORE_FIRMWARE_BUILD }, // MUST BE FIRST!
{ "sys", "fbs",_fn, 2, hw_print_fbs,hw_get_fbs,set_ro, (float *)&cs.null, 0 },
{ "sys", "fbc",_fn, 2, hw_print_fbc,hw_get_fbc,set_ro, (float *)&cs.null, 0 },
{ "sys", "fv", _fipn,2, hw_print_fv, get_flt, set_ro, (float *)&cs.fw_version, G2CORE_FIRMWARE_VERSION },
{ "sys", "hp", _fipn,0, hw_print_hp, get_flt, set_ro, (float *)&cs.hw_platform, G2CORE_HARDWARE_PLATFORM },
{ "sys", "hv", _fipn,0, hw_print_hv, get_flt, set_ro, (float *)&cs.hw_version, G2CORE_HARDWARE_VERSION },
{ "sys", "id", _fn, 0, hw_print_id, hw_get_id, set_ro, (float *)&cs.null, 0 }, // device ID (ASCII signature)
// dynamic model attributes for reporting purposes (up front for speed)
{ "", "stat",_f0, 0, cm_print_stat, cm_get_stat, set_nul,(float *)&cs.null, 0 }, // combined machine state
Executable → Regular
+1 -1
View File
@@ -154,7 +154,7 @@ void loop() {
}
/*
* Traps for debugging. These must be in mail.cpp for proper linker ordering
* Traps for debugging. These must be in main.cpp for proper linker ordering
*/
void MemManage_Handler ( void ) { __asm__("BKPT"); }