[riot-notifications] [RIOT-OS/RIOT] Proposal: eSAUL - Extended Sensor Actuator Uber Layer (#14121)

Juergen Fitschen notifications at github.com
Sat May 23 15:36:20 CEST 2020


#### Description

SAUL offers getter and setter to control actuators and obtain sensor readings. It is completely up to the application using SAUL when to access the SAUL device. This can be a limitation as the application may wants to react on sensor events.

Examples:
- A toggle button is pressed
- A temperature changes significantly
- A motion sensor detects significant motion

Of course, this may be implemented by polling these sensors. But hardware interrupts may allow more elegant and better solutions.

This made me thinking of a more sophisticated solution: eSAUL. It extends the existing SAUL registry by a maintenance thread that checks supported eSAUL devices in terms of changes and notify interested threads.

Has anyone already put some thought in solutions like this? What do you think of such a system? Do you have use-cases which could benefit from eSAUL?

##### Some implementation ideas

- The `saul_driver_t` is extended by an check_change function pointer -> `esaul_driver_t`. If this function is called, it checks if the sensor reading has changed since the last call and returns the current sensor reading.
- eSAUL requires one thread for maintaining all eSAUL devices:
  - It listens for `MSG_UPDATE_DEVICE` messages using `msg_receive()`. These messages trigger calling the check_change function defined in the respective `esaul_driver_t`.
  - If check_change returns a non-zero value, a `MSG_BUS_CHANGE` is posted using `msg_bus_post()`. Other threads may subscribe to these change events and listen for the new sensor readings
- During initialization of a driver supporting eSAUL, it:
  - registers the device with the SAUL registry -> eSAUL devices are also SAUL devices.
  - may implement IRQ handlers which sends `MSG_UPDATE_DEVICE` messages.
  - may start a recurrent timer which sends `MSG_UPDATE_DEVICE` messages periodically.

If this sounds interesting to someone, please let me know. In this case, I'll open a PR with a PoC demonstrating this proposal.

### Useful links

SAUL documentation: https://riot-os.org/api/group__drivers__saul.html


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/issues/14121
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200523/47c8ddfe/attachment.htm>


More information about the notifications mailing list