From b836c947c219b411ee16595c0682401709d52655 Mon Sep 17 00:00:00 2001 From: 3djc Date: Wed, 28 Aug 2019 07:45:46 +0200 Subject: [PATCH 1/2] Correctly respond to luaSportTelemetryPush(), luaCrossfireTelemetryPush() with L=0 (fix BF scripts) --- radio/src/lua/api_general.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 7b750487e..070728073 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -433,7 +433,7 @@ 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, outputTelemetryBuffer.isAvailable()); + lua_pushboolean(L, telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT ? outputTelemetryBuffer.isAvailable() : false); return 1; } @@ -630,7 +630,7 @@ When called without parameters, it will only return the status of the output buf static int luaCrossfireTelemetryPush(lua_State * L) { if (lua_gettop(L) == 0) { - lua_pushboolean(L, outputTelemetryBuffer.isAvailable()); + lua_pushboolean(L, telemetryProtocol == PROTOCOL_TELEMETRY_CROSSFIRE ? outputTelemetryBuffer.isAvailable() : false); } else if (outputTelemetryBuffer.isAvailable()) { uint8_t command = luaL_checkunsigned(L, 1); From 4787b89b87c32e6e91de5b88d03495949f84f3fc Mon Sep 17 00:00:00 2001 From: 3djc Date: Wed, 28 Aug 2019 08:48:19 +0200 Subject: [PATCH 2/2] Improvement --- radio/src/lua/api_general.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 070728073..63eaefd9d 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -432,8 +432,13 @@ When called without parameters, it will only return the status of the output buf static int luaSportTelemetryPush(lua_State * L) { + if (telemetryProtocol != PROTOCOL_TELEMETRY_FRSKY_SPORT) { + lua_pushboolean(L, false); + return 1; + } + if (lua_gettop(L) == 0) { - lua_pushboolean(L, telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT ? outputTelemetryBuffer.isAvailable() : false); + lua_pushboolean(L, outputTelemetryBuffer.isAvailable()); return 1; } @@ -629,8 +634,13 @@ When called without parameters, it will only return the status of the output buf */ static int luaCrossfireTelemetryPush(lua_State * L) { + if (telemetryProtocol != PROTOCOL_TELEMETRY_CROSSFIRE) { + lua_pushboolean(L, false); + return 1; + } + if (lua_gettop(L) == 0) { - lua_pushboolean(L, telemetryProtocol == PROTOCOL_TELEMETRY_CROSSFIRE ? outputTelemetryBuffer.isAvailable() : false); + lua_pushboolean(L, outputTelemetryBuffer.isAvailable()); } else if (outputTelemetryBuffer.isAvailable()) { uint8_t command = luaL_checkunsigned(L, 1);