mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
system/uorb: make listener see fetch()-only sensors
orb_subscribe_multi() opens the descriptor blocking, so a sensor whose lower half only implements fetch() (no push, e.g. an I2C part with no interrupt line) never satisfies poll()/read() and the listener silently times out with zero messages, indistinguishable from a sensor that has nothing to report. Set O_NONBLOCK after subscribing; sensors that do push samples are unaffected, since neither sensor_poll() nor sensor_read() consults O_NONBLOCK on that path. Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
This commit is contained in:
parent
5f286fc924
commit
0fd4adef52
1 changed files with 19 additions and 3 deletions
|
|
@ -200,15 +200,31 @@ static int listener_create_dir(FAR char *dir, size_t size)
|
|||
static int listener_subscribe(FAR struct listen_object_s *tmp,
|
||||
bool nonwakeup)
|
||||
{
|
||||
int flags;
|
||||
int fd;
|
||||
|
||||
if (nonwakeup)
|
||||
{
|
||||
return orb_subscribe_multi_nonwakeup(tmp->object.meta,
|
||||
tmp->object.instance);
|
||||
fd = orb_subscribe_multi_nonwakeup(tmp->object.meta,
|
||||
tmp->object.instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
return orb_subscribe_multi(tmp->object.meta, tmp->object.instance);
|
||||
fd = orb_subscribe_multi(tmp->object.meta, tmp->object.instance);
|
||||
}
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
return fd;
|
||||
}
|
||||
|
||||
flags = fcntl(fd, F_GETFL, 0);
|
||||
if (flags >= 0)
|
||||
{
|
||||
fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue