Home  Contents

gpio.register

Gpio Core4 Lua Event System

SYNOPSIS

#include <lua/gpio.lh>
  1. gpio.register(groupid, group, device, address)
  2. gpio.unregister(groupid)

DESCRIPTION

This function will register an external multi-IO device (MIO). Once registered, the system will automatically poll the device in regular intervals. The standard gpio functions can be used to access the inputs and outputs on the MIO.

The variable groupid uniquely identifies the device. It can be freely chosen, but must be unique for each registered device and must be in the range 0x0100...0xFFFF. The ID is used as the group parameter in all other gpio functions to reach the device.

The variable group identifies the parent group. Currently, this must be GPGRP_MUPP to indicate devices that talk the MUPP or MUPP/E protocol.

device contains the serial device used. This may be any serial port (/dev/ttySx). On the V4, you can also use /dev/mbus for devices attached to the µBus connector. Finally, address indicates the address of the device on the bus. Devices usually have jumpers or DIP-switches to select an address.

When not needed, a device can be unregistered again, using the same id as was used when it was registered.

RETURN VALUE

On success, returns true. On error, three values are returned: nil, a string describing the error (The result of the C library call strerror() on the errno code) and the errno number from the standard C library.

EXAMPLE

Assuming a V4 controller with an eeMIO attached to the µBus connector on address 0.

gpio.register(0x100, GPGRP_MUPP, "/dev/mbus", 0)

SEE ALSO