# HG changeset patch # User David Douard # Date 1604773401 -3600 # Node ID 11c57010e4f99f15627b397d5be9c5621443bd42 # Parent a4a007b3c42edc1f8728f44cfb509b1f3cb5c3bb Attempt to improve the detection of packet collisions (not fixed yet) diff -r a4a007b3c42e -r 11c57010e4f9 src/hp34comm.cpp --- 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) {