Skip to content

Commit e2597af

Browse files
committed
Skip vtx tables download if not available
1 parent 6676a11 commit e2597af

File tree

10 files changed

+27
-24
lines changed

10 files changed

+27
-24
lines changed

src/SCRIPTS/BF/MSP/common.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local MSP_STARTFLAG = bit32.lshift(1,4)
66
local mspSeq = 0
77
local mspRemoteSeq = 0
88
local mspRxBuf = {}
9+
local mspRxError = false
910
local mspRxSize = 0
1011
local mspRxCRC = 0
1112
local mspRxReq = 0
@@ -65,17 +66,13 @@ end
6566
function mspReceivedReply(payload)
6667
local idx = 1
6768
local status = payload[idx]
68-
local err = bit32.btest(status, 0x80)
6969
local version = bit32.rshift(bit32.band(status, 0x60), 5)
7070
local start = bit32.btest(status, 0x10)
7171
local seq = bit32.band(status, 0x0F)
7272
idx = idx + 1
73-
if err then
74-
mspStarted = false
75-
return nil
76-
end
7773
if start then
7874
mspRxBuf = {}
75+
mspRxError = bit32.btest(status, 0x80)
7976
mspRxSize = payload[idx]
8077
mspRxReq = mspLastReq
8178
idx = idx + 1
@@ -117,7 +114,7 @@ function mspPollReply()
117114
return nil
118115
elseif mspReceivedReply(mspData) then
119116
mspLastReq = 0
120-
return mspRxReq, mspRxBuf
117+
return mspRxReq, mspRxBuf, mspRxError
121118
end
122119
end
123120
end

src/SCRIPTS/BF/PAGES/vtx.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ local labels = {}
1212
local fields = {}
1313

1414
local vtx_tables
15-
if apiVersion >= 1.42 then
16-
vtx_tables = assert(loadScript("VTX_TABLES/"..mcuId..".lua"))()
15+
local f = loadScript("VTX_TABLES/"..mcuId..".lua")
16+
if apiVersion >= 1.42 and f then
17+
vtx_tables = f()
1718
else
1819
vtx_tables = assert(loadScript("VTX_TABLES/vtx_defaults.lua"))()
1920
end

src/SCRIPTS/BF/acc_cal.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ local accCalibrated = false
33
local lastRunTS = 0
44
local INTERVAL = 500
55

6-
local function processMspReply(cmd,rx_buf)
7-
if cmd == MSP_ACC_CALIBRATION then
6+
local function processMspReply(cmd,rx_buf,err)
7+
if cmd == MSP_ACC_CALIBRATION and not err then
88
accCalibrated = true
99
end
1010
end

src/SCRIPTS/BF/api_version.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ local apiVersionReceived = false
44
local lastRunTS = 0
55
local INTERVAL = 50
66

7-
local function processMspReply(cmd,rx_buf)
8-
if cmd == MSP_API_VERSION and #rx_buf >= 3 then
7+
local function processMspReply(cmd,rx_buf,err)
8+
if cmd == MSP_API_VERSION and #rx_buf >= 3 and not err then
99
apiVersion = rx_buf[2] + rx_buf[3] / 100
1010
apiVersionReceived = true
1111
end

src/SCRIPTS/BF/board_info.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ local i2cRegisteredDeviceCount = 0
2020
local lastRunTS = 0
2121
local INTERVAL = 100
2222

23-
local function processMspReply(cmd, payload)
24-
if cmd == MSP_BOARD_INFO then
23+
local function processMspReply(cmd, payload, err)
24+
if cmd == MSP_BOARD_INFO and not err then
2525
local length
2626
local i = 1
2727
length = 4

src/SCRIPTS/BF/mcu_id.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ local MCUIdReceived = false
55
local lastRunTS = 0
66
local INTERVAL = 100
77

8-
local function processMspReply(cmd, payload)
9-
if cmd == MSP_UID then
8+
local function processMspReply(cmd, payload, err)
9+
if cmd == MSP_UID and not err then
1010
local i = 1
1111
local id = ""
1212
for j = 1, 3 do

src/SCRIPTS/BF/rssi.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ local rssiSource = RSSI_SOURCE_NONE
99
local lastRunTS = 0
1010
local INTERVAL = 50
1111

12-
local function processMspReply(cmd,rx_buf)
13-
if cmd == MSP_TX_INFO and #rx_buf >= 1 then
12+
local function processMspReply(cmd,rx_buf,err)
13+
if cmd == MSP_TX_INFO and #rx_buf >= 1 and not err then
1414
rssiSource = rx_buf[1]
1515
rssiSourceReceived = true
1616
end

src/SCRIPTS/BF/rtc.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ local timeIsSet = false
44
local lastRunTS = 0
55
local INTERVAL = 50
66

7-
local function processMspReply(cmd,rx_buf)
8-
if cmd == MSP_SET_RTC then
7+
local function processMspReply(cmd,rx_buf,err)
8+
if cmd == MSP_SET_RTC and not err then
99
timeIsSet = true
1010
end
1111
end

src/SCRIPTS/BF/ui.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ local function createPopupMenu()
9696
end
9797
end
9898

99-
local function processMspReply(cmd,rx_buf)
100-
if not Page or not rx_buf then
99+
local function processMspReply(cmd,rx_buf,err)
100+
if not Page or not rx_buf or err then
101101
elseif cmd == Page.write then
102102
if Page.eepromWrite then
103103
eepromWrite()

src/SCRIPTS/BF/vtx_tables.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local MSP_VTX_CONFIG = 88
22
local MSP_VTXTABLE_BAND = 137
33
local MSP_VTXTABLE_POWERLEVEL = 138
44

5+
local vtxAvailable = true
56
local vtxTableAvailable = false
67
local vtxConfigReceived = false
78
local vtxFrequencyTableReceived = false
@@ -18,8 +19,12 @@ local powerTable = {}
1819
local lastRunTS = 0
1920
local INTERVAL = 100
2021

21-
local function processMspReply(cmd, payload)
22+
local function processMspReply(cmd, payload, err)
2223
if cmd == MSP_VTX_CONFIG then
24+
if err then
25+
vtxAvailable = false
26+
return
27+
end
2328
vtxConfigReceived = true
2429
vtxTableAvailable = payload[12] ~= 0
2530
vtxTableConfig.bands = payload[13]
@@ -113,7 +118,7 @@ local function getVtxTables()
113118
end
114119
mspProcessTxQ()
115120
processMspReply(mspPollReply())
116-
return vtxTablesReceived
121+
return vtxTablesReceived or not vtxAvailable
117122
end
118123

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

0 commit comments

Comments
 (0)