S.PORT Push with PXX2 (still not tested)
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
bool isSportOutputBufferAvailable()
|
bool isTelemetryOutputBufferAvailable()
|
||||||
{
|
{
|
||||||
return (outputTelemetryBuffer.size == 0 && outputTelemetryBuffer.trigger == 0x7E);
|
return (outputTelemetryBuffer.size == 0 && outputTelemetryBuffer.trigger == 0x7E);
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,6 @@ void sportOutputPushByte(uint8_t byte)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO merge it with S.PORT update function when finished
|
|
||||||
void sportOutputPushPacket(SportTelemetryPacket * packet)
|
void sportOutputPushPacket(SportTelemetryPacket * packet)
|
||||||
{
|
{
|
||||||
uint16_t crc = 0;
|
uint16_t crc = 0;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ PACK(union SportTelemetryPacket
|
|||||||
uint8_t raw[8];
|
uint8_t raw[8];
|
||||||
});
|
});
|
||||||
|
|
||||||
bool isSportOutputBufferAvailable();
|
bool isTelemetryOutputBufferAvailable();
|
||||||
void sportOutputPushPacket(SportTelemetryPacket * packet);
|
void sportOutputPushPacket(SportTelemetryPacket * packet);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -422,9 +422,9 @@ When called without parameters, it will only return the status of the output buf
|
|||||||
static int luaSportTelemetryPush(lua_State * L)
|
static int luaSportTelemetryPush(lua_State * L)
|
||||||
{
|
{
|
||||||
if (lua_gettop(L) == 0) {
|
if (lua_gettop(L) == 0) {
|
||||||
lua_pushboolean(L, isSportOutputBufferAvailable());
|
lua_pushboolean(L, isTelemetryOutputBufferAvailable());
|
||||||
}
|
}
|
||||||
else if (isSportOutputBufferAvailable()) {
|
else if (isTelemetryOutputBufferAvailable()) {
|
||||||
SportTelemetryPacket packet;
|
SportTelemetryPacket packet;
|
||||||
packet.physicalId = getDataId(luaL_checkunsigned(L, 1));
|
packet.physicalId = getDataId(luaL_checkunsigned(L, 1));
|
||||||
packet.primId = luaL_checkunsigned(L, 2);
|
packet.primId = luaL_checkunsigned(L, 2);
|
||||||
@@ -439,6 +439,59 @@ static int luaSportTelemetryPush(lua_State * L)
|
|||||||
return 1;
|
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)
|
#if defined(CROSSFIRE)
|
||||||
/*luadoc
|
/*luadoc
|
||||||
@function crossfireTelemetryPop()
|
@function crossfireTelemetryPop()
|
||||||
|
|||||||
@@ -238,3 +238,16 @@ void processPXX2TelemetryFrame(uint8_t module, uint8_t * frame)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pushPXX2TelemetryPacket(uint8_t module, uint8_t rx_uid, SportTelemetryPacket * packet)
|
||||||
|
{
|
||||||
|
// Flag0
|
||||||
|
outputTelemetryBuffer.push(rx_uid);
|
||||||
|
|
||||||
|
for (uint8_t i=1; i<sizeof(SportTelemetryPacket); i++) {
|
||||||
|
uint8_t byte = packet->raw[i];
|
||||||
|
outputTelemetryBuffer.push(byte);
|
||||||
|
}
|
||||||
|
|
||||||
|
outputTelemetryBuffer.setDestination(module);
|
||||||
|
}
|
||||||
|
|||||||
@@ -197,6 +197,6 @@ extern Fifo<uint8_t, LUA_TELEMETRY_INPUT_FIFO_SIZE> * luaInputTelemetryFifo;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void processPXX2TelemetryFrame(uint8_t module, uint8_t * frame);
|
void processPXX2TelemetryFrame(uint8_t module, uint8_t * frame);
|
||||||
|
void pushPXX2TelemetryPacket(uint8_t module, uint8_t rx_uid, SportTelemetryPacket * packet);
|
||||||
|
|
||||||
#endif // _TELEMETRY_H_
|
#endif // _TELEMETRY_H_
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user