Skip to content

Commit d15cc3e

Browse files
committed
Add COBS draining state to ensure fast resync
1 parent 1dd52a6 commit d15cc3e

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

Inc/cobs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ extern "C" {
2626
enum COBSPumpState
2727
{
2828
COBS_IDLE,
29-
COBS_RXING
29+
COBS_RXING,
30+
COBS_DRAINING
3031
};
3132

3233
struct Frame

Src/cobs.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ void COBSPump( struct COBS *t, const uint8_t *incoming, int len,
132132

133133
break;
134134

135+
case COBS_DRAINING: // ---------------------------------------------------------------
136+
if ( COBS_SYNC_CHAR == *fp )
137+
{
138+
t->s = COBS_IDLE;
139+
}
140+
141+
break;
142+
135143
case COBS_RXING: // -------------------------------------------------------------------
136144
t->intervalCount--;
137145

@@ -160,7 +168,7 @@ void COBSPump( struct COBS *t, const uint8_t *incoming, int len,
160168
if ( ( t->f.len > COBS_MAX_PACKET_LEN ) || ( COBS_SYNC_CHAR == *fp ) )
161169
{
162170
t->error++;
163-
t->s = COBS_IDLE;
171+
t->s = COBS_DRAINING;
164172
}
165173
else
166174
{

0 commit comments

Comments
 (0)