Sat, 07 Nov 2020 19:23:21 +0100
Attempt to improve the detection of packet collisions (not fixed yet)
src/hp34comm.cpp | file | annotate | diff | comparison | revisions |
--- a/src/hp34comm.cpp Sat Nov 07 19:22:04 2020 +0100 +++ b/src/hp34comm.cpp Sat Nov 07 19:23:21 2020 +0100 @@ -185,11 +185,35 @@ HPSerial::state_t HPSerial::do_state_sending(uint8_t c) { - // ghee - if (c == 0xFF) + // check the ack value returned by the main unit + + if ((tr_data.pos == 1) && (tr_data.payload[0] == 0x66)) + { + if (c != 0x99) + { + //::printf("ACK ERROR %X [exp. %X]\n", c, ~(tr_data.payload[0])); + // did not received the expected ack + if (c == 0x66) + { + // we received a start of transmission while trying to emit something, + // ignore it, the correct ack should be sent but the main unit just behind... + set_timer(RXTIMEOUT); + return cur_state; + } + else + { + // not sure how this may happen, in doubt, try again + tr_data.pos--; + } + } + } + /* + else if (c != 0x00) { // resend current char - tr_data.pos--; + tr_data.pos--; } + */ + // TODO: check ACK values (c is the received ack) if (tr_data.pos >= tr_data.size) {