mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
Cleaned up separation of CRSF test code.
This commit is contained in:
parent
6bada9c5e9
commit
1d79cab143
3 changed files with 17 additions and 13 deletions
|
@ -144,17 +144,6 @@ static void crsfFinalize(sbuf_t *dst)
|
|||
crsfRxWriteTelemetryData(sbufPtr(dst), sbufBytesRemaining(dst));
|
||||
}
|
||||
|
||||
static int crsfFinalizeBuf(sbuf_t *dst, uint8_t *frame)
|
||||
{
|
||||
crc8_dvb_s2_sbuf_append(dst, &crsfFrame[2]); // start at byte 2, since CRC does not include device address and frame length
|
||||
sbufSwitchToReader(dst, crsfFrame);
|
||||
const int frameSize = sbufBytesRemaining(dst);
|
||||
for (int ii = 0; sbufBytesRemaining(dst); ++ii) {
|
||||
frame[ii] = sbufReadU8(dst);
|
||||
}
|
||||
return frameSize;
|
||||
}
|
||||
|
||||
/*
|
||||
CRSF frame has the structure:
|
||||
<Device address> <Frame length> <Type> <Payload> <CRC>
|
||||
|
@ -577,7 +566,19 @@ void handleCrsfTelemetry(timeUs_t currentTimeUs)
|
|||
}
|
||||
}
|
||||
|
||||
int getCrsfFrame(uint8_t *frame, crsfFrameType_e frameType)
|
||||
#if defined(UNIT_TEST)
|
||||
static int crsfFinalizeBuf(sbuf_t *dst, uint8_t *frame)
|
||||
{
|
||||
crc8_dvb_s2_sbuf_append(dst, &crsfFrame[2]); // start at byte 2, since CRC does not include device address and frame length
|
||||
sbufSwitchToReader(dst, crsfFrame);
|
||||
const int frameSize = sbufBytesRemaining(dst);
|
||||
for (int ii = 0; sbufBytesRemaining(dst); ++ii) {
|
||||
frame[ii] = sbufReadU8(dst);
|
||||
}
|
||||
return frameSize;
|
||||
}
|
||||
|
||||
STATIC_UNIT_TESTED int getCrsfFrame(uint8_t *frame, crsfFrameType_e frameType)
|
||||
{
|
||||
sbuf_t crsfFrameBuf;
|
||||
sbuf_t *sbuf = &crsfFrameBuf;
|
||||
|
@ -604,3 +605,4 @@ int getCrsfFrame(uint8_t *frame, crsfFrameType_e frameType)
|
|||
return frameSize;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -35,7 +35,6 @@ bool checkCrsfTelemetryState(void);
|
|||
void handleCrsfTelemetry(timeUs_t currentTimeUs);
|
||||
void crsfScheduleDeviceInfoResponse(void);
|
||||
void crsfScheduleMspResponse(void);
|
||||
int getCrsfFrame(uint8_t *frame, crsfFrameType_e frameType);
|
||||
#if defined(USE_CRSF_CMS_TELEMETRY)
|
||||
void crsfProcessDisplayPortCmd(uint8_t *frameStart);
|
||||
#endif
|
||||
|
|
|
@ -69,6 +69,9 @@ extern "C" {
|
|||
int32_t testmAhDrawn = 0;
|
||||
|
||||
serialPort_t *telemetrySharedPort;
|
||||
|
||||
int getCrsfFrame(uint8_t *frame, crsfFrameType_e frameType);
|
||||
|
||||
PG_REGISTER(batteryConfig_t, batteryConfig, PG_BATTERY_CONFIG, 0);
|
||||
PG_REGISTER(telemetryConfig_t, telemetryConfig, PG_TELEMETRY_CONFIG, 0);
|
||||
PG_REGISTER(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue