fix(radio): race condition on pulse buffer (#6634)

This commit is contained in:
Raphael Coeffic
2025-10-14 20:42:41 +10:00
committed by GitHub
parent 2cbd995f35
commit dd029bc591
22 changed files with 73 additions and 6 deletions
+10
View File
@@ -262,6 +262,8 @@ class ProtoState
void applyConfigFromModel();
bool fifoFull() { return trsp.fifoFull(); }
protected:
void resetConfig(uint8_t version);
@@ -1159,6 +1161,13 @@ static void sendPulses(void* ctx, uint8_t* buffer, int16_t* channels,
p_state->sendFrame();
}
static bool txCompleted(void* ctx)
{
auto mod_st = (etx_module_state_t*)ctx;
auto p_state = (ProtoState*)mod_st->user_data;
return !p_state->fifoFull();
}
etx_proto_driver_t ProtoDriver = {
.protocol = PROTOCOL_CHANNELS_AFHDS3,
.init = initModule,
@@ -1167,6 +1176,7 @@ etx_proto_driver_t ProtoDriver = {
.processData = processTelemetryData,
.processFrame = nullptr,
.onConfigChange = nullptr,
.txCompleted = txCompleted,
};
} // namespace afhds3
+3
View File
@@ -129,6 +129,7 @@ struct CommandFifo {
}
inline bool isEmpty() const { return (getIndex == setIndex); }
inline bool isFull() const { return nextIndex(setIndex) == getIndex; }
inline void skip() { getIndex = nextIndex(getIndex); }
@@ -204,6 +205,8 @@ class Transport
void sendBuffer();
bool fifoFull() { return fifo.isFull(); }
/**
* Process retransmissions
* error: transport is in error state
+1
View File
@@ -452,4 +452,5 @@ const etx_proto_driver_t CrossfireDriver = {
.processData = nullptr,
.processFrame = crossfireProcessFrame,
.onConfigChange = nullptr,
.txCompleted = modulePortSerialTxCompleted,
};
+2
View File
@@ -298,6 +298,7 @@ const etx_proto_driver_t DSM2Driver = {
.processData = nullptr,
.processFrame = nullptr,
.onConfigChange = dsm2ConfigChange,
.txCompleted = modulePortSerialTxCompleted,
};
const etx_proto_driver_t DSMPDriver = {
@@ -308,4 +309,5 @@ const etx_proto_driver_t DSMPDriver = {
.processData = dsmpProcessData,
.processFrame = nullptr,
.onConfigChange = nullptr,
.txCompleted = modulePortSerialTxCompleted,
};
+1
View File
@@ -255,4 +255,5 @@ const etx_proto_driver_t GhostDriver = {
.processData = ghostProcessData,
.processFrame = nullptr,
.onConfigChange = nullptr,
.txCompleted = modulePortSerialTxCompleted,
};
+1
View File
@@ -288,6 +288,7 @@ const etx_proto_driver_t MultiDriver = {
.processData = multiProcessData,
.processFrame = nullptr,
.onConfigChange = nullptr,
.txCompleted = modulePortSerialTxCompleted,
};
static void sendChannels(uint8_t*& p_buf, uint8_t module)
+1
View File
@@ -244,4 +244,5 @@ const etx_proto_driver_t PpmDriver = {
.processData = ppmProcessTelemetryData,
.processFrame = nullptr,
.onConfigChange = ppmOnConfigChange,
.txCompleted = modulePortTimerTxCompleted,
};
+3
View File
@@ -551,6 +551,9 @@ void pulsesSendNextFrame(uint8_t module)
state.settings_updated = 0;
}
// if previous frame not completed, skip this one
if (!drv->txCompleted(ctx)) return;
uint8_t channelStart = g_model.moduleData[module].channelsStart;
int16_t* channels = &channelOutputs[channelStart];
uint8_t nChannels = 16; // TODO: MAX_CHANNELS - channelsStart
+1
View File
@@ -416,4 +416,5 @@ const etx_proto_driver_t Pxx1Driver = {
.processData = pxx1ProcessData,
.processFrame = nullptr,
.onConfigChange = nullptr,
.txCompleted = modulePortSerialTxCompleted,
};
+1 -1
View File
@@ -833,7 +833,6 @@ static void pxx2ProcessData(void* ctx, uint8_t data, uint8_t* buffer, uint8_t* l
}
#include "hal/module_driver.h"
// #include "extmodule_serial_driver.h"
const etx_proto_driver_t Pxx2Driver = {
.protocol = PROTOCOL_CHANNELS_PXX2,
@@ -843,4 +842,5 @@ const etx_proto_driver_t Pxx2Driver = {
.processData = pxx2ProcessData,
.processFrame = nullptr,
.onConfigChange = nullptr,
.txCompleted = modulePortSerialTxCompleted,
};
+1
View File
@@ -217,4 +217,5 @@ const etx_proto_driver_t SBusDriver = {
.processData = sbusProcessTelemetryData,
.processFrame = nullptr,
.onConfigChange = sbusOnConfigChange,
.txCompleted = modulePortSerialTxCompleted,
};