[riot-notifications] [RIOT-OS/RIOT] [PoC] Reactive SAUL: saul_observer based on msg_bus (#14182)
notifications at github.com
Sun May 31 16:53:48 CEST 2020
### Contribution description
After some bikeshedding in #14121, I started implementing a PoC.
This is the first PoC demonstrating an implementation based on `msg_bus`.
Some thoughts from my point-of-view:
- (+) Easy interface - especially if the interested thread wants to monitor many SAUL devices. No special list-item must be held in memory for every subscription.
- (+) Very few lines of code: Only ~50 LoCs are required for the basic functionality.
- (-) If the message-based IPC is used for other purposes, message types (they hold the bus ID and event type) may collide with other messages unrelated to `saul_observer`. Furthermore, message types used by `saul_observer` are not predictable as they encode the bus ID.
- (-) If more than 32 SAUL devices are present, `saul_observer_unsubscribe()` leads to unexpected behavior.
I'll come up with a second PoC show-casing a callback-based approach.
### Testing procedure
Flash `tests/saul_observer` onto a board with `saul_gpio` support and play around with the registered SAUL devices. You should see some change notifications.
# make -C tests/saul_observer BOARD=samr30-xpro flash term
2020-05-31 16:50:28,802 # saul
2020-05-31 16:50:28,805 # ID Class Name
2020-05-31 16:50:28,808 # #0 ACT_SWITCH LED(green)
2020-05-31 16:50:28,810 # #1 ACT_SWITCH LED(orange)
2020-05-31 16:50:28,811 # #2 SENSE_BTN Button(SW0)
> saul write 0 1
2020-05-31 16:50:43,470 # saul write 0 1
2020-05-31 16:50:43,473 # Writing to device #0 - LED(green)
2020-05-31 16:50:43,475 # Data: 1
2020-05-31 16:50:43,478 # data successfully written to device #0
> 2020-05-31 16:50:43,484 # SAUL DEV 0 (LED(green)) CHANGED - Data: 1
2020-05-31 16:50:55,254 # SAUL DEV 2 (Button(SW0)) CHANGED - Data: 1
2020-05-31 16:50:55,402 # SAUL DEV 2 (Button(SW0)) CHANGED - Data: 0
(Of course, no de-bouncing for the switch at the current state. This should be included for a PR that is about to be merged ...)
### Issues/PRs references
You can view, comment on, or merge this pull request online at:
-- Commit Summary --
* sys/saul_reg: add device id
* sys/saul_observer: initial commit
* tests/saul_observer: initial commit
* drivers/saul_gpio: add basic SAUL observer driver
-- File Changes --
M Makefile.dep (6)
M drivers/include/saul.h (17)
M drivers/saul/gpio_saul.c (19)
M drivers/saul/init_devs/auto_init_gpio.c (18)
M sys/Makefile.dep (5)
M sys/auto_init/auto_init.c (6)
A sys/include/saul_observer.h (114)
M sys/include/saul_reg.h (1)
A sys/saul_observer/Makefile (1)
A sys/saul_observer/saul_observer.c (63)
M sys/saul_reg/saul_reg.c (18)
A tests/saul_observer/Makefile (8)
A tests/saul_observer/Makefile.ci (7)
A tests/saul_observer/README.md (5)
A tests/saul_observer/main.c (67)
-- Patch Links --
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications