Skip to content

Commit

Permalink
Add COBS draining state to ensure fast resync
Browse files Browse the repository at this point in the history
  • Loading branch information
mubes committed Sep 20, 2024
1 parent 1dd52a6 commit d15cc3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Inc/cobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ extern "C" {
enum COBSPumpState
{
COBS_IDLE,
COBS_RXING
COBS_RXING,
COBS_DRAINING
};

struct Frame
Expand Down
10 changes: 9 additions & 1 deletion Src/cobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ void COBSPump( struct COBS *t, const uint8_t *incoming, int len,

break;

case COBS_DRAINING: // ---------------------------------------------------------------
if ( COBS_SYNC_CHAR == *fp )
{
t->s = COBS_IDLE;
}

break;

case COBS_RXING: // -------------------------------------------------------------------
t->intervalCount--;

Expand Down Expand Up @@ -160,7 +168,7 @@ void COBSPump( struct COBS *t, const uint8_t *incoming, int len,
if ( ( t->f.len > COBS_MAX_PACKET_LEN ) || ( COBS_SYNC_CHAR == *fp ) )
{
t->error++;
t->s = COBS_IDLE;
t->s = COBS_DRAINING;
}
else
{
Expand Down

0 comments on commit d15cc3e

Please sign in to comment.