Big commit. Added nv->value_int, and changed nv_value to nv->value_flt. Many many things changed. Passes smoke test. Now on to some real regressions.

This commit is contained in:
Alden Hart
2017-03-19 20:27:53 -04:00
parent 36f8b9a9cc
commit 5f306e1657
15 changed files with 841 additions and 811 deletions
+17 -14
View File
@@ -121,9 +121,10 @@ static stat_t _text_parser_kernal(char *str, nvObj_t *nv)
*rd = NUL; // terminate at end of name
strncpy(nv->token, str, TOKEN_LEN);
str = ++rd;
nv->value = strtof(str, &rd); // rd used as end pointer
nv->value_int = atol(str); // collect the number as an integer
nv->value_flt = strtof(str, &rd); // collect the number as a float - rd used as end pointer
if (rd != str) {
nv->valuetype = TYPE_FLOAT;
nv->valuetype = TYPE_FLOAT; // provisionally set it as a float
}
}
@@ -132,6 +133,7 @@ static stat_t _text_parser_kernal(char *str, nvObj_t *nv)
return (STAT_UNRECOGNIZED_NAME);
}
strcpy(nv->group, cfgArray[nv->index].group); // capture the group string if there is one
nv_coerce_types(nv); // adjust types based on type fields in configApp table
// see if you need to strip the token - but only if in text mode
if ((cs.comm_request_mode == TEXT_MODE) && (nv_group_is_prefixed(nv->group))) {
@@ -218,9 +220,9 @@ void tx_print_flt(nvObj_t *nv) { text_print_flt(nv, fmt_flt);}
void tx_print(nvObj_t *nv) {
switch ((int8_t)nv->valuetype) {
case TYPE_FLOAT: { text_print_flt(nv, fmt_flt); break;}
case TYPE_INT: { text_print_int(nv, fmt_int); break;}
case TYPE_STRING:{ text_print_str(nv, fmt_str); break;}
case TYPE_FLOAT: { text_print_flt(nv, fmt_flt); break;}
case TYPE_INTEGER: { text_print_int(nv, fmt_int); break;}
case TYPE_STRING: { text_print_str(nv, fmt_str); break;}
// TYPE_NULL is not needed in this list as it does nothing
}
}
@@ -244,35 +246,36 @@ void text_print_str(nvObj_t *nv, const char *format)
void text_print_int(nvObj_t *nv, const char *format)
{
sprintf(cs.out_buf, format, (uint32_t)nv->value);
sprintf(cs.out_buf, format, nv->value_int);
xio_writeline(cs.out_buf);
}
void text_print_flt(nvObj_t *nv, const char *format)
{
sprintf(cs.out_buf, format, nv->value);
sprintf(cs.out_buf, format, nv->value_flt);
xio_writeline(cs.out_buf);
}
void text_print_flt_units(nvObj_t *nv, const char *format, const char *units)
{
sprintf(cs.out_buf, format, nv->value, units);
sprintf(cs.out_buf, format, nv->value_flt, units);
xio_writeline(cs.out_buf);
}
void text_print_bool(nvObj_t *nv, const char *format)
{
sprintf(cs.out_buf, format, !!((uint32_t)nv->value)?"True":"False");
// sprintf(cs.out_buf, format, !!((uint32_t)nv->value)?"True":"False");
sprintf(cs.out_buf, format, (nv->value_int ? "True" : "False"));
xio_writeline(cs.out_buf);
}
void text_print(nvObj_t *nv, const char *format) {
switch ((int8_t)nv->valuetype) {
case TYPE_NULL: { text_print_nul(nv, format); break;}
case TYPE_FLOAT: { text_print_flt(nv, format); break;}
case TYPE_INT: { text_print_int(nv, format); break;}
case TYPE_STRING:{ text_print_str(nv, format); break;}
case TYPE_BOOL: { text_print_bool(nv, format); break;}
case TYPE_NULL: { text_print_nul(nv, format); break;}
case TYPE_FLOAT: { text_print_flt(nv, format); break;}
case TYPE_INTEGER: { text_print_int(nv, format); break;}
case TYPE_STRING: { text_print_str(nv, format); break;}
case TYPE_BOOLEAN: { text_print_bool(nv, format); break;}
}
}