Bsongis/crossfire refactoring (#3613)

* Crossfire refactoring

* Crossfire script now displaying fields

* Crossfire script now displaying text selection values
This commit is contained in:
Bertrand Songis
2016-06-18 22:16:50 +02:00
committed by GitHub
parent ab58151f2a
commit 53b51cac94
16 changed files with 288 additions and 177 deletions
+12 -10
View File
@@ -196,27 +196,30 @@ void processCrossfireTelemetryFrame()
#if defined(LUA)
default:
if (luaInputTelemetryFifo) {
LuaTelemetryPacket luaPacket;
luaPacket.crossfire.command = id;
luaPacket.crossfire.length = telemetryRxBuffer[1]-2;
for (int i=0; i<min<int>(sizeof(luaPacket.crossfire.data), luaPacket.crossfire.length); i++) {
luaPacket.crossfire.data[i] = telemetryRxBuffer[3+i];
for (uint8_t i=1; i<telemetryRxBufferCount-1; i++) {
// destination address and CRC are skipped
luaInputTelemetryFifo->push(telemetryRxBuffer[i]);
}
luaInputTelemetryFifo->push(luaPacket);
}
break;
#endif
}
}
bool isCrossfireOutputBufferAvailable()
{
return outputTelemetryBufferSize == 0;
}
void processCrossfireTelemetryData(uint8_t data)
{
if (telemetryRxBufferCount == 0 && data != 0x00) {
if (telemetryRxBufferCount == 0 && data != RADIO_ADDRESS) {
TRACE("processCrossfirePacket(): address 0x%02X error", data);
return;
}
if (telemetryRxBufferCount == 1 && (data < 2 || data > TELEMETRY_RX_PACKET_SIZE-2)) {
TRACE("processCrossfirePacket(): length 0x%02X error", data);
telemetryRxBufferCount = 0;
return;
}
@@ -225,8 +228,7 @@ void processCrossfireTelemetryData(uint8_t data)
telemetryRxBuffer[telemetryRxBufferCount++] = data;
}
else {
TRACE("processCrossfirePacket(): length error ");
DUMP(telemetryRxBuffer, TELEMETRY_RX_PACKET_SIZE);
TRACE("processCrossfirePacket(): array size error, %d", telemetryRxBufferCount);
telemetryRxBufferCount = 0;
}