The relay service is designed to run on a raspberry pi in a Waterloop Hyperloop Pod. It's goal is to enable remote communication between the desktop controller and the Pod's subsystems. The relay service also enables remote flashing supported embedded devices.
Portions of the relay service rely on having access to the socketcan
crate which is only for linux. These portions of the code are only important for connecting to the canbus.
For the purposes of testing the connection with the desktop, you can run the relay crate on windows with cargo run
but it will not have any CAN functionality.
The canota-sys crate provides bindings to a C library which is used for ota flashing through the CAN bus.
The bindings are generated and stored in the repository. After they are generated, some manual work is needed
to clean up the generated bindings. This includes adding some markers for functions which indicate errors in the form of boolean values. Outside of the markers, the C library is provided as is with unsafe functions. For a safe wrapper api, see the canota
crate.s
cargo run
The goal of the canota crate is to provide a safe, application ready implementation of the canota-sys library.
Creating the bindings should be done on a linux device or through WSL2.
To create the bindings, first install the CLI tool bindgen
via cargo install bindgen
You may be prompted to install other packages which bindgen relies on if they are not already installed on your system.
Once bindgen is installed, run make generate-bindings-canota
to generate the bindings file.
- cargo run : Runs a binary crate. For the purpose of this repo, run this command from the root to run the relay service
cargo build
: Builds a binary or library crate without running it if it is a binary crate. Useful for checking if code will compilecargo test
: Builds and runs the tests for a cratecargo doc --open
: Generates docs for the crate that this is called in.cargo run -- -ci vcan0
: Attach the relay to the virtual CAN bus.
There are instructions for getting vcan up and running available here
Wrapping Unsafe C Libraries in Rust
Rust for Rustaceans by Jon GJENGSET
The Rust Book