ev3-dc 0.1.0

Low level EV3 direct command library
Documentation
  • Coverage
  • 82.5%
    66 out of 80 items documented7 out of 37 items with examples
  • Size
  • Source code size: 38.6 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.75 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • stamp-cmd/EV3-DC
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • stamp-cmd

EV3-DC

[WIP] Low-level EV3 direct command library. Designed to be able to use safely

Features

  • Allocate global and local memory
  • Packet generation from bytecodes
  • Direct reply basic parser
  • Utility library for Run-Length-Encoding, packets merging, bytecode builder More documentation is available in docs
cargo doc

Bytecode documentation

LEGO Mindstorms EV3 Firmware Developer Kit [Link]

Example

This example turn on motor on port A & B with 50% power clockwise

use ev3_dc::{ Command, encode, Encoding, PORT };
use ev3_dc::utils::ChainByte;
use ev3_dc::parser::Reply;

// Create new packet. Packet can contains many OpCodes
let mut cmd = Command::new();
// Chainable vector operations
let mut byte = ChainByte::new();
byte.push(0xA4) // opOutput_Power
    .add(encode(LC0(0)).unwrap()) // Layer
    .add(encode(LC0(PORT.A + PORT.B)).unwrap()) // Port
    .add(encode(LC1(50)).unwrap()) // Power
    .push(0xA6) // opOutput_Power
    .add(encode(LC0(0)).unwrap()) // Layer
    .add(encode(LC0(PORT.A + PORT.B)).unwrap()); // Port
let mut buf = [0_u8; 5 + cmd.reserved_bytes()]; // Create reply buffer (SIZE SHOULD BE ATLEAST 5 + reserved_bytes)
println!("SENT: {:?}", cmd.gen_bytes()); // Generate direct command packet
not_real_function::read(&mut buf);
let rep = Reply::parse(&buf); // Parse direct reply
println!("RECV: {:?} | SIZE: {}, ID: {}, ERROR: {}, MEMORY: {}", buf, rep.length(), rep.id(), rep.error(), rep.memory());

Binary

All the example program is written for USB communication. Add hidapi to cargo

cargo add hidapi
  • examples/image.rs Display 178x128 PBM image on EV3 screen
    cargo run --example image example.pbm
    
  • examples/info.rs Show information about PBrick (w/ code comments)
    cargo run --example info