Skip to content

Commit

Permalink
#34 Reset syslink state when STM is restarted
Browse files Browse the repository at this point in the history
  • Loading branch information
krichardsson committed Feb 12, 2020
1 parent 3c4780c commit 9c69891
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions interface/syslink.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct syslinkPacket {
bool syslinkReceive(struct syslinkPacket *packet);

bool syslinkSend(struct syslinkPacket *packet);
void syslinkReset();


// Defined packet types
Expand Down
1 change: 1 addition & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ static void handleBootloaderCmd(struct esbPacket_s *packet)
case BOOTLOADER_CMD_SYSON:
pmSysBootloader(false);
pmSetState(pmSysRunning);
syslinkReset();
break;
case BOOTLOADER_CMD_GETVBAT:
if (esbCanTxPacket()) {
Expand Down
7 changes: 6 additions & 1 deletion src/syslink.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@
#define START_BYTE1 0xBC
#define START_BYTE2 0xCF

static enum {state_first_start, state_second_start, state_length, state_type, state_data, state_cksum1, state_cksum2, state_done} state = state_first_start;

void syslinkReset() {
state = state_first_start;
}

bool syslinkReceive(struct syslinkPacket *packet)
{
static enum {state_first_start, state_second_start, state_length, state_type, state_data, state_cksum1, state_cksum2, state_done} state = state_first_start;
static int step=0;
static int length=0;
static uint8_t cksum_a=0, cksum_b=0;
Expand Down

0 comments on commit 9c69891

Please sign in to comment.