diff --git a/boards/beacon/src/types.rs b/boards/beacon/src/types.rs index d2fccd10..1274347f 100644 --- a/boards/beacon/src/types.rs +++ b/boards/beacon/src/types.rs @@ -1,7 +1,7 @@ -use messages::sender::Sender; -use messages::sender::Sender::BeaconBoard; +use messages::node::Node; +use messages::node::Node::BeaconBoard; // ------- -// Sender ID +// Node ID // ------- -pub static COM_ID: Sender = BeaconBoard; \ No newline at end of file +pub static COM_ID: Node = BeaconBoard; \ No newline at end of file diff --git a/boards/camera/src/communication.rs b/boards/camera/src/communication.rs index cb30c676..1a54fdae 100644 --- a/boards/camera/src/communication.rs +++ b/boards/camera/src/communication.rs @@ -103,7 +103,7 @@ impl CanDevice0 { can.filters_standard() .push(Filter::Classic { action: Action::StoreFifo0, - filter: ecan::StandardId::new(messages::sender::Sender::SensorBoard.into()) + filter: ecan::StandardId::new(messages::node::Node::SensorBoard.into()) .unwrap(), mask: ecan::StandardId::ZERO, }) diff --git a/boards/camera/src/types.rs b/boards/camera/src/types.rs index 352f57f0..cea33bb0 100644 --- a/boards/camera/src/types.rs +++ b/boards/camera/src/types.rs @@ -1,5 +1,5 @@ -use messages::sender::{Sender, Sender::CameraBoard}; +use messages::node::{Node, Node::CameraBoard}; // ------- -// Sender ID +// Node ID // ------- -pub static _COM_ID: Sender = CameraBoard; +pub static _COM_ID: Node = CameraBoard; diff --git a/boards/communication/src/communication.rs b/boards/communication/src/communication.rs index 1ea183af..6af79cb4 100644 --- a/boards/communication/src/communication.rs +++ b/boards/communication/src/communication.rs @@ -120,7 +120,7 @@ impl CanDevice0 { can.filters_standard() .push(Filter::Classic { action: Action::StoreFifo0, - filter: ecan::StandardId::new(messages::sender::Sender::RecoveryBoard.into()) + filter: ecan::StandardId::new(messages::node::Node::RecoveryBoard.into()) .unwrap(), mask: ecan::StandardId::ZERO, }) @@ -129,7 +129,7 @@ impl CanDevice0 { can.filters_standard() .push(Filter::Classic { action: Action::StoreFifo1, - filter: ecan::StandardId::new(messages::sender::Sender::SensorBoard.into()) + filter: ecan::StandardId::new(messages::node::Node::SensorBoard.into()) .unwrap(), mask: ecan::StandardId::ZERO, }) @@ -138,7 +138,7 @@ impl CanDevice0 { can.filters_standard() .push(Filter::Classic { action: Action::StoreFifo0, - filter: ecan::StandardId::new(messages::sender::Sender::PowerBoard.into()).unwrap(), + filter: ecan::StandardId::new(messages::node::Node::PowerBoard.into()).unwrap(), mask: ecan::StandardId::ZERO, }) .unwrap_or_else(|_| panic!("Power filter")); @@ -146,7 +146,7 @@ impl CanDevice0 { can.filters_standard() .push(Filter::Classic { action: Action::StoreFifo0, - filter: ecan::StandardId::new(messages::sender::Sender::GroundStation.into()) + filter: ecan::StandardId::new(messages::node::Node::GroundStation.into()) .unwrap(), mask: ecan::StandardId::ZERO, }) diff --git a/boards/communication/src/types.rs b/boards/communication/src/types.rs index 236121d8..34315d1c 100644 --- a/boards/communication/src/types.rs +++ b/boards/communication/src/types.rs @@ -1,13 +1,13 @@ use atsamd_hal::gpio::*; use atsamd_hal::sercom::uart::EightBit; use atsamd_hal::sercom::{uart, IoSet1, Sercom5}; -use messages::sender::Sender; -use messages::sender::Sender::CommunicationBoard; +use messages::node::Node; +use messages::node::Node::CommunicationBoard; // ------- -// Sender ID +// Node ID // ------- -pub static COM_ID: Sender = CommunicationBoard; +pub static COM_ID: Node = CommunicationBoard; // ------- // Ground Station diff --git a/boards/power/src/communication.rs b/boards/power/src/communication.rs index 4d42abf2..59ca7b66 100644 --- a/boards/power/src/communication.rs +++ b/boards/power/src/communication.rs @@ -108,7 +108,7 @@ impl CanDevice0 { can.filters_standard() .push(Filter::Classic { action: Action::StoreFifo1, - filter: ecan::StandardId::new(messages::sender::Sender::CommunicationBoard.into()) + filter: ecan::StandardId::new(messages::node::Node::CommunicationBoard.into()) .unwrap(), mask: ecan::StandardId::ZERO, }) diff --git a/boards/power/src/types.rs b/boards/power/src/types.rs index 196af97b..f8bae4ef 100644 --- a/boards/power/src/types.rs +++ b/boards/power/src/types.rs @@ -1,5 +1,5 @@ -use messages::sender::{Sender, Sender::PowerBoard}; +use messages::node::{Node, Node::PowerBoard}; // ------- -// Sender ID +// Node ID // ------- -pub static _COM_ID: Sender = PowerBoard; +pub static _COM_ID: Node = PowerBoard; diff --git a/boards/recovery/src/communication.rs b/boards/recovery/src/communication.rs index 4d667b7b..c6e4d6e4 100644 --- a/boards/recovery/src/communication.rs +++ b/boards/recovery/src/communication.rs @@ -111,7 +111,7 @@ impl CanDevice0 { can.filters_standard() .push(Filter::Classic { action: Action::StoreFifo0, - filter: ecan::StandardId::new(messages::sender::Sender::SensorBoard.into()) + filter: ecan::StandardId::new(messages::node::Node::SensorBoard.into()) .unwrap(), mask: ecan::StandardId::ZERO, }) @@ -121,7 +121,7 @@ impl CanDevice0 { can.filters_standard() .push(Filter::Classic { action: Action::StoreFifo1, - filter: ecan::StandardId::new(messages::sender::Sender::CommunicationBoard.into()) + filter: ecan::StandardId::new(messages::node::Node::CommunicationBoard.into()) .unwrap(), mask: ecan::StandardId::ZERO, }) diff --git a/boards/recovery/src/state_machine/states/wait_for_recovery.rs b/boards/recovery/src/state_machine/states/wait_for_recovery.rs index cd404c88..52d4a3aa 100644 --- a/boards/recovery/src/state_machine/states/wait_for_recovery.rs +++ b/boards/recovery/src/state_machine/states/wait_for_recovery.rs @@ -5,7 +5,7 @@ use crate::state_machine::{RocketStates, State, StateMachineContext, TransitionI use crate::types::COM_ID; use defmt::{write, Format, Formatter}; use messages::command::{Command, PowerDown, RadioRate, RadioRateChange}; -use messages::sender::Sender::SensorBoard; +use messages::node::Node::SensorBoard; use messages::Message; use rtic::mutex::Mutex; diff --git a/boards/recovery/src/types.rs b/boards/recovery/src/types.rs index d7f5356d..6e6c29f3 100644 --- a/boards/recovery/src/types.rs +++ b/boards/recovery/src/types.rs @@ -1,7 +1,7 @@ -use messages::sender::Sender; -use messages::sender::Sender::RecoveryBoard; +use messages::node::Node; +use messages::node::Node::RecoveryBoard; // ------- -// Sender ID +// Node ID // ------- -pub static COM_ID: Sender = RecoveryBoard; +pub static COM_ID: Node = RecoveryBoard; diff --git a/boards/sensor/src/communication.rs b/boards/sensor/src/communication.rs index 2ef700ca..5eeda897 100644 --- a/boards/sensor/src/communication.rs +++ b/boards/sensor/src/communication.rs @@ -112,7 +112,7 @@ impl CanDevice0 { can.filters_standard() .push(Filter::Classic { action: Action::StoreFifo0, - filter: ecan::StandardId::new(messages::sender::Sender::CommunicationBoard.into()) + filter: ecan::StandardId::new(messages::node::Node::CommunicationBoard.into()) .unwrap(), mask: ecan::StandardId::ZERO, }) @@ -121,7 +121,7 @@ impl CanDevice0 { can.filters_standard() .push(Filter::Classic { action: Action::StoreFifo0, - filter: ecan::StandardId::new(messages::sender::Sender::RecoveryBoard.into()) + filter: ecan::StandardId::new(messages::node::Node::RecoveryBoard.into()) .unwrap(), mask: ecan::StandardId::ZERO, }) @@ -130,7 +130,7 @@ impl CanDevice0 { can.filters_standard() .push(Filter::Classic { action: Action::StoreFifo1, - filter: ecan::StandardId::new(messages::sender::Sender::GroundStation.into()) + filter: ecan::StandardId::new(messages::node::Node::GroundStation.into()) .unwrap(), mask: ecan::StandardId::ZERO, }) diff --git a/boards/sensor/src/types.rs b/boards/sensor/src/types.rs index fe0877ab..7c063a71 100644 --- a/boards/sensor/src/types.rs +++ b/boards/sensor/src/types.rs @@ -8,14 +8,14 @@ use hal::dmac::BufferPair; use hal::sercom::IoSet2; use hal::sercom::Sercom4; -use messages::sender::Sender; -use messages::sender::Sender::SensorBoard; +use messages::node::Node; +use messages::node::Node::SensorBoard; use sbg_rs::sbg::SBG_BUFFER_SIZE; // ------- -// Sender ID +// Node ID // ------- -pub static COM_ID: Sender = SensorBoard; +pub static COM_ID: Node = SensorBoard; // ------- // SBG diff --git a/libraries/messages/src/command.rs b/libraries/messages/src/command.rs index 6ad0b804..8e2f0b40 100644 --- a/libraries/messages/src/command.rs +++ b/libraries/messages/src/command.rs @@ -1,4 +1,4 @@ -use crate::sender::Sender; +use crate::node::Node; use derive_more::From; use messages_proc_macros_lib::common_derives; @@ -32,7 +32,7 @@ pub struct DeployMain { #[common_derives] #[derive(From)] pub struct PowerDown { - pub board: Sender, // This isn't proper naming !! This is the board to be powered down. Changes name of sender.rs to board.rs. + pub board: Node, } #[common_derives] diff --git a/libraries/messages/src/lib.rs b/libraries/messages/src/lib.rs index c89fb673..71e195b2 100644 --- a/libraries/messages/src/lib.rs +++ b/libraries/messages/src/lib.rs @@ -7,7 +7,7 @@ use crate::command::Command; use crate::health::Health; -use crate::sender::Sender; +use crate::node::Node; use crate::sensor::Sensor; use crate::state::State; use derive_more::From; @@ -19,7 +19,7 @@ use messages_proc_macros_lib::common_derives; pub mod command; pub mod health; mod logging; -pub mod sender; +pub mod node; pub mod sensor; pub mod sensor_status; pub mod state; @@ -37,7 +37,7 @@ pub struct Message { pub timestamp: u64, /// The original sender of this message. - pub sender: Sender, + pub sender: Node, /// The data contained in this message. pub data: Data, @@ -57,7 +57,7 @@ pub enum Data { impl Message { pub fn new( timestamp: &Instant, - sender: Sender, + sender: Node, data: impl Into, ) -> Self { Message { diff --git a/libraries/messages/src/node.rs b/libraries/messages/src/node.rs new file mode 100644 index 00000000..3eff0712 --- /dev/null +++ b/libraries/messages/src/node.rs @@ -0,0 +1,27 @@ +use messages_proc_macros_lib::common_derives; + +#[common_derives] +#[derive(Copy)] +pub enum Node { + GroundStation, + SensorBoard, + RecoveryBoard, + CommunicationBoard, + PowerBoard, + CameraBoard, + BeaconBoard, +} + +impl From for u16 { + fn from(node: Node) -> Self { + match node { + Node::GroundStation => 0, + Node::SensorBoard => 1, + Node::RecoveryBoard => 2, + Node::CommunicationBoard => 3, + Node::PowerBoard => 4, + Node::CameraBoard => 5, + Node::BeaconBoard => 6, + } + } +} diff --git a/libraries/messages/src/sender.rs b/libraries/messages/src/sender.rs deleted file mode 100644 index 2bc90999..00000000 --- a/libraries/messages/src/sender.rs +++ /dev/null @@ -1,28 +0,0 @@ -use messages_proc_macros_lib::common_derives; - -// I don't agree with the naming, We can use these as Ids to sent commands to that specific board. -#[common_derives] -#[derive(Copy)] -pub enum Sender { - GroundStation, - SensorBoard, - RecoveryBoard, - CommunicationBoard, - PowerBoard, - CameraBoard, - BeaconBoard, -} - -impl From for u16 { - fn from(sender: Sender) -> Self { - match sender { - Sender::GroundStation => 0, - Sender::SensorBoard => 1, - Sender::RecoveryBoard => 2, - Sender::CommunicationBoard => 3, - Sender::PowerBoard => 4, - Sender::CameraBoard => 5, - Sender::BeaconBoard => 6, - } - } -}