Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4a7ec40

Browse files
Use MSP_BUILD_INFO if >= MSP 1.47
1 parent 1067f8b commit 4a7ec40

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

‎src/SCRIPTS/BF/features.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
local features = {
2-
vtx = true,
3-
gps = true,
4-
osdSD = true,
2+
vtx = true,
3+
gps = true,
4+
osdSD = true,
5+
blackbox = true,
56
}
67

78
return features

‎src/SCRIPTS/BF/features_info.lua

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local MSP_GPS_CONFIG = 135
22
local MSP_VTX_CONFIG = 88
33
local MSP_OSD_CONFIG = 84
4+
45
local MSP_BUILD_INFO = 5
56

67
local BUILD_OPTION_GPS = 16412
@@ -21,20 +22,33 @@ local returnTable = {
2122
}
2223

2324
local function processBuildInfoReply(payload)
24-
-- TODO: parse build options
25+
features.gps = false
26+
features.vtx = false
27+
features.osdSD = false
28+
for i=1,#payload,2 do
29+
local byte1 = payload[i]
30+
local byte2 = payload[i + 1]
31+
local word = bit32.bor(bit32.arshift(byte1, -8), byte2)
32+
if word == BUILD_OPTION_GPS then
33+
features.gps = true
34+
elseif word == BUILD_OPTION_OSD_SD then
35+
features.osdSD = true
36+
elseif word == BUILD_OPTION_VTX then
37+
features.vtx = true
38+
end
39+
end
2540
end
2641

2742
local function processMspReply(cmd, payload, err)
2843
isInFlight = false
2944
local isOkay = not err
3045
if cmd == MSP_BUILD_INFO then
31-
if not isOkay then
32-
return
33-
end
3446
isGpsRead = true
3547
isVtxRead = true
3648
isOsdSDRead = true
37-
processBuildInfoReply(payload)
49+
if isOkay then
50+
processBuildInfoReply(payload)
51+
end
3852
elseif cmd == MSP_GPS_CONFIG then
3953
isGpsRead = true
4054
local providerSet = payload[1] ~= 0

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /