SAUL registry

Global sensor/actuator registry for SAUL devices.

struct saul_reg saul_reg_t

SAUL registry entry.

saul_reg.h::saul_reg_t * saul_reg

Export the SAUL registry as global variable.

int saul_reg_add(saul_reg.h::saul_reg_t * dev)

Register a device with the SAUL registry.

Note

Make sure the registry entry the dev pointer is pointing to resides in some persistent memory location and not on some position on the stack where it will be overwritten…

Parameters

dev:pointer to a pre-populated registry entry

Return values

  • 0 on success
  • -ENODEV on invalid entry given
int saul_reg_rm(saul_reg.h::saul_reg_t * dev)

Unregister a device from the SAUL registry.

Parameters

dev:pointer to a registry entry

Return values

  • 0 on success
  • -ENODEV if device was not found in the registry
saul_reg.h::saul_reg_t * saul_reg_find_nth(int pos)

Find a device by it’s position in the registry.

Parameters

pos:position to look up

Return values

  • pointer to the device at position specified by pos
  • NULL if no device is registered at that position
saul_reg.h::saul_reg_t * saul_reg_find_type(uint8_t type)

Find the first device of the given type in the registry.

Parameters

type:device type to look for

Return values

  • pointer to the first device matching the given type
  • NULL if no device of that type could be found
saul_reg.h::saul_reg_t * saul_reg_find_name(const char * name)

Find a device by its name.

Parameters

name:the name to look for

Return values

  • pointer to the first device matching the given name
  • NULL if no device with that name could be found
int saul_reg_read(saul_reg.h::saul_reg_t * dev, phydat_t * res)

Read data from the given device.

Parameters

dev:device to read from
res:location to store the results in

Return values

  • the number of data elements read to res [1-3]
  • -ENODEV if given device is invalid
  • -ENOTSUP if read operation is not supported by the device
  • -ECANCELED on device errors
int saul_reg_write(saul_reg.h::saul_reg_t * dev, phydat_t * data)

Write data to the given device.

Parameters

dev:device to write to
data:data to write to the device

Return values

  • the number of data elements processed by the device
  • -ENODEV if given device is invalid
  • -ENOTSUP if read operation is not supported by the device
  • -ECANCELED on device errors
struct saul_reg

SAUL registry entry.

struct saul_reg * next

pointer to the next device

void * dev

pointer to the device descriptor

const char * name

string identifier for the device

saul_driver_t const * driver

the devices read callback

struct saul_reg_info_t

Additional data to collect for each entry.

const char * name

string identifier for a device