diff options
author | Josh Allen <axlecrusher@gmail.com> | 2017-02-13 15:31:07 -0500 |
---|---|---|
committer | Josh Allen <axlecrusher@gmail.com> | 2017-02-13 15:31:07 -0500 |
commit | 98db590e55513ca10ea363050f8bcb245116784b (patch) | |
tree | 5c27bcfd8070a8942a865b1cb9b7f70adda24cf4 /tools/ootx_decode/ootx_decoder.c | |
parent | 96c3e7838d96fa87c39b28f78b79b925841e6bd4 (diff) | |
download | libsurvive-98db590e55513ca10ea363050f8bcb245116784b.tar.gz libsurvive-98db590e55513ca10ea363050f8bcb245116784b.tar.bz2 |
fix decoding of length value
Diffstat (limited to 'tools/ootx_decode/ootx_decoder.c')
-rw-r--r-- | tools/ootx_decode/ootx_decoder.c | 30 |
1 files changed, 4 insertions, 26 deletions
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 ); } |