Skip to content

Commit 59086c9

Browse files
committed
Ghost MSP support
1 parent f6f3e89 commit 59086c9

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

src/SCRIPTS/BF/MSP/ghost.lua

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- GHOST Frame Types
2+
local GHST_FRAMETYPE_MSP_REQ = 0x21
3+
local GHST_FRAMETYPE_MSP_WRITE = 0x22
4+
local GHST_FRAMETYPE_MSP_RESP = 0x28
5+
6+
ghstMspType = 0
7+
8+
protocol.mspSend = function(payload)
9+
local payloadOut = { #(payload) }
10+
for i=1, #(payload) do
11+
payloadOut[i+1] = payload[i]
12+
end
13+
return protocol.push(ghstMspType, payloadOut)
14+
end
15+
16+
protocol.mspRead = function(cmd)
17+
ghstMspType = GHST_FRAMETYPE_MSP_REQ
18+
return mspSendRequest(cmd, {})
19+
end
20+
21+
protocol.mspWrite = function(cmd, payload)
22+
ghstMspType = GHST_FRAMETYPE_MSP_WRITE
23+
return mspSendRequest(cmd, payload)
24+
end
25+
26+
protocol.mspPoll = function()
27+
local type, data = ghostTelemetryPop()
28+
if type == GHST_FRAMETYPE_MSP_RESP then
29+
local mspData = {}
30+
for i=2, data[1] do
31+
mspData[i-1] = data[i]
32+
end
33+
return mspReceivedReply(mspData)
34+
end
35+
return nil
36+
end

src/SCRIPTS/BF/protocols.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ local supportedProtocols =
2020
saveMaxRetries = 2,
2121
saveTimeout = 150,
2222
cms = {},
23+
},
24+
ghost =
25+
{
26+
mspTransport = "MSP/ghost.lua",
27+
push = ghostTelemetryPush,
28+
maxTxBufferSize = 9, -- Tx -> Rx (Push)
29+
maxRxBufferSize = 5, -- Rx -> Tx (Pop)
30+
saveMaxRetries = 2,
31+
saveTimeout = 150,
32+
cms = {},
2333
}
2434
}
2535

@@ -28,6 +38,8 @@ local function getProtocol()
2838
return supportedProtocols.smartPort
2939
elseif supportedProtocols.crsf.push() ~= nil then
3040
return supportedProtocols.crsf
41+
elseif supportedProtocols.ghost.push() ~= nil then
42+
return supportedProtocols.ghost
3143
end
3244
end
3345

0 commit comments

Comments
 (0)