Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/SCRIPTS/BF/MSP/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local MSP_STARTFLAG = bit32.lshift(1,4)
local mspSeq = 0
local mspRemoteSeq = 0
local mspRxBuf = {}
local mspRxError = false
local mspRxSize = 0
local mspRxCRC = 0
local mspRxReq = 0
Expand Down Expand Up @@ -65,17 +66,13 @@ end
function mspReceivedReply(payload)
local idx = 1
local status = payload[idx]
local err = bit32.btest(status, 0x80)
local version = bit32.rshift(bit32.band(status, 0x60), 5)
local start = bit32.btest(status, 0x10)
local seq = bit32.band(status, 0x0F)
idx = idx + 1
if err then
mspStarted = false
return nil
end
if start then
mspRxBuf = {}
mspRxError = bit32.btest(status, 0x80)
mspRxSize = payload[idx]
mspRxReq = mspLastReq
idx = idx + 1
Expand Down Expand Up @@ -117,7 +114,7 @@ function mspPollReply()
return nil
elseif mspReceivedReply(mspData) then
mspLastReq = 0
return mspRxReq, mspRxBuf
return mspRxReq, mspRxBuf, mspRxError
end
end
end
5 changes: 3 additions & 2 deletions src/SCRIPTS/BF/PAGES/vtx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ local labels = {}
local fields = {}

local vtx_tables
if apiVersion >= 1.42 then
vtx_tables = assert(loadScript("VTX_TABLES/"..mcuId..".lua"))()
local f = loadScript("VTX_TABLES/"..mcuId..".lua")
if apiVersion >= 1.42 and f then
vtx_tables = f()
else
vtx_tables = assert(loadScript("VTX_TABLES/vtx_defaults.lua"))()
end
Expand Down
4 changes: 2 additions & 2 deletions src/SCRIPTS/BF/acc_cal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ local accCalibrated = false
local lastRunTS = 0
local INTERVAL = 500

local function processMspReply(cmd,rx_buf)
if cmd == MSP_ACC_CALIBRATION then
local function processMspReply(cmd,rx_buf,err)
if cmd == MSP_ACC_CALIBRATION and not err then
accCalibrated = true
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/SCRIPTS/BF/api_version.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ local apiVersionReceived = false
local lastRunTS = 0
local INTERVAL = 50

local function processMspReply(cmd,rx_buf)
if cmd == MSP_API_VERSION and #rx_buf >= 3 then
local function processMspReply(cmd,rx_buf,err)
if cmd == MSP_API_VERSION and #rx_buf >= 3 and not err then
apiVersion = rx_buf[2] + rx_buf[3] / 100
apiVersionReceived = true
end
Expand Down
4 changes: 2 additions & 2 deletions src/SCRIPTS/BF/board_info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ local i2cRegisteredDeviceCount = 0
local lastRunTS = 0
local INTERVAL = 100

local function processMspReply(cmd, payload)
if cmd == MSP_BOARD_INFO then
local function processMspReply(cmd, payload, err)
if cmd == MSP_BOARD_INFO and not err then
local length
local i = 1
length = 4
Expand Down
4 changes: 2 additions & 2 deletions src/SCRIPTS/BF/mcu_id.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ local MCUIdReceived = false
local lastRunTS = 0
local INTERVAL = 100

local function processMspReply(cmd, payload)
if cmd == MSP_UID then
local function processMspReply(cmd, payload, err)
if cmd == MSP_UID and not err then
local i = 1
local id = ""
for j = 1, 3 do
Expand Down
4 changes: 2 additions & 2 deletions src/SCRIPTS/BF/rssi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ local rssiSource = RSSI_SOURCE_NONE
local lastRunTS = 0
local INTERVAL = 50

local function processMspReply(cmd,rx_buf)
if cmd == MSP_TX_INFO and #rx_buf >= 1 then
local function processMspReply(cmd,rx_buf,err)
if cmd == MSP_TX_INFO and #rx_buf >= 1 and not err then
rssiSource = rx_buf[1]
rssiSourceReceived = true
end
Expand Down
4 changes: 2 additions & 2 deletions src/SCRIPTS/BF/rtc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ local timeIsSet = false
local lastRunTS = 0
local INTERVAL = 50

local function processMspReply(cmd,rx_buf)
if cmd == MSP_SET_RTC then
local function processMspReply(cmd,rx_buf,err)
if cmd == MSP_SET_RTC and not err then
timeIsSet = true
end
end
Expand Down
5 changes: 4 additions & 1 deletion src/SCRIPTS/BF/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ local function createPopupMenu()
end
end

local function processMspReply(cmd,rx_buf)
local function processMspReply(cmd,rx_buf,err)
if not Page or not rx_buf then
elseif cmd == Page.write then
if Page.eepromWrite then
Expand All @@ -109,6 +109,9 @@ local function processMspReply(cmd,rx_buf)
rebootFc()
end
invalidatePages()
elseif cmd == Page.read and err then
Page.fields = { { x = 6, y = radio.yMinLimit, value = "", ro = true } }
Page.labels = { { x = 6, y = radio.yMinLimit, t = "N/A" } }
elseif cmd == Page.read and #rx_buf > 0 then
Page.values = rx_buf
for i=1,#Page.fields do
Expand Down
9 changes: 7 additions & 2 deletions src/SCRIPTS/BF/vtx_tables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local MSP_VTX_CONFIG = 88
local MSP_VTXTABLE_BAND = 137
local MSP_VTXTABLE_POWERLEVEL = 138

local vtxAvailable = true
local vtxTableAvailable = false
local vtxConfigReceived = false
local vtxFrequencyTableReceived = false
Expand All @@ -18,8 +19,12 @@ local powerTable = {}
local lastRunTS = 0
local INTERVAL = 100

local function processMspReply(cmd, payload)
local function processMspReply(cmd, payload, err)
if cmd == MSP_VTX_CONFIG then
if err then
vtxAvailable = false
return
end
vtxConfigReceived = true
vtxTableAvailable = payload[12] ~= 0
vtxTableConfig.bands = payload[13]
Expand Down Expand Up @@ -113,7 +118,7 @@ local function getVtxTables()
end
mspProcessTxQ()
processMspReply(mspPollReply())
return vtxTablesReceived
return vtxTablesReceived or not vtxAvailable
end

return { f = getVtxTables, t = "Downloading VTX tables" }