From 89a41124f33fed0930c59190ea0c0dc09cecdb77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Caruso?= <niccolo.caruso@skywarder.eu> Date: Wed, 2 Oct 2024 15:17:13 +0200 Subject: [PATCH] [GS] Dipswitch now with TX enable switches TX enable switches to enable the TX to Main or Payload --- .../Groundstation/LyraGS/Radio/Radio.cpp | 22 ++++++++++++++++- src/boards/Groundstation/LyraGS/Radio/Radio.h | 24 +++++++++++++++++++ .../Groundstation/lyra-gs-entry.cpp | 12 ++++++---- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/boards/Groundstation/LyraGS/Radio/Radio.cpp b/src/boards/Groundstation/LyraGS/Radio/Radio.cpp index 85b4afcaa..b52bb1241 100644 --- a/src/boards/Groundstation/LyraGS/Radio/Radio.cpp +++ b/src/boards/Groundstation/LyraGS/Radio/Radio.cpp @@ -149,4 +149,24 @@ bool RadioPayload::start() } return true; -} \ No newline at end of file +} + +bool RadioMain::sendMsg(const mavlink_message_t& msg) +{ + if (txEnable) + return RadioBase::sendMsg(msg); + return false; +}; + +/** + * @brief Send a mavlink message through this radio if it has been enabled + * by dipSwitch + * + * @returns false when the queue is full. + */ +bool RadioPayload::sendMsg(const mavlink_message_t& msg) +{ + if (txEnable) + return RadioBase::sendMsg(msg); + return false; +}; \ No newline at end of file diff --git a/src/boards/Groundstation/LyraGS/Radio/Radio.h b/src/boards/Groundstation/LyraGS/Radio/Radio.h index b176e2758..48d6d3009 100644 --- a/src/boards/Groundstation/LyraGS/Radio/Radio.h +++ b/src/boards/Groundstation/LyraGS/Radio/Radio.h @@ -47,8 +47,20 @@ public: RadioMain() : hasBackup{false} {}; + RadioMain(bool hasBackup, bool txEnable) + : hasBackup{hasBackup}, txEnable{txEnable} {}; + + /** + * @brief Send a mavlink message through this radio if it has been enabled + * by dipSwitch for transmission + * + * @returns false when the queue is full or if tx is not enabled. + */ + bool sendMsg(const mavlink_message_t& msg); + private: bool hasBackup = false; + bool txEnable = true; }; class RadioPayload : public Boardcore::InjectableWithDeps< Boardcore::InjectableBase<Groundstation::RadioBase>, @@ -61,8 +73,20 @@ public: RadioPayload() : hasBackup{false} {}; + RadioPayload(bool hasBackup, bool txEnable) + : hasBackup{hasBackup}, txEnable{txEnable} {}; + + /** + * @brief Send a mavlink message through this radio if it has been enabled + * by dipSwitch for transmission + * + * @returns false when the queue is full or if tx is not enabled. + */ + bool sendMsg(const mavlink_message_t& msg); + private: bool hasBackup = false; + bool txEnable = true; }; } // namespace LyraGS \ No newline at end of file diff --git a/src/entrypoints/Groundstation/lyra-gs-entry.cpp b/src/entrypoints/Groundstation/lyra-gs-entry.cpp index dd93dc87b..bce0c2943 100644 --- a/src/entrypoints/Groundstation/lyra-gs-entry.cpp +++ b/src/entrypoints/Groundstation/lyra-gs-entry.cpp @@ -56,6 +56,8 @@ struct DipStatusLyraGS bool isARP; bool mainHasBackup; bool payloadHasBackup; + bool mainTXenable; + bool payloadTXenable; uint8_t ipConfig; }; @@ -65,7 +67,9 @@ DipStatusLyraGS getDipStatus(uint8_t read) dipRead.isARP = 1 & read; dipRead.mainHasBackup = 1 & (read >> 1); dipRead.payloadHasBackup = 1 & (read >> 2); - dipRead.ipConfig = 0 | (read >> 3); + dipRead.mainTXenable = 1 & (read >> 3); + dipRead.payloadTXenable = 1 & (read >> 4); + dipRead.ipConfig = 0 | (read >> 5); return dipRead; } @@ -136,12 +140,12 @@ int main() Buses *buses = new Buses(); Serial *serial = new Serial(); LyraGS::RadioMain *radio_main = - new LyraGS::RadioMain(dipRead.mainHasBackup); + new LyraGS::RadioMain(dipRead.mainHasBackup, dipRead.mainTXenable); LyraGS::BoardStatus *board_status = new LyraGS::BoardStatus(dipRead.isARP); LyraGS::EthernetGS *ethernet = new LyraGS::EthernetGS(false, dipRead.ipConfig); - LyraGS::RadioPayload *radio_payload = - new LyraGS::RadioPayload(dipRead.payloadHasBackup); + LyraGS::RadioPayload *radio_payload = new LyraGS::RadioPayload( + dipRead.payloadHasBackup, dipRead.payloadTXenable); HubBase *hub = nullptr; -- GitLab