1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-15 20:35:17 +03:00

S.PORT Push with PXX2 (still not tested)

This commit is contained in:
Bertrand Songis 2019-03-20 17:04:23 +01:00
parent 04ba9e5c68
commit 7d2f3dff5a
5 changed files with 71 additions and 6 deletions

View file

@ -422,9 +422,9 @@ When called without parameters, it will only return the status of the output buf
static int luaSportTelemetryPush(lua_State * L)
{
if (lua_gettop(L) == 0) {
lua_pushboolean(L, isSportOutputBufferAvailable());
lua_pushboolean(L, isTelemetryOutputBufferAvailable());
}
else if (isSportOutputBufferAvailable()) {
else if (isTelemetryOutputBufferAvailable()) {
SportTelemetryPacket packet;
packet.physicalId = getDataId(luaL_checkunsigned(L, 1));
packet.primId = luaL_checkunsigned(L, 2);
@ -439,6 +439,59 @@ static int luaSportTelemetryPush(lua_State * L)
return 1;
}
/*luadoc
@function pxx2TelemetryPush()
This functions allows for sending SPORT telemetry data toward the receiver,
and more generally, to anything connected SPORT bus on the receiver or transmitter.
When called without parameters, it will only return the status of the output buffer without sending anything.
@param module module index
@param receiver receiver index
@param sensorId physical sensor ID
@param frameId frame ID
@param dataId data ID
@param value value
@retval boolean data queued in output buffer or not.
@status current Introduced in 2.3.0
*/
static int luaPXX2TelemetryPush(lua_State * L)
{
if (lua_gettop(L) == 0) {
lua_pushboolean(L, isTelemetryOutputBufferAvailable());
}
else if (isTelemetryOutputBufferAvailable()) {
SportTelemetryPacket packet;
uint8_t module = getDataId(luaL_checkunsigned(L, 1));
uint8_t receiver = getDataId(luaL_checkunsigned(L, 2));
uint8_t rx_uid = g_model.moduleData[module].pxx2.getReceiverSlot(receiver);
if (rx_uid > 0) {
// TODO add more controls (module started, module = PXX2, etc.)
packet.physicalId = getDataId(luaL_checkunsigned(L, 3));
packet.primId = luaL_checkunsigned(L, 4);
packet.dataId = luaL_checkunsigned(L, 5);
packet.value = luaL_checkunsigned(L, 6);
pushPXX2TelemetryPacket(module, rx_uid - 1, &packet);
lua_pushboolean(L, true);
}
else {
lua_pushboolean(L, false);
}
}
else {
lua_pushboolean(L, false);
}
return 1;
}
#if defined(CROSSFIRE)
/*luadoc
@function crossfireTelemetryPop()