From 9523c75ff4897c98c6fe4f921555d85d83cd0849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Daleck=C3=BD?= Date: Wed, 29 Dec 2021 16:04:02 +0100 Subject: [PATCH] Ghost MSP support --- src/SCRIPTS/BF/MSP/ghst.lua | 28 ++++++++++++++++++++++++++++ src/SCRIPTS/BF/protocols.lua | 12 ++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/SCRIPTS/BF/MSP/ghst.lua diff --git a/src/SCRIPTS/BF/MSP/ghst.lua b/src/SCRIPTS/BF/MSP/ghst.lua new file mode 100644 index 0000000..397b3e1 --- /dev/null +++ b/src/SCRIPTS/BF/MSP/ghst.lua @@ -0,0 +1,28 @@ +-- GHST Frame Types +local GHST_FRAMETYPE_MSP_REQ = 0x21 +local GHST_FRAMETYPE_MSP_WRITE = 0x22 +local GHST_FRAMETYPE_MSP_RESP = 0x28 + +local ghstMspType = 0 + +protocol.mspSend = function(payload) + return protocol.push(ghstMspType, payload) +end + +protocol.mspRead = function(cmd) + ghstMspType = GHST_FRAMETYPE_MSP_REQ + return mspSendRequest(cmd, {}) +end + +protocol.mspWrite = function(cmd, payload) + ghstMspType = GHST_FRAMETYPE_MSP_WRITE + return mspSendRequest(cmd, payload) +end + +protocol.mspPoll = function() + local type, data = ghostTelemetryPop() + if type == GHST_FRAMETYPE_MSP_RESP then + return mspReceivedReply(data) + end + return nil +end diff --git a/src/SCRIPTS/BF/protocols.lua b/src/SCRIPTS/BF/protocols.lua index c415104..8034821 100644 --- a/src/SCRIPTS/BF/protocols.lua +++ b/src/SCRIPTS/BF/protocols.lua @@ -20,6 +20,16 @@ local supportedProtocols = saveMaxRetries = 2, saveTimeout = 150, cms = {}, + }, + ghst = + { + mspTransport = "MSP/ghst.lua", + push = ghostTelemetryPush, + maxTxBufferSize = 10, -- Tx -> Rx (Push) + maxRxBufferSize = 6, -- Rx -> Tx (Pop) + saveMaxRetries = 2, + saveTimeout = 250, + cms = {}, } } @@ -28,6 +38,8 @@ local function getProtocol() return supportedProtocols.smartPort elseif supportedProtocols.crsf.push() ~= nil then return supportedProtocols.crsf + elseif supportedProtocols.ghst.push() ~= nil then + return supportedProtocols.ghst end end