From 1b7fb27404ebd74c06e4acd3e8a63526df28b549 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Thu, 15 Jan 2026 18:44:35 +0100 Subject: [PATCH 1/4] initial commit --- radio/src/pulses/crossfire.cpp | 48 +++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/radio/src/pulses/crossfire.cpp b/radio/src/pulses/crossfire.cpp index 18fc7f61269..be0dc25077b 100644 --- a/radio/src/pulses/crossfire.cpp +++ b/radio/src/pulses/crossfire.cpp @@ -96,20 +96,20 @@ uint8_t createCrossfireModelIDFrame(uint8_t moduleIdx, uint8_t * frame) uint8_t createCrossfireChannelsFrame(uint8_t moduleIdx, uint8_t * frame, int16_t * pulses) { // - // sends channel data and also communicates commanded armed status in arming mode Switch. - // frame len 24 -> arming mode CH5: module will use channel 5 - // frame len 25 -> arming mode Switch: send commanded armed status in extra byte after channel data - // - ModuleData *md = &g_model.moduleData[moduleIdx]; - - uint8_t armingMode = md->crsf.crsfArmingMode; // 0 = Channel mode, 1 = Switch mode - uint8_t lenAdjust = (armingMode == ARMING_MODE_SWITCH) ? 1 : 0; - + // sends channel data and also communicates status information in status byte: + // - arming mode Switch or CH5 + // - arming status in Switch mode + // - crsf errors + // uint8_t * buf = frame; *buf++ = MODULE_ADDRESS; - *buf++ = 24 + lenAdjust; // 1(ID) + 22(channel data) + (+1 extra byte if Switch mode) + 1(CRC) + *buf++ = 25; // 1(ID) + 22(channel data) + 1(extra status byte) + 1(CRC) uint8_t * crc_start = buf; *buf++ = CHANNELS_ID; + + // + // assemble channel data + // uint32_t bits = 0; uint8_t bitsavailable = 0; for (int i=0; icrsf.crsfArmingMode == ARMING_MODE_SWITCH) { swsrc_t sw = md->crsf.crsfArmingTrigger; - *buf++ = (sw != SWSRC_NONE) && getSwitch(sw, 0); // commanded armed status in Switch mode + *buf = (sw != SWSRC_NONE) && getSwitch(sw, 0); // commanded armed status in Switch mode + } else { + *buf = 0x02; // flag arming mode CH5 + } + + extern bool crsfErrorFlag; + if(crsfErrorFlag) { + *buf |= 0x04; // flag crsf error + crsfErrorFlag = false; } + + buf++; - *buf++ = crc8(crc_start, 23 + lenAdjust); + // + // add crc + // + *buf++ = crc8(crc_start, 24); + return buf - frame; } @@ -452,5 +471,4 @@ const etx_proto_driver_t CrossfireDriver = { .processData = nullptr, .processFrame = crossfireProcessFrame, .onConfigChange = nullptr, - .txCompleted = modulePortSerialTxCompleted, }; From a6406bc80e73374e49b7fb55f1e6b2d12cba655a Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Thu, 15 Jan 2026 18:53:24 +0100 Subject: [PATCH 2/4] make flagging crsf errors an example --- radio/src/pulses/crossfire.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/radio/src/pulses/crossfire.cpp b/radio/src/pulses/crossfire.cpp index be0dc25077b..6015660ad7f 100644 --- a/radio/src/pulses/crossfire.cpp +++ b/radio/src/pulses/crossfire.cpp @@ -136,11 +136,13 @@ uint8_t createCrossfireChannelsFrame(uint8_t moduleIdx, uint8_t * frame, int16_t *buf = 0x02; // flag arming mode CH5 } - extern bool crsfErrorFlag; - if(crsfErrorFlag) { - *buf |= 0x04; // flag crsf error - crsfErrorFlag = false; - } + // Example: flag crsf errors to ELRS in bit 2 for resending linkstats + // + //extern bool crsfErrorFlag; + //if(crsfErrorFlag) { + // *buf |= 0x04; // flag crsf error + // crsfErrorFlag = false; + //} buf++; From de13f39c03b924aa961941f86edccad0e15b717b Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Thu, 15 Jan 2026 19:00:37 +0100 Subject: [PATCH 3/4] updated comment on bit meanings --- radio/src/pulses/crossfire.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/radio/src/pulses/crossfire.cpp b/radio/src/pulses/crossfire.cpp index 6015660ad7f..cd49191db06 100644 --- a/radio/src/pulses/crossfire.cpp +++ b/radio/src/pulses/crossfire.cpp @@ -97,9 +97,9 @@ uint8_t createCrossfireChannelsFrame(uint8_t moduleIdx, uint8_t * frame, int16_t { // // sends channel data and also communicates status information in status byte: - // - arming mode Switch or CH5 - // - arming status in Switch mode - // - crsf errors + // - arming status in Switch mode (bit 0) + // - arming mode Switch or CH5 (bit 1) + // - bits 2-7 spare // uint8_t * buf = frame; *buf++ = MODULE_ADDRESS; From 2ca8d269a2130bb103318d751d5e5e55a9c9f1d1 Mon Sep 17 00:00:00 2001 From: Michael <101.37584@germanynet.de> Date: Thu, 15 Jan 2026 20:30:29 +0100 Subject: [PATCH 4/4] fix merge error --- radio/src/pulses/crossfire.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/radio/src/pulses/crossfire.cpp b/radio/src/pulses/crossfire.cpp index cd49191db06..a94aad449ba 100644 --- a/radio/src/pulses/crossfire.cpp +++ b/radio/src/pulses/crossfire.cpp @@ -473,4 +473,5 @@ const etx_proto_driver_t CrossfireDriver = { .processData = nullptr, .processFrame = crossfireProcessFrame, .onConfigChange = nullptr, + .txCompleted = modulePortSerialTxCompleted, };