SAUL registry

Global sensor/actuator registry for SAUL devices. More...

Detailed Description

Global sensor/actuator registry for SAUL devices.

See also
[S]ensor [A]ctuator [U]ber [L]ayer

Files

file  saul_reg.h
 SAUL registry interface definition.
 

Data Structures

struct  saul_reg
 SAUL registry entry. More...
 
struct  saul_reg_info_t
 Additional data to collect for each entry. More...
 

Typedefs

typedef struct saul_reg saul_reg_t
 SAUL registry entry.
 

Functions

int saul_reg_add (saul_reg_t *dev)
 Register a device with the SAUL registry. More...
 
int saul_reg_rm (saul_reg_t *dev)
 Unregister a device from the SAUL registry. More...
 
saul_reg_tsaul_reg_find_nth (int pos)
 Find a device by it's position in the registry. More...
 
saul_reg_tsaul_reg_find_type (uint8_t type)
 Find the first device of the given type in the registry. More...
 
saul_reg_tsaul_reg_find_name (const char *name)
 Find a device by its name. More...
 
int saul_reg_read (saul_reg_t *dev, phydat_t *res)
 Read data from the given device. More...
 
int saul_reg_write (saul_reg_t *dev, phydat_t *data)
 Write data to the given device. More...
 

Variables

saul_reg_tsaul_reg
 Export the SAUL registry as global variable.
 

Function Documentation

◆ saul_reg_add()

int saul_reg_add ( 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
[in]devpointer to a pre-populated registry entry
Returns
0 on success
-ENODEV on invalid entry given

◆ saul_reg_find_name()

saul_reg_t* saul_reg_find_name ( const char *  name)

Find a device by its name.

Parameters
[in]namethe name to look for
Returns
pointer to the first device matching the given name
NULL if no device with that name could be found

◆ saul_reg_find_nth()

saul_reg_t* saul_reg_find_nth ( int  pos)

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

Parameters
[in]posposition to look up
Returns
pointer to the device at position specified by pos
NULL if no device is registered at that position

◆ saul_reg_find_type()

saul_reg_t* saul_reg_find_type ( uint8_t  type)

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

Parameters
[in]typedevice type to look for
Returns
pointer to the first device matching the given type
NULL if no device of that type could be found

◆ saul_reg_read()

int saul_reg_read ( saul_reg_t dev,
phydat_t res 
)

Read data from the given device.

Parameters
[in]devdevice to read from
[out]reslocation to store the results in
Returns
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

◆ saul_reg_rm()

int saul_reg_rm ( saul_reg_t dev)

Unregister a device from the SAUL registry.

Warning
Removing the device at runtime can send applications that have looked up that device into invalid states, and should thus be avoided.
This function must only be used by drivers that advise developers using them on how to prevent race conditions when using SAUL.
Deprecated:
This function will be removed soon as it is practically unusable for the above reasons.
Parameters
[in]devpointer to a registry entry
Returns
0 on success
-ENODEV if device was not found in the registry

◆ saul_reg_write()

int saul_reg_write ( saul_reg_t dev,
phydat_t data 
)

Write data to the given device.

Parameters
[in]devdevice to write to
[in]datadata to write to the device
Returns
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