kcan 0.1.8

CAN controller primitives for actuator and motor control.
Documentation
use kcan::protocol::{
    DirectCommand, MitCommand, MitHelperCommand, MotorModel, direct_command_frame,
    mit_command_frame, mit_helper_frame,
};

fn main() -> Result<(), kcan::Error> {
    println!("Supported CubeMars AK models:");
    for model in MotorModel::all() {
        let mit = mit_command_frame(*model, 0x03, MitCommand::neutral())?;
        let helper = mit_helper_frame(*model, 0x03, MitHelperCommand::Enable)?;
        let spec = model.spec();
        let layout = if model.uses_extended_mit_layout() {
            "extended"
        } else {
            "standard"
        };

        println!(
            "{:<9} layout={:<8} mit_id={:?} helper_id={:?} gear={} max_erpm={}",
            model.name(),
            layout,
            mit.id(),
            helper.id(),
            spec.gear_ratio,
            spec.max_velocity_erpm,
        );
    }

    let direct = direct_command_frame(0x03, DirectCommand::Velocity(1_000))?;
    println!(
        "Direct servo velocity frame example: id={:?} data={:02X?}",
        direct.id(),
        direct.data()
    );

    Ok(())
}