From 98db590e55513ca10ea363050f8bcb245116784b Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Mon, 13 Feb 2017 15:31:07 -0500 Subject: fix decoding of length value --- tools/ootx_decode/ootx_decoder.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) (limited to 'tools') diff --git a/tools/ootx_decode/ootx_decoder.c b/tools/ootx_decode/ootx_decoder.c index 98bac67..510fadb 100644 --- a/tools/ootx_decode/ootx_decoder.c +++ b/tools/ootx_decode/ootx_decoder.c @@ -60,33 +60,11 @@ int8_t ootx_decode_lighthouse_number(uint8_t last_num, uint32_t ticks, int32_t d if (delta>18000) return 1; //a slave, should be at least 20000 but there are some data issues return -1; } -/* -uint8_t decode_internal(uint32_t length) { - uint16_t temp = length - 2880; -// printf - -#if BETTER_SAFE_THAN_FAST - if (temp < 0 || length > 6525) { - return -1; - } -#endif - if ((temp % 500) < 150) { - return temp / 500; - } - - return -1; - -} -*/ uint8_t ootx_decode_bit(uint32_t length) { - length = ((length/500)*500)+500; - - length-=3000; - if (length>=2000) { length-=2000; } - if (length>=1000) { return 0xFF; } - - return 0x00; + uint8_t t = (length - 2750) / 500; //why 2750? +// return ((t & 0x02)>0)?0xFF:0x00; + return ((t & 0x02)>>1); } void ootx_accumulate_bit(ootx_decoder_context *ctx, uint8_t bit) { @@ -151,7 +129,7 @@ void ootx_write_to_buffer(ootx_decoder_context *ctx, uint8_t dbit) { } void ootx_process_bit(ootx_decoder_context *ctx, uint32_t length) { - int8_t dbit = ootx_decode_bit(length); + uint8_t dbit = ootx_decode_bit(length); ootx_pump_bit( ctx, dbit ); } -- cgit v1.2.3