Fixed pushing CRSF telem packets to internal module
This commit is contained in:
committed by
Raphael Coeffic
parent
9fb741be98
commit
043c1e6a2d
@@ -696,7 +696,10 @@ When called without parameters, it will only return the status of the output buf
|
|||||||
*/
|
*/
|
||||||
static int luaCrossfireTelemetryPush(lua_State * L)
|
static int luaCrossfireTelemetryPush(lua_State * L)
|
||||||
{
|
{
|
||||||
if (telemetryProtocol != PROTOCOL_TELEMETRY_CROSSFIRE) {
|
bool sport = (telemetryProtocol == PROTOCOL_TELEMETRY_CROSSFIRE);
|
||||||
|
bool internal = (moduleState[INTERNAL_MODULE].protocol == PROTOCOL_CHANNELS_CROSSFIRE);
|
||||||
|
|
||||||
|
if (!internal && !sport) {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -719,8 +722,8 @@ static int luaCrossfireTelemetryPush(lua_State * L)
|
|||||||
lua_rawgeti(L, 2, i+1);
|
lua_rawgeti(L, 2, i+1);
|
||||||
outputTelemetryBuffer.pushByte(luaL_checkunsigned(L, -1));
|
outputTelemetryBuffer.pushByte(luaL_checkunsigned(L, -1));
|
||||||
}
|
}
|
||||||
outputTelemetryBuffer.pushByte(crc8(outputTelemetryBuffer.data+2, 1 + length));
|
outputTelemetryBuffer.pushByte(crc8(outputTelemetryBuffer.data + 2, 1 + length));
|
||||||
outputTelemetryBuffer.setDestination(TELEMETRY_ENDPOINT_SPORT);
|
outputTelemetryBuffer.setDestination(internal ? 0 : TELEMETRY_ENDPOINT_SPORT);
|
||||||
lua_pushboolean(L, true);
|
lua_pushboolean(L, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -70,10 +70,11 @@ uint8_t createCrossfireChannelsFrame(uint8_t * frame, int16_t * pulses)
|
|||||||
return buf - frame;
|
return buf - frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setupPulsesCrossfire(uint8_t idx, CrossfirePulsesData* p_data)
|
static void setupPulsesCrossfire(uint8_t idx, CrossfirePulsesData* p_data,
|
||||||
|
uint8_t endpoint)
|
||||||
{
|
{
|
||||||
#if defined(LUA)
|
#if defined(LUA)
|
||||||
if (outputTelemetryBuffer.destination == TELEMETRY_ENDPOINT_SPORT) {
|
if (outputTelemetryBuffer.destination == endpoint) {
|
||||||
memcpy(p_data->pulses, outputTelemetryBuffer.data,
|
memcpy(p_data->pulses, outputTelemetryBuffer.data,
|
||||||
outputTelemetryBuffer.size);
|
outputTelemetryBuffer.size);
|
||||||
p_data->length = outputTelemetryBuffer.size;
|
p_data->length = outputTelemetryBuffer.size;
|
||||||
@@ -96,9 +97,9 @@ void setupPulsesCrossfire(uint8_t idx)
|
|||||||
{
|
{
|
||||||
if (idx == INTERNAL_MODULE) {
|
if (idx == INTERNAL_MODULE) {
|
||||||
auto* p_data = &intmodulePulsesData.crossfire;
|
auto* p_data = &intmodulePulsesData.crossfire;
|
||||||
setupPulsesCrossfire(idx, p_data);
|
setupPulsesCrossfire(idx, p_data, 0);
|
||||||
} else if (telemetryProtocol == PROTOCOL_TELEMETRY_CROSSFIRE) {
|
} else if (telemetryProtocol == PROTOCOL_TELEMETRY_CROSSFIRE) {
|
||||||
auto* p_data = &extmodulePulsesData.crossfire;
|
auto* p_data = &extmodulePulsesData.crossfire;
|
||||||
setupPulsesCrossfire(idx, p_data);
|
setupPulsesCrossfire(idx, p_data, TELEMETRY_ENDPOINT_SPORT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user