diff --git a/src/boards/Groundstation/LyraGS/Radio/Radio.cpp b/src/boards/Groundstation/LyraGS/Radio/Radio.cpp index 85b4afcaab6c2d2641b37cc5c462deba3f77ab62..b52bb12410232be1f63dc52c14c2374ecd5e1b54 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 b176e2758a751f70be2f79a24f200ac2d2df2cd7..48d6d3009c6d9a5ca16579d88b811ea4bbfbc796 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 dd93dc87bd048cd26471d5691f26b5e7ff5d910a..bce0c2943bcbd270f111983b2ce6b7ff7002afb8 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;