Added crate for usb-serial protocol

This commit is contained in:
Sebastian 2024-10-03 16:06:17 +02:00
parent b4b07b505c
commit 78db26addc
4 changed files with 82 additions and 0 deletions

34
Cargo.lock generated
View file

@ -173,6 +173,12 @@ version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]] [[package]]
name = "bytes" name = "bytes"
version = "1.6.1" version = "1.6.1"
@ -482,12 +488,32 @@ version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
[[package]]
name = "hash32"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606"
dependencies = [
"byteorder",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.14.5" version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" 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]] [[package]]
name = "heck" name = "heck"
version = "0.4.1" version = "0.4.1"
@ -994,6 +1020,14 @@ dependencies = [
"xca9548a", "xca9548a",
] ]
[[package]]
name = "radomctl-protocol"
version = "0.1.0"
dependencies = [
"heapless",
"serde",
]
[[package]] [[package]]
name = "radomctld" name = "radomctld"
version = "0.1.0" version = "0.1.0"

View file

@ -4,6 +4,7 @@ resolver = "2"
members = [ members = [
"daemon", "daemon",
"firmware", "firmware",
"protocol",
] ]

10
protocol/Cargo.toml Normal file
View file

@ -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"]}

37
protocol/src/lib.rs Normal file
View file

@ -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<Alarm, 64>,
}
#[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,
}