Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ categories = [
defmt = ["dep:defmt"]
std = ["bitflags/std", "thiserror/std"]

serde = ["dep:serde"]
postcard = ["dep:postcard-schema"]

[dependencies]
bitflags = { version = "2.9" }
crc = { version = "3.3" }
defmt = { version = "1.0", optional = true }
postcard-schema = { version = "0.2.5", optional = true, features = ["derive"] }
serde = { version = "1.0.228", default-features = false, optional = true, features = ["derive"] }
thiserror = { version = "2.0", default-features = false }

[dev-dependencies]
Expand Down
14 changes: 14 additions & 0 deletions src/command.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

#[cfg(feature = "postcard")]
use postcard_schema::Schema;

use bitflags::bitflags;
use core::ffi::CStr;

Expand Down Expand Up @@ -374,6 +380,8 @@ impl<'a> Command<'a> {
/// calling [`Command::GetValues`] or [`Command::GetValuesSelective`].
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "postcard", derive(Schema))]
#[repr(u8)]
pub enum FaultCode {
#[default]
Expand Down Expand Up @@ -618,6 +626,8 @@ impl FwInfo {
/// [`ValuesMask`] are populated; all others remain at their default.
#[derive(Debug, Copy, Clone, Default)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "postcard", derive(Schema))]
pub struct Values {
pub temp_mosfet: f32,
pub temp_motor: f32,
Expand Down Expand Up @@ -649,6 +659,8 @@ pub struct Values {
/// [`Command::GetValuesSetupSelective`].
#[derive(Debug, Copy, Clone, Default)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "postcard", derive(Schema))]
pub struct SetupValues {
pub temp_mosfet: f32,
pub temp_motor: f32,
Expand Down Expand Up @@ -677,6 +689,8 @@ pub struct SetupValues {
/// Runtime statistics returned by the motor controller.
#[derive(Debug, Copy, Clone, Default)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "postcard", derive(Schema))]
pub struct Stats {
pub speed_avg: f32,
pub speed_max: f32,
Expand Down
Loading