diff --git a/Cargo.lock b/Cargo.lock index 126871b..c14201d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -465,17 +465,11 @@ dependencies = [ "powerfmt", ] -[[package]] -name = "embassy-futures" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f878075b9794c1e4ac788c95b728f26aa6366d32eeb10c7051389f898f7d067" - [[package]] name = "embassy-sync" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2c8cdff05a7a51ba0087489ea44b0b1d97a296ca6b1d6d1a33ea7423d34049" +checksum = "cef1a8a1ea892f9b656de0295532ac5d8067e9830d49ec75076291fd6066b136" dependencies = [ "cfg-if", "critical-section", @@ -827,7 +821,6 @@ version = "0.1.0" dependencies = [ "crc", "defmt", - "embassy-futures", "embassy-sync", "embedded-io-adapters", "embedded-io-async", diff --git a/mctp-estack/Cargo.toml b/mctp-estack/Cargo.toml index 2fa4f23..caabca8 100644 --- a/mctp-estack/Cargo.toml +++ b/mctp-estack/Cargo.toml @@ -16,8 +16,7 @@ log = { version = "0.4", optional = true } crc = "3" embedded-io-async = { workspace = true } defmt = { workspace = true, optional = true } -embassy-sync = "0.6" -embassy-futures = "0.1" +embassy-sync = "0.7" smbus-pec = { version = "1.0", features = ["lookup-table"] } uuid = { version = "1.16.0", default-features = false } diff --git a/mctp-estack/src/lib.rs b/mctp-estack/src/lib.rs index 6709dbe..f621613 100644 --- a/mctp-estack/src/lib.rs +++ b/mctp-estack/src/lib.rs @@ -3,14 +3,13 @@ * Copyright (c) 2024-2025 Code Construct */ -//! MCTP Stack +//! # MCTP Stack //! //! This crate provides a MCTP stack that can be embedded in other programs -//! or devices. A [`Stack`] handles MCTP message formatting and parsing, independent -//! of any particular MCTP transport binding. +//! or devices. //! //! A [`Router`] object lets programs use a [`Stack`] with -//! MCTP transport binding links. Each "port" handles transmitting and receiving +//! MCTP transport binding links. Each *Port* handles transmitting and receiving //! packets independently. Messages destined for the stack's own EID will //! be passed to applications. //! @@ -18,6 +17,9 @@ //! instances to communicate over MCTP. Those implement the standard [`mctp` crate](mctp) //! async traits. //! +//! The IO-less [`Stack`] handles MCTP message formatting and parsing, independent +//! of any particular MCTP transport binding. +//! //! ## Configuration //! //! `mctp-estack` uses fixed sizes to be suitable on no-alloc platforms. @@ -30,6 +32,8 @@ /// Re-exported so that callers can use the same `heapless` version. /// +/// `heapless::Vec` is currently an argument of `send_fill()` in transports. +/// /// TODO: will be replaced with something else, maybe `heapless::VecView` once /// released. pub use heapless::Vec; @@ -39,15 +43,16 @@ use heapless::FnvIndexMap; use mctp::{Eid, Error, MsgType, Result, Tag, TagValue}; pub mod control; -mod fragment; +pub mod fragment; pub mod i2c; mod reassemble; pub mod router; pub mod serial; pub mod usb; +#[macro_use] mod util; -pub use fragment::{Fragmenter, SendOutput}; +use fragment::{Fragmenter, SendOutput}; use reassemble::Reassembler; pub use router::Router; @@ -80,8 +85,6 @@ pub(crate) const HEADER_LEN: usize = 4; /// during the build. Those variables can be set in the `[env]` /// section of `.cargo/config.toml`. pub mod config { - use crate::get_build_var; - /// Maximum size of a MCTP message payload in bytes, default 1032 /// /// This does not include the MCTP type byte. @@ -142,6 +145,9 @@ type Header = libmctp::base_packet::MCTPTransportHeader<[u8; HEADER_LEN]>; #[derive(Debug)] pub struct ReceiveHandle(usize); +/// Low level MCTP stack. +/// +/// This is an IO-less MCTP stack, independent of any particular transport. #[derive(Debug)] pub struct Stack { own_eid: Eid, diff --git a/mctp-estack/src/util.rs b/mctp-estack/src/util.rs index 9d707b1..3b1fdb3 100644 --- a/mctp-estack/src/util.rs +++ b/mctp-estack/src/util.rs @@ -1,7 +1,6 @@ /// Takes a `usize` from a build-time environment variable. /// /// If unset, the default is used. Can be used in a const context. -#[macro_export] macro_rules! get_build_var { ($name:literal, $default:expr) => {{ match option_env!($name) { diff --git a/mctp/src/lib.rs b/mctp/src/lib.rs index defa638..90fb229 100644 --- a/mctp/src/lib.rs +++ b/mctp/src/lib.rs @@ -10,7 +10,7 @@ #![forbid(unsafe_code)] #![warn(missing_docs)] -//! Management Component Transport Protocol (MCTP) +//! # Management Component Transport Protocol (MCTP) //! //! This crate provides common types and traits for MCTP. //! Transport implementations can implement [`ReqChannel`] and [`Listener`] to diff --git a/standalone/src/serial.rs b/standalone/src/serial.rs index d0076d1..6256942 100644 --- a/standalone/src/serial.rs +++ b/standalone/src/serial.rs @@ -16,7 +16,8 @@ use smol::Timer; use mctp::{Eid, Error, MsgType, Result, Tag, TagValue}; use mctp_estack::{ - serial::MctpSerialHandler, MctpMessage, ReceiveHandle, SendOutput, Stack, + fragment::SendOutput, serial::MctpSerialHandler, MctpMessage, + ReceiveHandle, Stack, }; struct Inner {