The ESF GPIO Driver manages the General Purpose IOs on a gateway using the Driver model. Based on the ESF GPIO Service, the driver can be used in to the Wires framework, the Asset model or directly using the Driver itself.
The GPIO Driver includes the following features:
- support for digital input and output
- support for unsolicited inputs
- the trigger event can be configured directly through the Driver
As the others Drivers supported by ESF, it is distributed as a deployment package on Eclipse Marketplace. It can be installed following the instructions provided here.
A new GPIO Driver instance can be created either by clicking the New Driver button in the dedicated Drivers and Assets Web UI section or by clicking on the + button under Services. In both cases, the
org.eclipse.kura.driver.gpio factory must be selected and a unique name must be provided for the new instance.
Once instantiated, the GPIO Driver is ready to use and no configuration is needed.
The GPIO Driver channel can be configured with the following parameters:
enabled: it allows to enable/disable the channel. If it isn't selected the channel will be ignored.
name: the channel name.
type: the channel type, (
value.type: the Java type of the channel value. The value read by the Driver will be converted to the value.type. Conversely, in write operations the Driver will accept value of this kind.
listen: when selected, a listener will be attached to this channel. Any event on the channel will be reported using a callback and the value will be emitted.
resource.name: the name of the GPIO resource as reported by the GPIO Service. The
#select resourceselection has no effect on the channel.
resource.direction: the direction of the GPIO. Possible values are
#select directionselection has no effect on the channel.
resource.trigger: the type of event that triggers the listener, if selected. Possible values are:
NONE: no event will trigger the listener.
BOTH_EDGES: the listeners will be triggered respectively by a low-high transition, a high-low transition or both.
BOTH_LEVELS: the listeners will be triggered respectively by the detection of a high, low or both levels. Please note that these options aren't supported by all the devices.
Drive a LED using the GPIO Driver
In this section a simple example on the ESF GPIO Driver will be presented. The examples use a ReliaGATE 10-11 or 10-12.
From the Drivers and Assets tab, create a new ESF GPIO Driver, call it GPIODriver and add an Asset as shown in the following picture.
The asset is configured to manage the LED1 gpio as an output and drives it writing a boolean value. In the Data tab, fill the Value form with true and press Apply: the USER1 green led will switch on.
Updated over 3 years ago