Skip to content

Commit d58cbe7

Browse files
f34rdotcomper1234
authored andcommitted
Sync issue when host sends multiple signon requests
If the host sends a signon but does not get a SYNC response it will send again. This will lead to being out of sync with data in the rx buffer that is not consumed. To avoid this we consume all extra host bytes before sending a INSYNC reply.
1 parent b3da224 commit d58cbe7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino

+3
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ uint8_t spi_transaction(uint8_t a, uint8_t b, uint8_t c, uint8_t d) {
341341

342342
void empty_reply() {
343343
if (CRC_EOP == getch()) {
344+
// clear RX buffer. No more host data expected until after SYNC.
345+
while(SERIAL.available())
346+
SERIAL.read();
344347
SERIAL.print((char)STK_INSYNC);
345348
SERIAL.print((char)STK_OK);
346349
} else {

0 commit comments

Comments
 (0)