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
No related branches found
No related tags found
No related merge requests found
......@@ -150,3 +150,23 @@ bool RadioPayload::start()
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:
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
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment