From 4d469a681d9f7d990ccefd16e45c84a3d8ee66c2 Mon Sep 17 00:00:00 2001 From: Sean Mathews Date: Wed, 24 Oct 2018 17:06:35 -0700 Subject: [PATCH 1/3] 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. --- build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino b/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino index 8caa58eabe1..f292a787338 100644 --- a/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino +++ b/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino @@ -331,6 +331,9 @@ uint8_t spi_transaction(uint8_t a, uint8_t b, uint8_t c, uint8_t d) { void empty_reply() { if (CRC_EOP == getch()) { + // clear RX buffer. No more host data expected until after SYNC. + while(SERIAL.available()) + SERIAL.read(); SERIAL.print((char)STK_INSYNC); SERIAL.print((char)STK_OK); } else { From 484ee34fd0a12ee95957c4e77fc09ecd06d48aea Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 25 Oct 2018 20:02:29 -0700 Subject: [PATCH 2/3] Update build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino Co-Authored-By: f34rdotcom --- build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino b/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino index f292a787338..4b44d5c24e5 100644 --- a/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino +++ b/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino @@ -333,7 +333,7 @@ void empty_reply() { if (CRC_EOP == getch()) { // clear RX buffer. No more host data expected until after SYNC. while(SERIAL.available()) - SERIAL.read(); + SERIAL.read(); SERIAL.print((char)STK_INSYNC); SERIAL.print((char)STK_OK); } else { From faf1b6a18b36fab49f3f165e910701f9137a21c5 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 25 Oct 2018 20:02:35 -0700 Subject: [PATCH 3/3] Update build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino Co-Authored-By: f34rdotcom --- build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino b/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino index 4b44d5c24e5..860a3449d86 100644 --- a/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino +++ b/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino @@ -332,7 +332,7 @@ uint8_t spi_transaction(uint8_t a, uint8_t b, uint8_t c, uint8_t d) { void empty_reply() { if (CRC_EOP == getch()) { // clear RX buffer. No more host data expected until after SYNC. - while(SERIAL.available()) + while (SERIAL.available()) SERIAL.read(); SERIAL.print((char)STK_INSYNC); SERIAL.print((char)STK_OK);