# VESC communication for Rust
A `no-std`/`no-alloc` Rust implementation of the VESC®[^1] firmware
communication protocol, making it ideal for embedded systems, robotics, and any
application that needs to communicate with VESC motor controllers.
## Supported commands
> [!NOTE]
>
> If you find a missing command, feel free to contribute! Adding a new command
> should be relatively easy. Just follow the well-established pattern (see
> commits [`b0287c7`] and [`1049f10`] for reference).
>
> [`b0287c7`]: https://github.com/ikalnytskyi/vesc-rs/commit/b0287c7
> [`1049f10`]: https://github.com/ikalnytskyi/vesc-rs/commit/1049f10
| `0` | `FwVersion` | ✅ |
| `4` | `GetValues` | ✅ |
| `5` | `SetDuty` | ✅ |
| `6` | `SetCurrent` | ✅ |
| `7` | `SetCurrentBrake` | ✅ |
| `8` | `SetRpm` | ✅ |
| `9` | `SetPos` | ✅ |
| `10` | `SetHandbrake` | ✅ |
| `29` | `Reboot` | ✅ |
| `30` | `Alive` | ✅ |
| `34` | `ForwardCan` | ✅ |
| `50` | `GetValuesSelective` | ✅ |
| `110` | `SetOdometer` | ✅ |
| `128` | `GetStats` | ✅ |
| `129` | `ResetStats` | ✅ |
| `156` | `Shutdown` | ✅ |
| `157` | `FwInfo` | ✅ |
| `159` | `MotorEstop` | ✅ |
## Supported command replies
> [!NOTE]
>
> Many commands have no replies, so this list need not mirror the supported
> commands.
| `0` | `FwVersion` | ✅ |
| `4` | `GetValues` | ✅ |
| `50` | `GetValuesSelective` | ✅ |
| `128` | `GetStats` | ✅ |
| `129` | `ResetStats` | ✅ |
| `157` | `FwInfo` | ✅ |
## Installation
Add this to your Cargo.toml:
```rust
[dependencies]
vesc = "0.4"
```
## Usage
```rust
let mut buf = [0u8; 16];
let size = vesc::encode(Command::SetRpm(5000), &mut buf).unwrap();
tx.write_all(&buf[..size]).unwrap();
```
```rust
let mut decoder = Decoder::default();
let mut buf = [0u8; 512];
loop {
let size = rx.read(&mut buf).unwrap()
decoder.feed(&buf[..size]).unwrap();
for reply in self.decoder.by_ref() {
// process `reply`
}
}
```
## License
This project is licensed under the [MIT license](LICENSE).