From bc557ccdebaf6cccd7b4bc01bc3713627cff33fd Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 3 Oct 2024 16:06:17 +0200 Subject: [PATCH] Added crate for usb-serial protocol --- Cargo.lock | 34 ++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + protocol/Cargo.toml | 10 ++++++++++ protocol/src/lib.rs | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 protocol/Cargo.toml create mode 100644 protocol/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 67e6a78..b8099aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -173,6 +173,12 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytes" version = "1.6.1" @@ -482,12 +488,32 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +[[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + [[package]] name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "hash32", + "serde", + "stable_deref_trait", +] + [[package]] name = "heck" version = "0.4.1" @@ -994,6 +1020,14 @@ dependencies = [ "xca9548a", ] +[[package]] +name = "radomctl-protocol" +version = "0.1.0" +dependencies = [ + "heapless", + "serde", +] + [[package]] name = "radomctld" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index fe5402c..ed7d23d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ resolver = "2" members = [ "daemon", "firmware", + "protocol", ] diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml new file mode 100644 index 0000000..201707b --- /dev/null +++ b/protocol/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "radomctl-protocol" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde = {version = "1.0.193", default-features = false, features = ["derive"]} +heapless = {version = "0.8.0", features = ["serde"]} \ No newline at end of file diff --git a/protocol/src/lib.rs b/protocol/src/lib.rs new file mode 100644 index 0000000..4793873 --- /dev/null +++ b/protocol/src/lib.rs @@ -0,0 +1,37 @@ +#![no_std] +use heapless::Vec; + +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Debug, PartialEq)] +pub enum RadomMessage { + Status(StatusMessage), +} + +#[derive(Serialize, Deserialize, Debug, PartialEq)] +pub enum HostMessage { + RequestStatus, + TriggerDFUBootloader, +} + +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct StatusMessage { + position: Position, + alarms: Vec, +} + +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Position { + az: f32, + el: f32, + az_endcoder: f32, + el_encoder: f32, + az_magnetic: f32, + el_magnetic: f32, +} + +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub enum Alarm { + AZEncoderFault, + ELEncoderFault, +}