Skip to content
Snippets Groups Projects
Commit 89a41124 authored by Nicolò Caruso's avatar Nicolò Caruso Committed by Emilio Corigliano
Browse files

[GS] Dipswitch now with TX enable switches

TX enable switches to enable the TX to Main or Payload
parent 9eaa0a9d
Branches
No related tags found
No related merge requests found
...@@ -150,3 +150,23 @@ bool RadioPayload::start() ...@@ -150,3 +150,23 @@ bool RadioPayload::start()
return true; return true;
} }
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
...@@ -47,8 +47,20 @@ public: ...@@ -47,8 +47,20 @@ public:
RadioMain() : hasBackup{false} {}; 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: private:
bool hasBackup = false; bool hasBackup = false;
bool txEnable = true;
}; };
class RadioPayload : public Boardcore::InjectableWithDeps< class RadioPayload : public Boardcore::InjectableWithDeps<
Boardcore::InjectableBase<Groundstation::RadioBase>, Boardcore::InjectableBase<Groundstation::RadioBase>,
...@@ -61,8 +73,20 @@ public: ...@@ -61,8 +73,20 @@ public:
RadioPayload() : hasBackup{false} {}; 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: private:
bool hasBackup = false; bool hasBackup = false;
bool txEnable = true;
}; };
} // namespace LyraGS } // namespace LyraGS
\ No newline at end of file
...@@ -56,6 +56,8 @@ struct DipStatusLyraGS ...@@ -56,6 +56,8 @@ struct DipStatusLyraGS
bool isARP; bool isARP;
bool mainHasBackup; bool mainHasBackup;
bool payloadHasBackup; bool payloadHasBackup;
bool mainTXenable;
bool payloadTXenable;
uint8_t ipConfig; uint8_t ipConfig;
}; };
...@@ -65,7 +67,9 @@ DipStatusLyraGS getDipStatus(uint8_t read) ...@@ -65,7 +67,9 @@ DipStatusLyraGS getDipStatus(uint8_t read)
dipRead.isARP = 1 & read; dipRead.isARP = 1 & read;
dipRead.mainHasBackup = 1 & (read >> 1); dipRead.mainHasBackup = 1 & (read >> 1);
dipRead.payloadHasBackup = 1 & (read >> 2); 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; return dipRead;
} }
...@@ -136,12 +140,12 @@ int main() ...@@ -136,12 +140,12 @@ int main()
Buses *buses = new Buses(); Buses *buses = new Buses();
Serial *serial = new Serial(); Serial *serial = new Serial();
LyraGS::RadioMain *radio_main = 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::BoardStatus *board_status = new LyraGS::BoardStatus(dipRead.isARP);
LyraGS::EthernetGS *ethernet = LyraGS::EthernetGS *ethernet =
new LyraGS::EthernetGS(false, dipRead.ipConfig); new LyraGS::EthernetGS(false, dipRead.ipConfig);
LyraGS::RadioPayload *radio_payload = LyraGS::RadioPayload *radio_payload = new LyraGS::RadioPayload(
new LyraGS::RadioPayload(dipRead.payloadHasBackup); dipRead.payloadHasBackup, dipRead.payloadTXenable);
HubBase *hub = nullptr; HubBase *hub = nullptr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment