Skip to content

Commit

Permalink
Update frame check
Browse files Browse the repository at this point in the history
  • Loading branch information
mmosca committed Jun 24, 2024
1 parent 4c56952 commit 459fec9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
31 changes: 15 additions & 16 deletions src/main/rx/sbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ typedef struct sbusFrameData_s {
timeUs_t lastActivityTimeUs;
} sbusFrameData_t;

static uint8_t sbus2ActiveTelemetryFrame = 0;
static uint8_t sbus2ActiveTelemetryPage = 0;
timeUs_t frameTime = 0;

// Receive ISR callback
Expand Down Expand Up @@ -101,19 +101,18 @@ static void sbusDataReceive(uint16_t c, void *data)
// Do some sanity check
switch (frame->endByte) {
case 0x00: // This is S.BUS 1
case 0x04: // S.BUS 2 receiver voltage
sbus2ActiveTelemetryFrame = 0;
goto process_end_frame;
case 0x14: // S.BUS 2 GPS/baro
sbus2ActiveTelemetryFrame = 1;
goto process_end_frame;
case 0x24: // Unknown SBUS2 data
sbus2ActiveTelemetryFrame = 2;
goto process_end_frame;
case 0x34: // Unknown SBUS2 data
sbus2ActiveTelemetryFrame = 3;
process_end_frame:
frameTime = currentTimeUs;
case 0x04: // S.BUS 2 telemetry page 1
case 0x14: // S.BUS 2 telemetry page 2
case 0x24: // S.BUS 2 telemetry page 3
case 0x34: // S.BUS 2 telemetry page 4
if(frame->endByte & 0x4) {
sbus2ActiveTelemetryPage = (frame->endByte >> 4) & 0xF;
frameTime = currentTimeUs;
} else {
sbus2ActiveTelemetryPage = 0;
frameTime = -1;
}


frameValid = true;
sbusFrameData->state = STATE_SBUS_WAIT_SYNC;
Expand Down Expand Up @@ -223,8 +222,8 @@ uint8_t sbusGetLastFrameTime(void) {
return frameTime;
}

uint8_t sbusGetCurrentTelemetryFrame(void) {
return sbus2ActiveTelemetryFrame;
uint8_t sbusGetCurrentTelemetryPage(void) {
return sbus2ActiveTelemetryPage;
}
#endif // USE_TELEMETRY && USE_SBUS2_TELEMETRY

Expand Down
2 changes: 1 addition & 1 deletion src/main/rx/sbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ bool sbusInit(const rxConfig_t *initialRxConfig, rxRuntimeConfig_t *rxRuntimeCon
bool sbusInitFast(const rxConfig_t *initialRxConfig, rxRuntimeConfig_t *rxRuntimeConfig);

#ifdef USE_SBUS2_TELEMETRY
uint8_t sbusGetCurrentTelemetryFrame(void);
uint8_t sbusGetCurrentTelemetryPage(void);
uint8_t sbusGetLastFrameTime(void);
#endif

0 comments on commit 459fec9

Please sign in to comment.