diff --git a/src/SCRIPTS/BF/MSP/common.lua b/src/SCRIPTS/BF/MSP/common.lua index dc20f9b..467c1ce 100644 --- a/src/SCRIPTS/BF/MSP/common.lua +++ b/src/SCRIPTS/BF/MSP/common.lua @@ -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 @@ -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 @@ -117,7 +114,7 @@ function mspPollReply() return nil elseif mspReceivedReply(mspData) then mspLastReq = 0 - return mspRxReq, mspRxBuf + return mspRxReq, mspRxBuf, mspRxError end end end diff --git a/src/SCRIPTS/BF/acc_cal.lua b/src/SCRIPTS/BF/acc_cal.lua index 582d459..0ebfc17 100644 --- a/src/SCRIPTS/BF/acc_cal.lua +++ b/src/SCRIPTS/BF/acc_cal.lua @@ -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 diff --git a/src/SCRIPTS/BF/api_version.lua b/src/SCRIPTS/BF/api_version.lua index c80efb3..5bcb4c2 100644 --- a/src/SCRIPTS/BF/api_version.lua +++ b/src/SCRIPTS/BF/api_version.lua @@ -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 diff --git a/src/SCRIPTS/BF/board_info.lua b/src/SCRIPTS/BF/board_info.lua index 10efbe4..2ba3ec1 100644 --- a/src/SCRIPTS/BF/board_info.lua +++ b/src/SCRIPTS/BF/board_info.lua @@ -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 diff --git a/src/SCRIPTS/BF/mcu_id.lua b/src/SCRIPTS/BF/mcu_id.lua index 26d1e2b..f3c8438 100644 --- a/src/SCRIPTS/BF/mcu_id.lua +++ b/src/SCRIPTS/BF/mcu_id.lua @@ -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 diff --git a/src/SCRIPTS/BF/rssi.lua b/src/SCRIPTS/BF/rssi.lua index 401e710..dc31dd0 100644 --- a/src/SCRIPTS/BF/rssi.lua +++ b/src/SCRIPTS/BF/rssi.lua @@ -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 diff --git a/src/SCRIPTS/BF/rtc.lua b/src/SCRIPTS/BF/rtc.lua index 148a2fd..f0cd330 100644 --- a/src/SCRIPTS/BF/rtc.lua +++ b/src/SCRIPTS/BF/rtc.lua @@ -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 diff --git a/src/SCRIPTS/BF/ui.lua b/src/SCRIPTS/BF/ui.lua index 23f5bb9..fee070e 100644 --- a/src/SCRIPTS/BF/ui.lua +++ b/src/SCRIPTS/BF/ui.lua @@ -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 @@ -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 diff --git a/src/SCRIPTS/BF/vtx_tables.lua b/src/SCRIPTS/BF/vtx_tables.lua index 2efa894..d7edbba 100644 --- a/src/SCRIPTS/BF/vtx_tables.lua +++ b/src/SCRIPTS/BF/vtx_tables.lua @@ -11,15 +11,26 @@ local requestedBand = 1 local requestedPowerLevel = 1 local vtxTableConfig = {} local frequencyTable = {} -local frequenciesPerBand = 0 local bandTable = {} 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 + -- Vtx not available. Create empty vtx table to skip future download attempts + frequencyTable[1] = {} + vtxTableConfig.channels = 0 + bandTable = { [0] = "U", "1" } + powerTable = { "LV0" } + vtxConfigReceived = true + vtxTableAvailable = true + vtxFrequencyTableReceived = true + vtxPowerTableReceived = true + return + end vtxConfigReceived = true vtxTableAvailable = payload[12] ~= 0 vtxTableConfig.bands = payload[13]