📦 LAR linux can support rewrited in 🦀 Rust
🚧 Work In Progress 🚧
DIN
DOUT
- ⚙️
GP
Stirrer
Stepper
Pin
Uart
-
iface
: socket can interface name default valuevcan0
-
⚙️
server
⚙️ run driver in a work dir All of the arguments and flags to this command are optional:address
: ip address default to127.0.0.1
port
: port default to6677
-
🔧
virtual
🔩 Configure and start virtual can interfacebaurtate
: default to500000
-
-
Install
cargo
:Edinburgh is installed through Cargo, a Rust package manager. Rustup, a tool for installing Rust, will also install Cargo. On Linux and macOS systems,
rustup
can be installed as follows:curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly
rustup toolchain install nightly
rustup default nightly
cargo build
-
PanelPC
Additional installation methods are available here. Be sure to switch back to
stable
withrustup default stable
if that's your preferred toolchain.To cross-compile for the PanelPC you will need an
i686-unknown-linux-gnu
GCC toolchain and Rust component installed. Add the Rust target withrustup target add i686-unknown-linux-gnu
. Then you can cross-compile withcargo
:cargo build --release --target i686-unknown-linux-gnu
binary file:
target/i686-unknown-linux-gnu/release/lscan
Integrating the test into a CI system is non-trivial as it relies on a `vcan0` virtual can device existing.
Adding one to most linux systems is pretty easy with root access but attaching a vcan device to a container for CI seems difficult to find support for
To run the tests locally, though, setup should be simple:
**Virtual device:**
* Linux modul activate:
```zsh
sudo modprobe vcan
```
* Link vcan device:
```zsh
sudo ip link add vcan0 type vcan
```
* Activate interface:
```zsh
sudo ip link set vcan0 up
```
PCan usb device `Peak`
* Linux modul activate:
```bash
modprobe peak_usb
```
* Link vcan device:
```zsh
sudo ip link set can0 up type can bitrate 500000
```
* Activate interface:
```zsh
cargo test
```
It is best to start with a brand new Raspbian image. Download the latest [raspbian](https://www.raspberrypi.org/downloads/raspbian/)
After first time boot up, do an update and upgrade first.
```zsh
sudo apt-get update
```
```zsh
sudo apt-get upgrade
```
```zsh
sudo reboot
```
* Add the overlays by:
```
sudo nano /boot/config.txt
```
* Add these 3 lines to the end of file:
```
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
```
For PiCAN2 Duo add these 4 lines to the end of file:
```
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
```
* Reboot Pi: `sudo reboot`
protocol:jsonrpc
Auf GitHub
cargo add jsonrpc-core
cargo add jsonrpc-delive
Testing: Read analog1 in01
curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "analog_get_in01", "id":123 }' 127.0.0.1:3030