This is an old revision of the document!
Using the HAL with the GPIO Subsystem
In the EEROS library you will find a directory with examples. For this example see HalTest4.cpp.
The system either uses real hardware inputs and output or makes use of a simulated gpio device. You need to install the necessary wrapper library for gpio, see Installing Hardware Libraries.
When using a simulated gpio device, make sure to load the kernel driver first and then create the device with
$ sudo modprobe gpio-sim $ sudo mkdir /sys/kernel/config/gpio-sim/ofagpio $ sudo mkdir /sys/kernel/config/gpio-sim/ofagpio/bank0 $ echo 32 | sudo tee /sys/kernel/config/gpio-sim/ofagpio/bank0/num_lines $ echo 1 | sudo tee /sys/kernel/config/gpio-sim/ofagpio/live
Make sure that your local user has access to the device file.
$ sudo chown $USER:$USER /dev/gpiochip0
Open a shell in the build directory of your EEROS library and run
$ ./examples/hal/halTest4 -c HalTest4ConfigGpio.json
It will start in safety level slOne and mirror the digital input channel 1 to output channel 0. You can check this behavior with
$ echo pull-up | sudo tee /sys/devices/platform/gpio-sim.0/gpiochip0/sim_gpio1/pull
or
$ echo pull-down | sudo tee /sys/devices/platform/gpio-sim.0/gpiochip0/sim_gpio1/pull
while reading the state of channel 0 with
$ cat /sys/devices/platform/gpio-sim.0/gpiochip0/sim_gpio0/value
