diff options
| author | Keith Packard <keithp@keithp.com> | 2011-06-24 08:31:12 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2011-06-27 19:16:42 -0700 | 
| commit | 5e111fdf1f23203baeeb490ae1b69402ebd513b8 (patch) | |
| tree | 4df5c4e61eb47f7c05b1f0e324ac3b75de03ee8d /src | |
| parent | 489a68ba8e3bc360e2e8fc887e4c4b840b5a0dd3 (diff) | |
altos: Add checksum to TELEM output lines
Verify the received telemetry lines to protect against OS data loss
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/ao_monitor.c | 12 | 
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ao_monitor.c b/src/ao_monitor.c index ac1929db..1d083c59 100644 --- a/src/ao_monitor.c +++ b/src/ao_monitor.c @@ -36,6 +36,7 @@ ao_monitor(void)  #define recv_tiny	(u.tiny)  	uint8_t state; +	uint8_t sum, byte;  	int16_t rssi;  	for (;;) { @@ -191,9 +192,14 @@ ao_monitor(void)  				ao_monitoring = AO_MAX_TELEMETRY;  			if (!ao_radio_recv(&recv_raw, ao_monitoring))  				continue; -			for (state = 0; state < ao_monitoring + 1; state++) -				printf("%02x ", recv_raw.packet[state]); -			printf("%02x\n", recv_raw.packet[state]); +			printf ("TELEM %02x", ao_monitoring+2); +			sum = 0x5a; +			for (state = 0; state < ao_monitoring + 2; state++) { +				byte = recv_raw.packet[state]; +				sum += byte; +				printf("%02x", byte); +			} +			printf("%02x\n", sum);  			break;  		}  		ao_usb_flush();  | 
