# HG changeset patch # User David Douard # Date 1476215383 -7200 # Node ID c5e5bdc5ef496fe0f5bc51eb92a1dfe43f2e7c5a # Parent ec327bf8f224ac2a066f66002bf80edf5c737466 [hp34comm] fix key stroke reception code was not correct diff -r ec327bf8f224 -r c5e5bdc5ef49 src/hp34comm.cpp --- a/src/hp34comm.cpp Tue Oct 11 21:48:22 2016 +0200 +++ b/src/hp34comm.cpp Tue Oct 11 21:49:43 2016 +0200 @@ -91,10 +91,6 @@ ack = 1; wait_us(2); ack = 0; - wait_us(2); - ack = 1; - wait_us(2); - ack = 0; #endif } else @@ -125,14 +121,35 @@ tx_len = 0xFF; } else if (tx_len == 0xFF) { - // got a cmd, expect a payload size - tx_len = val; - tx_ack = false; + if (val == 0x55) { + // packet was in fact a keystroke, tx_cmd is in fact the key + // stroke and no payload is expected +#ifdef DEBUG2 + statetx = 1; +#endif + pushCmd((TrState)Tx, tx_cmd, 0, (char*)buf); +#ifdef DEBUG2 + wait_us(2); + statetx = 0; +#endif + reset(); + } else { + // got a cmd, expect a payload size + tx_len = val; + tx_ack = false; + } } else if (tx_len == 0x55) { // packet was in fact a keystroke, tx_cmd is in fact the key // stroke and no payload is expected - pushCmd((TrState)Tx, tx_cmd, 0, NULL); +#ifdef DEBUG2 + statetx = 1; +#endif + pushCmd((TrState)Tx, tx_cmd, 0, (char*)buf); +#ifdef DEBUG2 + wait_us(2); + statetx = 0; +#endif reset(); } else if (tx_len > 0) {