Home  Contents

MUPP read/write

Gpio Core4 Lua Event System

SYNOPSIS

#include <lua/gpio.lh>
  1. ans = gpio.read(group, addr, len)
  2. gpio.write(group, addr, data)
  3. gpio.writeAnd(group, addr, data)
  4. gpio.writeOr(group, addr, data)

DESCRIPTION

Perform a read or write access on a MUPP device. group indicates the registered group ID used with the gpio.register() command.

addr is the starting address on the device. Bits 8..15 specify the MUPP-object and bits 0..7 specify the MUPP-address inside the object.

For read accesses, len indicates the number of bytes to transfer. The command returns the data that was read on success.

For write accesses, data holds the data to be written. The command returns true on success. Instead of a plain write, bit-wise AND and OR operations are possible, the accessed device permitting.

RETURN VALUE

On success, the read command returns the requested data as a string, the write command 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.

SEE ALSO