Crate ev3_dc

Crate ev3_dc 

Source
Expand description

Low-level EV3 Direct command library. Library for direct command bytecode generation and basic direct reply parsing.

By itself, It can allocate memory, create bytecode packet, parsing reply and other utility functions. Only some ad-hoc functions are available in funcs. Other OpCode is documented at Firmware Developer Kit. This library cannot prevent value overflow for any specific OpCode, only the parameter and command itself.

More information about direct commands and bytecode is available at LEGO MINDSTORMS Firmware Developer Kit

§Example

§Show blinking green LED

use ev3_dc::{ Command, Encoding::*, encode };

let mut cmd = Command::new();
let mut byte = vec![0x84, 0x1B]; // OpUI_Write, LED
byte.extend(encode(LC0(0x04)).unwrap()); // Green flashing
cmd.bytecode = byte;
println!("SENT: {:02X?}", cmd.gen_bytes());
// and send actual bytes via HID, or Bluetooth, etc.

Modules§

funcs
Command generation function. Not all command will be here, only some of them.
parser
Module for parsing direct reply
utils
Utility functions for ev3-dc

Structs§

Command
The packets that get sent to EV3. Can contain more than 1 OpCode
Port
Port struct. Use defined PORT constant instead.

Enums§

DataType
EV3 DataType.
Encoding
Parameter encoding
ValError
ev3_dc Error type

Constants§

PID
USB ProductId of EV3
PORT
PORT Constants. Add them together to use multiple ports
VID
USB VendorId of EV3

Functions§

encode
Encode value to parameter encoding. For encoding constant value or encoding address to variable directly. Use Command::allocate to encode variable without specifying pointer directly