Expand description
The VESC® firmware is an open source motor controller firmware, and this
library implements the necessary structures and functions to encode
commands and decode replies.
§Examples
§Encoding a Command
use vesc::{Command, ValuesMask};
let mut buf = [0u8; 64];
let command = Command::GetValuesSelective(ValuesMask::RPM | ValuesMask::VOLTAGE_IN);
let frame_len = vesc::encode(command, &mut buf).unwrap();
let frame = &buf[..frame_len];§Decoding a Reply
use vesc::CommandReply;
match vesc::decode(&[2, 7, 50, 0, 0, 1, 128, 0, 0, 4, 210, 1, 176, 254, 22, 3]) {
Ok((_, CommandReply::GetValuesSelective(values))) => {
let rpm = values.rpm;
let voltage_in = values.voltage_in;
}
_ => (),
}Structs§
- Decoder
- A streaming decoder for VESC communication protocol.
- Values
- Telemetry data returned by the motor controller.
- Values
Mask - A bitmask used with
Command::GetValuesSelectiveto request specific telemetry fields. This allows for efficient communication by requesting only the data you need, reducing bandwidth and processing overhead. Each flag corresponds to a field in theValuesstruct.
Enums§
- Command
- Commands that can be sent to a VESC controller.
- Command
Reply - Reply messages received from the VESC in response to commands.
- Error
- Errors that can occur during command encoding or decoding.
Functions§
- decode
- Decodes a
CommandReplyfrom a byte buffer. - encode
- Encodes a
Commandinto a byte buffer.