Skip to main content

Crate motor_codec

Crate motor_codec 

Source
Expand description

Vendor-agnostic motor codec contract.

This crate defines MotorCodec — the single trait the rest of the can-motor-control stack uses to talk to a vendor-specific motor protocol — together with the shared types every vendor agrees on (CanFrame, Command, Event, MotorTypeId, Limits, BusCapabilities).

The crate is no_std. Vendor codec implementations (e.g. the can-motor-damiao-codec package) live in their own crates; can-motor-control depends on this trait crate only and never on a specific vendor.

use motor_codec::{CanFrame, MotorCodec};
// Trait is object-safe: usable as `Box<dyn MotorCodec>`.
fn _accept_dyn(_c: alloc::boxed::Box<dyn MotorCodec>) {}

Structs§

BusCapabilities
Runtime feature set of a CAN transport.
CanFrame
Unified CAN frame: covers both classical CAN (8-byte payload) and CAN-FD (up to 64-byte payload).
FrameFlags
Metadata bits attached to every CanFrame.
Limits
Per-motor-type physical limits used to scale MIT commands and unscale state replies.
MotorRef
Borrowed view of a motor’s identity, suitable for passing into codec encode methods without taking ownership of the motor’s mutable state.

Enums§

CodecError
Errors returned by MotorCodec implementations.
Command
A control command directed at a single motor.
CommandKind
Tagged discriminant of Command, suitable for error-reporting “this codec does not support mode X”.
Event
A decoded inbound message from a motor.
FrameError
Errors that can arise constructing a CanFrame.
MotorTypeId
Vendor-tagged motor type identifier.
ParamValue
Union of value encodings used by vendor parameter sub-protocols.

Traits§

MotorCodec
The vendor-agnostic codec contract.