1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-26 01:35:41 +03:00

Merge pull request #9863 from mikeller/cleanup_crsf_tests

Cleaned up separation of CRSF test code.
This commit is contained in:
Michael Keller 2020-07-26 15:30:10 +12:00 committed by GitHub
commit 0e28a646fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 13 deletions

View file

@ -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>
@ -646,7 +635,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;
@ -673,3 +674,4 @@ int getCrsfFrame(uint8_t *frame, crsfFrameType_e frameType)
return frameSize;
}
#endif
#endif

View file

@ -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

View file

@ -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);