diff options
| author | Keith Packard <keithp@keithp.com> | 2014-09-03 22:58:22 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2014-09-03 22:58:22 -0700 | 
| commit | be38fb88d11bda1ba1caca38220773d3abcede19 (patch) | |
| tree | 5aef38678d6a088c25f2652a19de606a5b258ba0 /src/kernel/ao_pyro.c | |
| parent | 3842735e303f0bf6f46ed8cb659c92d8bb9bd137 (diff) | |
altos: Allow negative values for pyro configuration data
All of the integer pyro configuration parameters may be negative, so
parse that correctly.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/kernel/ao_pyro.c')
| -rw-r--r-- | src/kernel/ao_pyro.c | 17 | 
1 files changed, 15 insertions, 2 deletions
| diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c index 154edad5..3044d565 100644 --- a/src/kernel/ao_pyro.c +++ b/src/kernel/ao_pyro.c @@ -499,13 +499,26 @@ ao_pyro_set(void)  		}  		pyro_tmp.flags |= ao_pyro_values[v].flag;  		if (ao_pyro_values[v].offset != NO_VALUE) { +			uint8_t negative = 0; +			ao_cmd_white(); +			if (ao_cmd_lex_c == '-') { +				negative = 1; +				ao_cmd_lex(); +			}  			ao_cmd_decimal();  			if (ao_cmd_status != ao_cmd_success)  				return; -			if (ao_pyro_values[v].flag & AO_PYRO_8_BIT_VALUE) +			if (ao_pyro_values[v].flag & AO_PYRO_8_BIT_VALUE) { +				if (negative) { +					ao_cmd_status = ao_cmd_syntax_error; +					return; +				}  				*((uint8_t *) ((char *) &pyro_tmp + ao_pyro_values[v].offset)) = ao_cmd_lex_i; -			else +			} else { +				if (negative) +					ao_cmd_lex_i = -ao_cmd_lex_i;  				*((int16_t *) ((char *) &pyro_tmp + ao_pyro_values[v].offset)) = ao_cmd_lex_i; +			}  		}  	}  	_ao_config_edit_start(); | 
