bevy_serial
bevy_serial is a plugin to add non-blocking serial communication to bevy. This plugin is based on mio-serial that can realize non-blocking high-performance I/O.
Reading and writing from/to serial port is realized via bevy's event system. Each serial port is handled via port name or a unique label you choose. These event handlers are added to the following stage to minimize the frame delay.
- Reading:
PreUpdate - Writing:
PostUpdate
Usage
Simple Example
Here is a simple example:
use *;
use ;
// to write data to serial port periodically
;
const SERIAL_PORT: &str = "/dev/ttyUSB0";
// reading event for serial port
// writing event for serial port
Multiple Serial Ports with Additional Config
You can add multiple serial ports with additional config.
new
.add_plugins
// you can specify various configurations for multiple serial ports by this way
.add_plugins
// reading and writing from/to serial port is achieved via bevy's event system
.add_systems
.add_systems
.run;
Development
pre-commit hooks
Install pre-commit and hooks (pre-commit/pre-push) hooks if you need:
pre-commit install --hook-type pre-commit --hook-type pre-push
To uninstall:
pre-commit uninstall --hook-type pre-commit --hook-type pre-push
Supported Versions
| bevy | bevy_serial |
|---|---|
| 0.17 | 0.10 |
| 0.16 | 0.9 |
| 0.15 | 0.8 |
| 0.14 | 0.7 |
| 0.13 | 0.5, 0.6 |
| 0.12 | 0.4 |
| 0.11 | 0.3 |
| 0.6 | 0.2 |
| 0.5 | 0.1 |
License
Dual-licensed under either
- MIT
- Apache 2.0