1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-23 16:25:26 +03:00

CLI: non-digit values should give invalid value, not 0

This commit is contained in:
theArchLadder 2016-05-12 15:35:44 +02:00
parent f6a03a3c00
commit d93abe9475

View file

@ -2396,20 +2396,22 @@ static void cliSet(char *cmdline)
int_float_value_t tmp; int_float_value_t tmp;
switch (valueTable[i].type & VALUE_MODE_MASK) { switch (valueTable[i].type & VALUE_MODE_MASK) {
case MODE_DIRECT: { case MODE_DIRECT: {
int32_t value = 0; if(strspn(eqptr, "0123456789.+-") == strlen(eqptr)) {
float valuef = 0; int32_t value = 0;
float valuef = 0;
value = atoi(eqptr); value = atoi(eqptr);
valuef = fastA2F(eqptr); valuef = fastA2F(eqptr);
if (valuef >= valueTable[i].config.minmax.min && valuef <= valueTable[i].config.minmax.max) { // note: compare float value if (valuef >= valueTable[i].config.minmax.min && valuef <= valueTable[i].config.minmax.max) { // note: compare float value
if ((valueTable[i].type & VALUE_TYPE_MASK) == VAR_FLOAT) if ((valueTable[i].type & VALUE_TYPE_MASK) == VAR_FLOAT)
tmp.float_value = valuef; tmp.float_value = valuef;
else else
tmp.int_value = value; tmp.int_value = value;
changeValue = true; changeValue = true;
}
} }
} }
break; break;