mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 20:35:17 +03:00
lua: allow telemetry buffer availability to be queried
When crossfireTelemetryPush() or sportTelemetryPush() is called without arguments, it returns a boolean telling whether or not the output buffer is currently available. This simplifies the LUA in case SPORT or Crossfire is used as a transport for bigger requests (like MSP/SPORT).
This commit is contained in:
parent
fd127e1ec2
commit
a315f6702b
1 changed files with 8 additions and 2 deletions
|
@ -333,7 +333,10 @@ uint8_t getDataId(uint8_t physicalId)
|
||||||
|
|
||||||
static int luaSportTelemetryPush(lua_State * L)
|
static int luaSportTelemetryPush(lua_State * L)
|
||||||
{
|
{
|
||||||
if (isSportOutputBufferAvailable()) {
|
if (lua_gettop(L) == 0) {
|
||||||
|
lua_pushboolean(L, isSportOutputBufferAvailable());
|
||||||
|
}
|
||||||
|
else if (isSportOutputBufferAvailable()) {
|
||||||
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);
|
||||||
|
@ -378,7 +381,10 @@ static int luaCrossfireTelemetryPop(lua_State * L)
|
||||||
|
|
||||||
static int luaCrossfireTelemetryPush(lua_State * L)
|
static int luaCrossfireTelemetryPush(lua_State * L)
|
||||||
{
|
{
|
||||||
if (isCrossfireOutputBufferAvailable()) {
|
if (lua_gettop(L) == 0) {
|
||||||
|
lua_pushboolean(L, isCrossfireOutputBufferAvailable());
|
||||||
|
}
|
||||||
|
else if (isCrossfireOutputBufferAvailable()) {
|
||||||
uint8_t command = luaL_checkunsigned(L, 1);
|
uint8_t command = luaL_checkunsigned(L, 1);
|
||||||
luaL_checktype(L, 2, LUA_TTABLE);
|
luaL_checktype(L, 2, LUA_TTABLE);
|
||||||
uint8_t length = luaL_len(L, 2);
|
uint8_t length = luaL_len(L, 2);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue