From 7eb1feba7c7a64910cb17f741f2349254a34fddd Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sat, 11 Feb 2017 10:08:16 -0500 Subject: ootx payload length for lighthouse 1 seems to be decoding correctly at 0x21. the payload length seems to be oscillating between 0x21 and a much larger number. the larger number 0xc8ec I have no idea why. 0xc8ec does not last long before a new preamble is found --- tools/ootx_decode/ootx_decode.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index 735b5fc..26e0028 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -65,6 +65,7 @@ void raw_test() { uint32_t delta = 0x00; int8_t current_lighthouse = 0; + ootx_decoder_context *c_ctx = ctx; while (getline(&line,&line_len,stdin)>0) { // printf("%s\n", line); @@ -80,14 +81,37 @@ void raw_test() { // printf("%d\n", ticks); int8_t lh = ootx_decode_lighthouse_number(current_lighthouse, ticks, delta); +// printf("lh:%d %s\n", lh, line); +// if (lh>0) continue; if (lh > -1) { + //pump last bit + ootx_pump_greatest_bit(c_ctx); + + uint16_t s = *(c_ctx->payload_size); +// uint16_t ss = (s>>8) | (s<<8); + if (c_ctx->found_preamble) printf("LH:%d s:%d 0x%x\t%s", current_lighthouse, s, s, line); + //change to newly found lighthouse current_lighthouse = lh; + c_ctx = ctx+current_lighthouse; + } + + if (ticks>2000 && current_lighthouse==0) { + ootx_log_bit(c_ctx, ticks); + } + + if (lh == -1) { // printf("%d %d %d\n", ticks, delta, current_lighthouse); - ootx_process_bit(ctx+current_lighthouse, ticks); - printf("%d %d %d\n", current_lighthouse, *(ctx->payload_size), ctx->found_preamble); +// ootx_process_bit(ctx+current_lighthouse, ticks); + } +// printf("%d %d %d\n", ticks, delta, current_lighthouse); +// ootx_process_bit(ctx+current_lighthouse, ticks); + + //we would expect a length of 40 bytes +// printf("%d %d %d\t%s\n", current_lighthouse, *(ctx->payload_size), ctx->found_preamble, line); +// } /* if (current_lighthouse >= 0) { ootx_process_bit(ctx+current_lighthouse, ticks); @@ -103,6 +127,7 @@ int main(int argc, char* argv[]) ootx_init_decoder_context(ctx+1); raw_test(); +// hello_world_test(); return 0; } \ No newline at end of file -- cgit v1.2.3 From 998ffc6ec9dc6ca2f0c94501c6d70882dfb13f5b Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sat, 11 Feb 2017 11:27:21 -0500 Subject: print protocol and firmware version --- tools/ootx_decode/ootx_decode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index 26e0028..aabf1e8 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -89,8 +89,11 @@ void raw_test() { ootx_pump_greatest_bit(c_ctx); uint16_t s = *(c_ctx->payload_size); + uint16_t fwv = *(c_ctx->buffer+2); + uint16_t pv = 0x3f & fwv; + fwv>>=6; // uint16_t ss = (s>>8) | (s<<8); - if (c_ctx->found_preamble) printf("LH:%d s:%d 0x%x\t%s", current_lighthouse, s, s, line); + if (c_ctx->found_preamble) printf("LH:%d s:%d 0x%x fw:%d pv:%d %d\t%s", current_lighthouse, s, s, fwv, pv, c_ctx->buf_offset, line); //change to newly found lighthouse current_lighthouse = lh; -- cgit v1.2.3 From 5c54917eaed3e1c6777e16baec65e63dffa215ce Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sat, 11 Feb 2017 15:45:10 -0500 Subject: end of frame detection corrected --- tools/ootx_decode/ootx_decode.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index aabf1e8..d3c1c0f 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -86,14 +86,19 @@ void raw_test() { if (lh > -1) { //pump last bit - ootx_pump_greatest_bit(c_ctx); +// printf("LH:%d ", current_lighthouse); + uint8_t bit = 0x01; + + if (current_lighthouse==0) bit &= ootx_pump_greatest_bit(c_ctx); uint16_t s = *(c_ctx->payload_size); uint16_t fwv = *(c_ctx->buffer+2); - uint16_t pv = 0x3f & fwv; - fwv>>=6; + uint16_t pv = 0x3f & fwv; //protocol version + fwv>>=6; //firmware version // uint16_t ss = (s>>8) | (s<<8); - if (c_ctx->found_preamble) printf("LH:%d s:%d 0x%x fw:%d pv:%d %d\t%s", current_lighthouse, s, s, fwv, pv, c_ctx->buf_offset, line); + + //this will print after any messages from ootx_pump + if (c_ctx->found_preamble>0) printf("LH:%d s:%d 0x%x fw:%d pv:%d bo:%d bit:%d\t%s", current_lighthouse, s, s, fwv, pv, c_ctx->buf_offset, bit, line); //change to newly found lighthouse current_lighthouse = lh; @@ -101,6 +106,7 @@ void raw_test() { } if (ticks>2000 && current_lighthouse==0) { + //only work with master lighthouse for now ootx_log_bit(c_ctx, ticks); } -- cgit v1.2.3 From aab9f4f1db0dd752a00f3ae67531f1d58b9e2980 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sat, 11 Feb 2017 16:27:57 -0500 Subject: correctly decodes lighthouse 1 ootx frames --- tools/ootx_decode/ootx_decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index d3c1c0f..19d6574 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -98,7 +98,7 @@ void raw_test() { // uint16_t ss = (s>>8) | (s<<8); //this will print after any messages from ootx_pump - if (c_ctx->found_preamble>0) printf("LH:%d s:%d 0x%x fw:%d pv:%d bo:%d bit:%d\t%s", current_lighthouse, s, s, fwv, pv, c_ctx->buf_offset, bit, line); +// if (c_ctx->found_preamble>0) printf("LH:%d s:%d 0x%x fw:%d pv:%d bo:%d bit:%d\t%s", current_lighthouse, s, s, fwv, pv, c_ctx->buf_offset, bit, line); //change to newly found lighthouse current_lighthouse = lh; -- cgit v1.2.3 From c04c9fb7dcf80123edec53a2e6709bb128548a73 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sat, 11 Feb 2017 20:56:50 -0500 Subject: add lighthouse_info_v6 --- tools/ootx_decode/ootx_decode.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index 19d6574..3a6b6f0 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -22,6 +22,10 @@ void my_test(ootx_packet* packet) { void my_test2(ootx_packet* packet) { printf("completed ootx packet\n"); + + lighthouse_info_v6 lhi; + init_lighthouse_info_v6(&lhi,packet->data); + print_lighthouse_info_v6(&lhi); // packet->data[packet->length] = 0; // printf("%d %s 0x%X\n", packet->length, packet->data, packet->crc32); } @@ -91,11 +95,10 @@ void raw_test() { if (current_lighthouse==0) bit &= ootx_pump_greatest_bit(c_ctx); - uint16_t s = *(c_ctx->payload_size); - uint16_t fwv = *(c_ctx->buffer+2); - uint16_t pv = 0x3f & fwv; //protocol version - fwv>>=6; //firmware version -// uint16_t ss = (s>>8) | (s<<8); +// uint16_t s = *(c_ctx->payload_size); +// uint16_t fwv = *(c_ctx->buffer+2); +// uint16_t pv = 0x3f & fwv; //protocol version +// fwv>>=6; //firmware version //this will print after any messages from ootx_pump // if (c_ctx->found_preamble>0) printf("LH:%d s:%d 0x%x fw:%d pv:%d bo:%d bit:%d\t%s", current_lighthouse, s, s, fwv, pv, c_ctx->buf_offset, bit, line); -- cgit v1.2.3 From 600df0b1cb3fac30bd7a7c3df3b50f5e003032bf Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sun, 12 Feb 2017 08:36:00 -0500 Subject: use ootx_accumulate_bit --- tools/ootx_decode/ootx_decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index 3a6b6f0..6365a1d 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -110,7 +110,7 @@ void raw_test() { if (ticks>2000 && current_lighthouse==0) { //only work with master lighthouse for now - ootx_log_bit(c_ctx, ticks); + ootx_accumulate_bit(c_ctx, ootx_decode_bit(ticks) ); } if (lh == -1) { -- cgit v1.2.3 From da93d5821e6da8462ff42f2c8e6e07a3cbe10740 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sun, 12 Feb 2017 09:58:32 -0500 Subject: proper decoding of bith lighthouse ootx data --- tools/ootx_decode/ootx_decode.c | 89 ++++++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 24 deletions(-) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index 6365a1d..380d7b2 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -91,45 +91,85 @@ void raw_test() { if (lh > -1) { //pump last bit // printf("LH:%d ", current_lighthouse); - uint8_t bit = 0x01; + uint8_t bit = 0x01; //bit for debugging purposes - if (current_lighthouse==0) bit &= ootx_pump_greatest_bit(c_ctx); +// if (current_lighthouse==1) bit &= ootx_pump_greatest_bit(c_ctx); + bit &= ootx_pump_greatest_bit(c_ctx); -// uint16_t s = *(c_ctx->payload_size); -// uint16_t fwv = *(c_ctx->buffer+2); -// uint16_t pv = 0x3f & fwv; //protocol version -// fwv>>=6; //firmware version +/* + uint16_t s = *(c_ctx->payload_size); + uint16_t fwv = *(c_ctx->buffer+2); + uint16_t pv = 0x3f & fwv; //protocol version + fwv>>=6; //firmware version //this will print after any messages from ootx_pump -// if (c_ctx->found_preamble>0) printf("LH:%d s:%d 0x%x fw:%d pv:%d bo:%d bit:%d\t%s", current_lighthouse, s, s, fwv, pv, c_ctx->buf_offset, bit, line); - + if (c_ctx->found_preamble>0) printf("LH:%d s:%d 0x%x fw:%d pv:%d bo:%d bit:%d\t%s", current_lighthouse, s, s, fwv, pv, c_ctx->buf_offset, bit, line); +*/ //change to newly found lighthouse current_lighthouse = lh; c_ctx = ctx+current_lighthouse; } - if (ticks>2000 && current_lighthouse==0) { - //only work with master lighthouse for now - ootx_accumulate_bit(c_ctx, ootx_decode_bit(ticks) ); +// if (ticks>2000 && current_lighthouse==1) { + if (ticks>2000) { + ootx_accumulate_bit(c_ctx, ootx_decode_bit(ticks) ); } + } +} - if (lh == -1) { -// printf("%d %d %d\n", ticks, delta, current_lighthouse); -// ootx_process_bit(ctx+current_lighthouse, ticks); +void acode_test() { + ootx_packet_clbk = my_test2; - } -// printf("%d %d %d\n", ticks, delta, current_lighthouse); -// ootx_process_bit(ctx+current_lighthouse, ticks); + char* line = NULL; + size_t line_len = 0; + char trash[100] = ""; + int32_t atime = 0x00; +// uint32_t ticks = 0x00; +// uint32_t delta = 0x00; + uint8_t acode = 0x00; + char lighthouse_code = '\0'; - //we would expect a length of 40 bytes -// printf("%d %d %d\t%s\n", current_lighthouse, *(ctx->payload_size), ctx->found_preamble, line); -// } -/* - if (current_lighthouse >= 0) { - ootx_process_bit(ctx+current_lighthouse, ticks); + int8_t current_lighthouse = 0; + ootx_decoder_context *c_ctx = ctx; + + while (getline(&line,&line_len,stdin)>0) { + //L X HMD -1842671365 18 0 175393 222 + sscanf(line,"%c %s %s %d %s %hhu %s %s", + &lighthouse_code, + trash, + trash, + &atime, + trash, + &acode, + trash, + trash); + + int8_t lh = lighthouse_code=='R'?0:1; +// printf("LH:%d bit:%d %s\n", lh, (acode & 0x02) >> 1,line); + + if (lh != current_lighthouse) { + //pump last bit + uint8_t bit = 0x01; + + if (current_lighthouse==0) bit &= ootx_pump_greatest_bit(c_ctx); +// ootx_pump_greatest_bit(c_ctx); + + uint16_t s = *(c_ctx->payload_size); + uint16_t fwv = *(c_ctx->buffer+2); + uint16_t pv = 0x3f & fwv; //protocol version + fwv>>=6; //firmware version + + //this will print after any messages from ootx_pump + if (c_ctx->found_preamble>0) printf("LH:%d s:%d 0x%x fw:%d pv:%d bo:%d bit:%d\t%s", current_lighthouse, s, s, fwv, pv, c_ctx->buf_offset, bit, line); + + //change to newly found lighthouse + current_lighthouse = lh; + c_ctx = ctx+current_lighthouse; } -*/ +// if (current_lighthouse==0) { + ootx_accumulate_bit(c_ctx, (acode & 0x02) >> 1); +// } } } @@ -139,6 +179,7 @@ int main(int argc, char* argv[]) ootx_init_decoder_context(ctx+1); raw_test(); +// acode_test(); // hello_world_test(); return 0; -- cgit v1.2.3 From b79a1766aaf207943772b2565f674853e2be8314 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sun, 12 Feb 2017 10:47:17 -0500 Subject: fix copyright --- tools/ootx_decode/ootx_decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index 380d7b2..0c4a81a 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -1,4 +1,4 @@ -// (C) 2016 Joshua Allen, MIT/x11 License. +// (C) 2017 Joshua Allen, MIT/x11 License. // //All MIT/x11 Licensed Code in this file may be relicensed freely under the GPL or LGPL licenses. -- cgit v1.2.3 From ac556ccbb2ecd419773b3ad941f7aea78a191381 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sun, 12 Feb 2017 10:57:57 -0500 Subject: clean up code. move some of the debugging code out into the test harness --- tools/ootx_decode/ootx_decode.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index 0c4a81a..0abde2d 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -30,11 +30,38 @@ void my_test2(ootx_packet* packet) { // printf("%d %s 0x%X\n", packet->length, packet->data, packet->crc32); } + +void print_crc32(uint32_t crc) { +// uint8_t* p = (uint32_t*)&crc; +// uint8_t i = 0; + + printf("%X\n", crc); +} + +void write_to_file(uint8_t *d, uint16_t length){ + FILE *fp = fopen("binary.data","w"); + fwrite(d, length, 1, fp); + fclose(fp); +} + +void bad_crc(ootx_packet* packet) { + printf("CRC mismatch\n"); +/* + printf("r:"); + print_crc32(op.crc32); + + printf("c:"); + print_crc32(crc); +// write_to_file(op.data,op.length); +*/ +} + ootx_decoder_context ctx[2]; void hello_world_test() { // ootx_init_buffer(); ootx_packet_clbk = my_test; + ootx_bad_crc_clbk = bad_crc; char* line = NULL; size_t line_len = 0; -- cgit v1.2.3 From 6ad28759408695a4825738bcc32bc294d1869ca8 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sun, 12 Feb 2017 11:09:38 -0500 Subject: handler for bad crc32 --- tools/ootx_decode/ootx_decode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index 0abde2d..9e76d8f 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -44,16 +44,15 @@ void write_to_file(uint8_t *d, uint16_t length){ fclose(fp); } -void bad_crc(ootx_packet* packet) { +void bad_crc(ootx_packet* packet, uint32_t crc) { printf("CRC mismatch\n"); -/* + printf("r:"); - print_crc32(op.crc32); + print_crc32(packet->crc32); printf("c:"); print_crc32(crc); -// write_to_file(op.data,op.length); -*/ + write_to_file(packet->data,packet->length); } ootx_decoder_context ctx[2]; @@ -61,7 +60,6 @@ ootx_decoder_context ctx[2]; void hello_world_test() { // ootx_init_buffer(); ootx_packet_clbk = my_test; - ootx_bad_crc_clbk = bad_crc; char* line = NULL; size_t line_len = 0; @@ -87,6 +85,7 @@ void hello_world_test() { void raw_test() { ootx_packet_clbk = my_test2; + ootx_bad_crc_clbk = bad_crc; char* line = NULL; size_t line_len = 0; @@ -146,6 +145,7 @@ void raw_test() { void acode_test() { ootx_packet_clbk = my_test2; + ootx_bad_crc_clbk = bad_crc; char* line = NULL; size_t line_len = 0; -- cgit v1.2.3 From c2ca44be9f6408351cfe32e855b1472ec155b9b2 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sun, 12 Feb 2017 14:34:29 -0500 Subject: free decoder context --- tools/ootx_decode/ootx_decode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index 9e76d8f..1e93574 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -197,7 +197,7 @@ void acode_test() { // if (current_lighthouse==0) { ootx_accumulate_bit(c_ctx, (acode & 0x02) >> 1); // } - } + } } int main(int argc, char* argv[]) @@ -209,5 +209,8 @@ int main(int argc, char* argv[]) // acode_test(); // hello_world_test(); + ootx_free_decoder_context(ctx); + ootx_free_decoder_context(ctx+1); + return 0; } \ No newline at end of file -- cgit v1.2.3 From 72559b7f8d29d07d7fbf382dd7b1650511d50304 Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Mon, 13 Feb 2017 15:31:46 -0500 Subject: add code to use cnlohr's improved dataset --- tools/ootx_decode/ootx_decode.c | 59 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index 1e93574..a97bc8d 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -200,12 +200,69 @@ void acode_test() { } } +void cnlohr_code_test() { + ootx_packet_clbk = my_test2; + ootx_bad_crc_clbk = bad_crc; + + char* line = NULL; + size_t line_len = 0; + char trash[100] = ""; +// int32_t atime = 0x00; + int8_t lh_id = 0x00; + uint32_t ticks = 0x00; + int32_t delta = 0x00; +// uint8_t acode = 0x00; +// char lighthouse_code = '\0'; + +// int8_t current_lighthouse = 0; + ootx_decoder_context *c_ctx = ctx; + + while (getline(&line,&line_len,stdin)>0) { + //R Y HMD -1575410734 -2 7 19714 6485 + sscanf(line,"%s %s %s %s %hhd %s %d %d", + trash, + trash, + trash, + trash, + &lh_id, + trash, //sensor id? + &delta, + &ticks); + +// int8_t lh = lighthouse_code=='R'?0:1; +// printf("LH:%d %s\n", lh_id, line); + int8_t lh = (lh_id*-1)-1; + if (lh_id < 0) { +// uint8_t bit = 0x01; //bit for debugging purposes + + //change to newly found lighthouse + c_ctx = ctx+lh; + +// uint8_t dbit = ootx_decode_bit(ticks); +// printf("LH:%d ticks:%d bit:%X %s", lh, ticks, dbit, line); + + ootx_process_bit(c_ctx, ticks); + +/* + uint16_t s = *(c_ctx->payload_size); + uint16_t fwv = *(c_ctx->buffer+2); + uint16_t pv = 0x3f & fwv; //protocol version + fwv>>=6; //firmware version + + //this will print after any messages from ootx_pump +// if (c_ctx->found_preamble>0) printf("LH:%d s:%d 0x%x fw:%d pv:%d bo:%d bit:%d\t%s", current_lighthouse, s, s, fwv, pv, c_ctx->buf_offset, bit, line); +*/ + } + } +} + int main(int argc, char* argv[]) { ootx_init_decoder_context(ctx); ootx_init_decoder_context(ctx+1); - raw_test(); + cnlohr_code_test(); +// raw_test(); // acode_test(); // hello_world_test(); -- cgit v1.2.3 From cbb6d0b53319a7e0124fff6ce7ffb12cfe94fa3f Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Mon, 13 Feb 2017 15:44:39 -0500 Subject: remove unused code --- tools/ootx_decode/ootx_decode.c | 153 ---------------------------------------- 1 file changed, 153 deletions(-) (limited to 'tools/ootx_decode/ootx_decode.c') diff --git a/tools/ootx_decode/ootx_decode.c b/tools/ootx_decode/ootx_decode.c index a97bc8d..1074698 100644 --- a/tools/ootx_decode/ootx_decode.c +++ b/tools/ootx_decode/ootx_decode.c @@ -12,9 +12,6 @@ #include "ootx_decoder.h" -//char* fmt_str = "L Y HMD %d 5 1 206230 %d\n"; -//extern std::istream cin; - void my_test(ootx_packet* packet) { packet->data[packet->length] = 0; printf("%d %s 0x%X\n", packet->length, packet->data, packet->crc32); @@ -57,149 +54,6 @@ void bad_crc(ootx_packet* packet, uint32_t crc) { ootx_decoder_context ctx[2]; -void hello_world_test() { -// ootx_init_buffer(); - ootx_packet_clbk = my_test; - - char* line = NULL; - size_t line_len = 0; - char trash[100] = ""; - uint32_t ticks = 0x00; - - while (getline(&line,&line_len,stdin)>0) { -// printf("%s\n", line); - sscanf(line,"%s %s %s %s %s %s %s %d", - trash, - trash, - trash, - trash, - trash, - trash, - trash, - &ticks); -// printf("%d\n", ticks); - - ootx_process_bit(ctx, ticks); - } -} - -void raw_test() { - ootx_packet_clbk = my_test2; - ootx_bad_crc_clbk = bad_crc; - - char* line = NULL; - size_t line_len = 0; - char trash[100] = ""; - int32_t atime = 0x00; - uint32_t ticks = 0x00; - uint32_t delta = 0x00; - - int8_t current_lighthouse = 0; - ootx_decoder_context *c_ctx = ctx; - - while (getline(&line,&line_len,stdin)>0) { -// printf("%s\n", line); - - //HMD 20 0 5881 765645903 -5 - sscanf(line,"%s %s %s %d %d %d", - trash, - trash, - trash, - &ticks, - &atime, - &delta); -// printf("%d\n", ticks); - - int8_t lh = ootx_decode_lighthouse_number(current_lighthouse, ticks, delta); -// printf("lh:%d %s\n", lh, line); -// if (lh>0) continue; - - if (lh > -1) { - //pump last bit -// printf("LH:%d ", current_lighthouse); - uint8_t bit = 0x01; //bit for debugging purposes - -// if (current_lighthouse==1) bit &= ootx_pump_greatest_bit(c_ctx); - bit &= ootx_pump_greatest_bit(c_ctx); - -/* - uint16_t s = *(c_ctx->payload_size); - uint16_t fwv = *(c_ctx->buffer+2); - uint16_t pv = 0x3f & fwv; //protocol version - fwv>>=6; //firmware version - - //this will print after any messages from ootx_pump - if (c_ctx->found_preamble>0) printf("LH:%d s:%d 0x%x fw:%d pv:%d bo:%d bit:%d\t%s", current_lighthouse, s, s, fwv, pv, c_ctx->buf_offset, bit, line); -*/ - //change to newly found lighthouse - current_lighthouse = lh; - c_ctx = ctx+current_lighthouse; - } - -// if (ticks>2000 && current_lighthouse==1) { - if (ticks>2000) { - ootx_accumulate_bit(c_ctx, ootx_decode_bit(ticks) ); - } - } -} - -void acode_test() { - ootx_packet_clbk = my_test2; - ootx_bad_crc_clbk = bad_crc; - - char* line = NULL; - size_t line_len = 0; - char trash[100] = ""; - int32_t atime = 0x00; -// uint32_t ticks = 0x00; -// uint32_t delta = 0x00; - uint8_t acode = 0x00; - char lighthouse_code = '\0'; - - int8_t current_lighthouse = 0; - ootx_decoder_context *c_ctx = ctx; - - while (getline(&line,&line_len,stdin)>0) { - //L X HMD -1842671365 18 0 175393 222 - sscanf(line,"%c %s %s %d %s %hhu %s %s", - &lighthouse_code, - trash, - trash, - &atime, - trash, - &acode, - trash, - trash); - - int8_t lh = lighthouse_code=='R'?0:1; -// printf("LH:%d bit:%d %s\n", lh, (acode & 0x02) >> 1,line); - - if (lh != current_lighthouse) { - //pump last bit - uint8_t bit = 0x01; - - if (current_lighthouse==0) bit &= ootx_pump_greatest_bit(c_ctx); -// ootx_pump_greatest_bit(c_ctx); - - uint16_t s = *(c_ctx->payload_size); - uint16_t fwv = *(c_ctx->buffer+2); - uint16_t pv = 0x3f & fwv; //protocol version - fwv>>=6; //firmware version - - //this will print after any messages from ootx_pump - if (c_ctx->found_preamble>0) printf("LH:%d s:%d 0x%x fw:%d pv:%d bo:%d bit:%d\t%s", current_lighthouse, s, s, fwv, pv, c_ctx->buf_offset, bit, line); - - //change to newly found lighthouse - current_lighthouse = lh; - c_ctx = ctx+current_lighthouse; - } - -// if (current_lighthouse==0) { - ootx_accumulate_bit(c_ctx, (acode & 0x02) >> 1); -// } - } -} - void cnlohr_code_test() { ootx_packet_clbk = my_test2; ootx_bad_crc_clbk = bad_crc; @@ -207,14 +61,10 @@ void cnlohr_code_test() { char* line = NULL; size_t line_len = 0; char trash[100] = ""; -// int32_t atime = 0x00; int8_t lh_id = 0x00; uint32_t ticks = 0x00; int32_t delta = 0x00; -// uint8_t acode = 0x00; -// char lighthouse_code = '\0'; -// int8_t current_lighthouse = 0; ootx_decoder_context *c_ctx = ctx; while (getline(&line,&line_len,stdin)>0) { @@ -262,9 +112,6 @@ int main(int argc, char* argv[]) ootx_init_decoder_context(ctx+1); cnlohr_code_test(); -// raw_test(); -// acode_test(); -// hello_world_test(); ootx_free_decoder_context(ctx); ootx_free_decoder_context(ctx+1); -- cgit v1.2.3