summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-02-19 17:58:09 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-02-19 17:58:09 +0100
commitcf0ec112c87f25e546295a4eb07f218ff912d0a8 (patch)
tree2c20573ec8676976528adc277051c05cf01f786b
parent208416b58565ee5a8ea7a1670924dcde4e633663 (diff)
system: reset state machine on error
-rw-r--r--src/system.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/system.cc b/src/system.cc
index d2231b4..a12dd71 100644
--- a/src/system.cc
+++ b/src/system.cc
@@ -58,11 +58,15 @@ void System::receive(void)
case START1:
if (rx_byte == 0x99)
rxExpect = START2;
+ else
+ rxExpect = START_OR_PATTERN;
break;
case START2:
if (rx_byte == 0x99) {
rxExpect = PATTERN1;
storage.reset();
+ } else {
+ rxExpect = START_OR_PATTERN;
}
break;
case START_OR_PATTERN:
@@ -70,14 +74,20 @@ void System::receive(void)
rxExpect = START2;
else if (rx_byte == 0xa9)
rxExpect = PATTERN2;
+ else
+ rxExpect = START_OR_PATTERN;
break;
case PATTERN1:
if (rx_byte == 0xa9)
rxExpect = PATTERN2;
+ else
+ rxExpect = START_OR_PATTERN;
break;
case PATTERN2:
if (rx_byte == 0xa9)
rxExpect = HEADER1;
+ else
+ rxExpect = START_OR_PATTERN;
break;
case HEADER1:
rxExpect = HEADER2;