Skip to content

Commit d900131

Browse files
authored
Merge pull request #475 from klutvott123/skip-vtx-table
Skip vtx tables download if not available
2 parents 6676a11 + 61d3029 commit d900131

File tree

9 files changed

+32
-21
lines changed

9 files changed

+32
-21
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/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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ local function createPopupMenu()
9696
end
9797
end
9898

99-
local function processMspReply(cmd,rx_buf)
99+
local function processMspReply(cmd,rx_buf,err)
100100
if not Page or not rx_buf then
101101
elseif cmd == Page.write then
102102
if Page.eepromWrite then
@@ -109,6 +109,9 @@ local function processMspReply(cmd,rx_buf)
109109
rebootFc()
110110
end
111111
invalidatePages()
112+
elseif cmd == Page.read and err then
113+
Page.fields = { { x = 6, y = radio.yMinLimit, value = "", ro = true } }
114+
Page.labels = { { x = 6, y = radio.yMinLimit, t = "N/A" } }
112115
elseif cmd == Page.read and #rx_buf > 0 then
113116
Page.values = rx_buf
114117
for i=1,#Page.fields do

src/SCRIPTS/BF/vtx_tables.lua

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,26 @@ local requestedBand = 1
1111
local requestedPowerLevel = 1
1212
local vtxTableConfig = {}
1313
local frequencyTable = {}
14-
local frequenciesPerBand = 0
1514
local bandTable = {}
1615
local powerTable = {}
1716

1817
local lastRunTS = 0
1918
local INTERVAL = 100
2019

21-
local function processMspReply(cmd, payload)
20+
local function processMspReply(cmd, payload, err)
2221
if cmd == MSP_VTX_CONFIG then
22+
if err then
23+
-- Vtx not available. Create empty vtx table to skip future download attempts
24+
frequencyTable[1] = {}
25+
vtxTableConfig.channels = 0
26+
bandTable = { [0] = "U", "1" }
27+
powerTable = { "LV0" }
28+
vtxConfigReceived = true
29+
vtxTableAvailable = true
30+
vtxFrequencyTableReceived = true
31+
vtxPowerTableReceived = true
32+
return
33+
end
2334
vtxConfigReceived = true
2435
vtxTableAvailable = payload[12] ~= 0
2536
vtxTableConfig.bands = payload[13]

0 commit comments

Comments
 (0)