#command-line-tool #pi #plc #industrial #control #driver #file

bin+lib picontrol

A library to access the RevolutionPi industrial PLC. A console application similar to the piTest command line tool is provided as an example.

4 releases

0.2.1 Nov 7, 2019
0.2.0 Nov 3, 2019
0.1.1 Apr 9, 2019
0.1.0 Apr 9, 2019

#1132 in Hardware support

47 downloads per month

MIT license

105KB
2.5K SLoC

Rust 1.5K SLoC // 0.0% comments C 1K SLoC // 0.3% comments C++ 128 SLoC // 0.5% comments Shell 1 SLoC // 0.8% comments

picontrol-rs

Rust version of the PiControl driver for the Revolution Pi.

An example: pitestrs

A command line tool to control the Pi Control process image is in the file pitestrs.rs. The executable can be cross-compiled by launching ./build_pi.sh. See below how to enable cross compilation.

How to generate the Rust FFI bindings to C

  1. Use bindgen binary directly:

    TARGET=armv7-unknown-linux-gnueabihf bindgen -o src/picontrol.rs kunbus/interface/piControl/wrapper.h  -- -I`pwd`/kunbus/interface/piControl
    
  2. Use bindgen with a build.rs file

Rust cross-compilation

Cross project with Docker

See: https://github.com/rust-embedded/cross

Same operating system

See: https://medium.com/@wizofe/cross-compiling-rust-for-arm-e-g-raspberry-pi-using-any-os-11711ebfc52b

source $HOME/.cargo/env

sudo apt-get install -qq gcc-arm-linux-gnueabihf
rustup target add armv7-unknown-linux-gnueabihf

Configure Cargo for cross-compilation

mkdir -p ~/.cargo
# > should not be included when pasting
cat >> ~/.cargo/config << EOF
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
EOF

# you may need to install this on Ubuntu 18.06
sudo apt-get install g++-multilib libc6-dev-i386
sudo apt-get install -qq gcc-arm-linux-gnueabihf

You can now compile:

cargo build --target=armv7-unknown-linux-gnueabihf

Dependencies

~2MB
~40K SLoC