Hi,
As a part of developing the sensor interface, I want to register a
“listener” on the event queue:
listener.sl_sensor_type = type;
listener.sl_func = sensor_shell_read_listener;
listener.sl_arg = &ctx;
rc = sensor_register_listener(sensor, &listener);
if (rc != 0) {
goto err;
}
And then I want to essentially “wait” until I’ve read ’n’
entries, and block in my task:
/* Block until we've read 'n' samples. */
while (ctx.num_entries < nsamples) {
os_eventq_run(sensor_mgr_evq_get());
os_time_delay(1);
}
The sensor_shell_read_listener() function updates “num_entries”, and
when I’ve read the desired number of samples, the loop finishes.
Just calling os_time_delay() or os_eventq_run() in and of themselves is
not sufficient:
- os_eventq_run() will let the current task’s events (default event
queue in this case) run, but won’t process other tasks events (e.g.
shell is run out of a separate task in this case.)
- os_time_delay() lets the other tasks run.
q: Should we add a os_eventq_yield(evq, time) function that does both of
these tasks? I think it might be clearer that this is the intention in
that case.
Sterling