GPIO class Null safety

GPIO wrapper functions for Linux userspace character device gpio-cdev and sysfs GPIOs.

Character device GPIOs were introduced in Linux kernel version 4.8. If the toolchain used to compiled c-periphery contains Linux kernel headers older than 4.8 (i.e. linux/gpio.h is missing), then only legacy sysfs GPIOs will be supported.

c-periphery GPIO documentation.

Constructors

GPIO(int line, GPIOdirection direction, [int chip = 0])
Opens the character device GPIO with the specified GPIO line and direction at the default character device GPIO with the chip number. The default chip number is 0, with the path /dev/gpiochip0. [...]
GPIO.advanced(int line, GPIOconfig config, [int chip = 0])
Opens the character device GPIO with the specified GPIO line and configuration config at the default character device GPIO with the chip number. The default chip numer is 0, with the path /dev/gpiochip0. Use GPIO.setBaseGPIOpath to change the default character device path.
GPIO.name(String name, GPIOdirection direction, [int chip = 0])
Opens the character device GPIO with the specified GPIO name and direction at the default character device GPIO with the chip number. The default chip number is 0, with the path /dev/gpiochip0. Use GPIO.setBaseGPIOpath to change the default character device path.
GPIO.nameAdvanced(String name, GPIOconfig config, [int chip = 0])
Opens the character device GPIO with the specified GPIO name and the configuration config at the default character device GPIO with the chip number. The default chip numer is 0, with the path /dev/gpiochip0. Use GPIO.setBaseGPIOpath to change the default character device path.
GPIO.sysfs(int line, GPIOdirection direction)
Opens the sysfs GPIO with the specified line and direction.

Properties

chip int
GPIO chip number, e.g. 0 for /dev/gpiochip0
final
direction GPIOdirection
input/ouput GPIO direction
final
hashCode int
The hash code for this object. [...]
read-only, inherited
line int
GPIO line number, is -1 if GPIO.name is used
final
name String
GPIO name, is empty if GPIO.line is used
final
path String
GPIO chip device path e.g. /dev/gpiochip0
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

dispose() → void
Releases all internal native resoures.
getErrno() int
Returns the libc errno of the last failure that occurred.
getGPIObias() GPIObias
Returns the property bias of the GPIO.
getGPIOchipFD() int
Returns the GPIO chip file descriptor of the GPIO handle. This method is intended for use with character device GPIOs and is unsupported by sysfs GPIOs.
getGPIOchipLabel() String
Returns the label of the GPIO chip associated with the GPIO.
getGPIOchipName() String
Returns the label of the GPIO chip associated with the GPIO.
getGPIOdirection() GPIOdirection
Returns the property direction of the GPIO.
getGPIOdrive() GPIOdrive
Returns the property drive of the GPIO.
getGPIOedge() GPIOedge
Returns the property edge of the GPIO.
getGPIOfd() int
Returns the native line file descriptor of the GPIO handle.
getGPIOinfo() String
Returns a string representation of the native GPIO handle.
getGPIOlabel() String
Returns the line consumer label of the GPIO. This method is intended for use with character device GPIOs and always returns the empty string for sysfs GPIOs.
getGPIOname() String
Returns the line name of the GPIO. This method is intended for use with character device GPIOs and always returns the empty string for sysfs GPIOs.
getLine() int
Returns the line the GPIO handle was opened with.
isInverted() bool
Returns if the GPIO line is inverted,
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
poll(int timeoutMillis) GPIOpolling
Polls a GPIO for the edge event configured with GPIO.setGPIOedge. For character device GPIOs, the edge event should be consumed with gpio_read_event(). For sysfs GPIOs, the edge event should be consumed with GPIO.read.
read() bool
Reads the state of the GPIO line.
readEvent(int timeoutMillis) GPIOreadEvent
Reads the edge event that occurred with the GPIO. This method is intended for use with character device GPIOs and is unsupported by sysfs GPIOs.
setGPIObias(GPIObias bias) → void
Sets the bias of the GPIO.
setGPIOdirection(GPIOdirection direction) → void
Sets the direction of the GPIO.
setGPIOdrive(GPIOdrive drive) → void
Sets the drive of the GPIO.
setGPIOedge(GPIOedge edge) → void
Sets the edge of the GPIO.
setInverted(bool inverted) → void
Inverts the GPIO line.
toString() String
A string representation of this object. [...]
inherited
write(bool value) → void
Sets the state of the GPIO to value.

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited

Static Methods

getGPIOerrorCode(int value) GPIOerrorCode
Converts the native error code value to GPIOerrorCode.
pollMultiple(List<GPIO> gpios, int timeoutMillis) PollMultipleEvent
Polls multiple GPIOs for an edge event configured with GPIO.setGPIOedge. For character device GPIOs, the edge event should be consumed with GPIO.readEvent. For sysfs GPIOs, the edge event should be consumed with GPIO.read. timeoutMillis can be positive for a timeout in milliseconds, zero for a non-blocking poll, or negative for a blocking poll. Returns a PollMultipleEvent()
setBaseGPIOpath(String chipBasePath) → void
Sets an alternative chipBasePath, default value is '/dev/gpiochip'