Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 25 additions & 27 deletions system/uorb/listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static int listener_print(FAR const struct orb_metadata *meta, int fd);
static void listener_monitor(FAR struct listen_list_s *objlist,
int nb_objects, float topic_rate,
int topic_latency, int nb_msgs,
int timeout, bool record, bool nonwakeup);
int timeout, bool record, bool wakeup);
static int listener_update(FAR struct listen_list_s *objlist,
FAR struct orb_object *object);
static void listener_top(FAR struct listen_list_s *objlist,
Expand Down Expand Up @@ -140,7 +140,7 @@ listener <command> [arguments...]\n\
\t[-l ] Top only execute once.\n\
\t[-i ] Get sensor device information based on topic.\n\
\t[-f ] Flush sensor drive data.\n\
\t[-u ] Subscribe in non-wakeup mode to save power.\n\
\t[-w ] Subscribe in wakeup mode.\n\
");
}

Expand Down Expand Up @@ -187,28 +187,26 @@ static int listener_create_dir(FAR char *dir, size_t size)
* Name: listener_subscribe
*
* Description:
* Subscribe topic according to non wakeup mode.
* Subscribe topic according to wakeup mode.
*
* Input Parameters:
* tmp Given object
* nonwakeup State of nonwakeup.
* wakeup State of wakeup.
*
* Returned Value:
* fd on success, otherwise -1.
****************************************************************************/

static int listener_subscribe(FAR struct listen_object_s *tmp,
bool nonwakeup)
bool wakeup)
{
if (nonwakeup)
if (wakeup)
{
return orb_subscribe_multi_nonwakeup(tmp->object.meta,
tmp->object.instance);
}
else
{
return orb_subscribe_multi(tmp->object.meta, tmp->object.instance);
return orb_subscribe_multi_wakeup(tmp->object.meta,
tmp->object.instance);
}

return orb_subscribe_multi(tmp->object.meta, tmp->object.instance);
}

/****************************************************************************
Expand Down Expand Up @@ -571,14 +569,14 @@ static int listener_print(FAR const struct orb_metadata *meta, int fd)
* objlist Topic object list.
* nb_objects Length of objects list.
* timeout Maximum poll waiting time(microsecond).
* nonwakeup The state of non wakeup
* wakeup The state of wakeup
*
* Returned Value:
* void
****************************************************************************/

static void listener_flush_topic(FAR const struct listen_list_s *objlist,
int nb_objects, int timeout, bool nonwakeup)
int nb_objects, int timeout, bool wakeup)
{
FAR struct listen_object_s *tmp;
FAR struct pollfd *fds;
Expand Down Expand Up @@ -607,7 +605,7 @@ static void listener_flush_topic(FAR const struct listen_list_s *objlist,
{
int fd;

fd = listener_subscribe(tmp, nonwakeup);
fd = listener_subscribe(tmp, wakeup);
if (fd < 0)
{
fds[i].fd = -1;
Expand Down Expand Up @@ -703,14 +701,14 @@ static void listener_flush_topic(FAR const struct listen_list_s *objlist,
*
* Input Parameters:
* objlist topic object list.
* nonwakeup The state of non wakeup
* wakeup The state of wakeup
*
* Returned Value:
* void
****************************************************************************/

static void listener_print_info(FAR const struct listen_list_s *objlist,
bool nonwakeup)
bool wakeup)
{
FAR struct listen_object_s *tmp;
orb_info_t info;
Expand All @@ -719,7 +717,7 @@ static void listener_print_info(FAR const struct listen_list_s *objlist,

SLIST_FOREACH(tmp, objlist, node)
{
fd = listener_subscribe(tmp, nonwakeup);
fd = listener_subscribe(tmp, wakeup);
if (fd < 0)
{
continue;
Expand Down Expand Up @@ -807,7 +805,7 @@ static int listener_record(FAR const struct orb_metadata *meta, int fd,
static void listener_monitor(FAR struct listen_list_s *objlist,
int nb_objects, float topic_rate,
int topic_latency, int nb_msgs,
int timeout, bool record, bool nonwakeup)
int timeout, bool record, bool wakeup)
{
FAR struct pollfd *fds;
char path[PATH_MAX];
Expand Down Expand Up @@ -838,7 +836,7 @@ static void listener_monitor(FAR struct listen_list_s *objlist,
{
int fd;

fd = listener_subscribe(tmp, nonwakeup);
fd = listener_subscribe(tmp, wakeup);
if (fd < 0)
{
fds[i].fd = -1;
Expand Down Expand Up @@ -1079,7 +1077,7 @@ int main(int argc, FAR char *argv[])
bool info = false;
bool flush = false;
bool record = false;
bool nonwakeup = false;
bool wakeup = false;
bool only_once = false;
FAR char *filter = NULL;
int ret;
Expand All @@ -1093,7 +1091,7 @@ int main(int argc, FAR char *argv[])

/* Pasrse Argument */

while ((ch = getopt(argc, argv, "r:b:n:t:Tfslhiu")) != EOF)
while ((ch = getopt(argc, argv, "r:b:n:t:Tfslhiw")) != EOF)
{
switch (ch)
{
Expand Down Expand Up @@ -1151,8 +1149,8 @@ int main(int argc, FAR char *argv[])
info = true;
break;

case 'u':
nonwakeup = true;
case 'w':
wakeup = true;
break;

case 'h':
Expand All @@ -1177,13 +1175,13 @@ int main(int argc, FAR char *argv[])

if (flush)
{
listener_flush_topic(&objlist, ret, timeout, nonwakeup);
listener_flush_topic(&objlist, ret, timeout, wakeup);
goto exit;
}

if (info)
{
listener_print_info(&objlist, nonwakeup);
listener_print_info(&objlist, wakeup);
goto exit;
}

Expand All @@ -1202,7 +1200,7 @@ int main(int argc, FAR char *argv[])
}

listener_monitor(&objlist, ret, topic_rate, topic_latency,
nb_msgs, timeout, record, nonwakeup);
nb_msgs, timeout, record, wakeup);
}

exit:
Expand Down
11 changes: 7 additions & 4 deletions system/uorb/sensor/accel.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@
#ifdef CONFIG_DEBUG_UORB
static const char sensor_accel_format[] =
"timestamp:%" PRIu64 ",x:%hf,y:%hf,z:%hf,temperature:%hf";

static const char sensor_accel_uncal_format[] =
"timestamp:%" PRIu64 ",x:%hf,y:%hf,z:%hf,x_bias:%hf,y_bias:%hf,"
"z_bias:%hf,temperature:%hf";
#endif

/****************************************************************************
* Public Data
****************************************************************************/

ORB_DEFINE(sensor_accel, struct sensor_accel, sensor_accel_format);
ORB_DEFINE(sensor_accel_uncal, struct sensor_accel, sensor_accel_format);
ORB_DEFINE(sensor_accel_uncal, struct sensor_accel_uncal,
sensor_accel_uncal_format);
ORB_DEFINE(sensor_linear_accel, struct sensor_accel, sensor_accel_format);
ORB_DEFINE(sensor_linear_accel_uncal, struct sensor_accel,
sensor_accel_format);
ORB_DEFINE(sensor_linear_accel_uncal, struct sensor_accel_uncal,
sensor_accel_uncal_format);
6 changes: 5 additions & 1 deletion system/uorb/sensor/gyro.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@
#ifdef CONFIG_DEBUG_UORB
static const char sensor_gyro_format[] =
"timestamp:%" PRIu64 ",x:%hf,y:%hf,z:%hf,temperature:%hf";
static const char sensor_gyro_uncal_format[] =
"timestamp:%" PRIu64 ",x:%hf,y:%hf,z:%hf,x_bias:%hf,y_bias:%hf,"
"z_bias:%hf,temperature:%hf";
#endif

/****************************************************************************
* Public Data
****************************************************************************/

ORB_DEFINE(sensor_gyro, struct sensor_gyro, sensor_gyro_format);
ORB_DEFINE(sensor_gyro_uncal, struct sensor_gyro, sensor_gyro_format);
ORB_DEFINE(sensor_gyro_uncal, struct sensor_gyro_uncal,
sensor_gyro_uncal_format);
6 changes: 5 additions & 1 deletion system/uorb/sensor/mag.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@
static const char sensor_mag_format[] =
"timestamp:%" PRIu64 ",x:%hf,y:%hf,z:%hf,temperature:%hf,"
"status:%" PRId32 "";
static const char sensor_mag_uncal_format[] =
"timestamp:%" PRIu64 ",x:%hf,y:%hf,z:%hf,x_bias:%hf,y_bias:%hf,"
"z_bias:%hf,temperature:%hf,status:%" PRId32 "";
#endif

/****************************************************************************
* Public Data
****************************************************************************/

ORB_DEFINE(sensor_mag, struct sensor_mag, sensor_mag_format);
ORB_DEFINE(sensor_mag_uncal, struct sensor_mag, sensor_mag_format);
ORB_DEFINE(sensor_mag_uncal, struct sensor_mag_uncal,
sensor_mag_uncal_format);
9 changes: 2 additions & 7 deletions system/uorb/test/unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,6 @@ static int test_multi(int *afds, int *sfds)
return test_fail("sub #1 val. mismatch: %d", sub_sample.val);
}

if (OK != latency_test(false))
{
return test_fail("latency test failed");
}

orb_unsubscribe(sfds[0]);
orb_unsubscribe(sfds[1]);

Expand Down Expand Up @@ -1162,12 +1157,12 @@ int main(int argc, FAR char *argv[])
{
if (test() == OK)
{
printf("PASS\n");
printf("TEST PASS\n");
return 0;
}
else
{
printf("FAIL\n");
printf("TEST FAIL\n");
return -1;
}
}
Expand Down
10 changes: 5 additions & 5 deletions system/uorb/uORB/uORB.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@
* flag The open flag.
* instance Instance number to open.
* queue_size Maximum number of buffered elements.
* non_wakeup The non wakeup flag.
* wakeup The wakeup flag.
*
* Returned Value:
* fd on success, otherwise returns negative value and set errno.
****************************************************************************/

static int orb_advsub_open(FAR const struct orb_metadata *meta, int flags,
int instance, unsigned int queue_size,
FAR orb_info_t *info, bool non_wakeup)
FAR orb_info_t *info, bool wakeup)
{
char path[ORB_PATH_MAX];
int fd;
Expand Down Expand Up @@ -124,9 +124,9 @@
ioctl(fd, SNIOC_SET_BUFFER_NUMBER, (unsigned long)queue_size);
}

if (non_wakeup)
if (wakeup)
{
ioctl(fd, SNIOC_SET_NONWAKEUP, (unsigned long)non_wakeup);
ioctl(fd, SNIOC_SET_WAKEUP, (unsigned long)wakeup);

Check failure on line 129 in system/uorb/uORB/uORB.c

View workflow job for this annotation

GitHub Actions / Linux (sim-03)

'SNIOC_SET_WAKEUP' undeclared (first use in this function); did you mean 'SNIOC_SET_NONWAKEUP'?

Check failure on line 129 in system/uorb/uORB/uORB.c

View workflow job for this annotation

GitHub Actions / Linux (sim-03)

'SNIOC_SET_WAKEUP' undeclared (first use in this function); did you mean 'SNIOC_SET_NONWAKEUP'?
}

return fd;
Expand Down Expand Up @@ -219,7 +219,7 @@
return orb_advsub_open(meta, O_RDONLY, instance, 0, NULL, false);
}

int orb_subscribe_multi_nonwakeup(FAR const struct orb_metadata *meta,
int orb_subscribe_multi_wakeup(FAR const struct orb_metadata *meta,
unsigned instance)
{
return orb_advsub_open(meta, O_RDONLY, instance, 0, NULL, true);
Expand Down
24 changes: 11 additions & 13 deletions system/uorb/uORB/uORB.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ static inline int orb_publish_auto(FAR const struct orb_metadata *meta,
* Name: orb_subscribe_multi
*
* Description:
* Subscribe to a topic.
* Subscribe to a topic in a non-wakeup ways.
*
* The data is published to the topic and any waiting subscribers will be
* notified. Subscribers that are not waiting can check the topic for
Expand Down Expand Up @@ -485,20 +485,18 @@ static inline int orb_subscribe(FAR const struct orb_metadata *meta)
}

/****************************************************************************
* Name: orb_subscribe_multi_nonwakeup/orb_subscribe_nonwakeup
* Name: orb_subscribe_multi_wakeup/orb_subscribe_wakeup
*
* Description:
* Subscribe to a topic in a non-wakeup ways.
* Subscribe to a topic in a wakeup ways.
*
* The usage of orb_subscribe_multi_nonwakeup is similar to that of
* The usage of orb_subscribe_multi_wakeup is similar to that of
* orb_subscribe_multi, with the key difference lying in whether the
* system's wakeup status needs to be concerned. This distinction is
* particularly beneficial for low-power consumption scenarios.
* If the subscription is in a non-wakeup mode, the subscriber will not
* receive data while the system is in sleep mode. In such cases, new data
* will overwrite old data until the system is awakened, at which point
* the subscriber will be notified. Typically, the subscriber and
* publisher of a topic reside in two separate systems.
* If the subscription is in a wakeup mode, the subscriber will be wokeup
* and it receives data while the system is in sleep mode. Typically, the
* subscriber and publisher of a topic reside in two separate systems.
*
* Input Parameters:
* meta The uORB metadata (usually from the ORB_ID() macro)
Expand All @@ -513,13 +511,13 @@ static inline int orb_subscribe(FAR const struct orb_metadata *meta)
* this function will return -1 and set errno to ENOENT.
****************************************************************************/

int orb_subscribe_multi_nonwakeup(FAR const struct orb_metadata *meta,
unsigned instance);
int orb_subscribe_multi_wakeup(FAR const struct orb_metadata *meta,
unsigned instance);

static inline
int orb_subscribe_nonwakeup(FAR const struct orb_metadata *meta)
int orb_subscribe_wakeup(FAR const struct orb_metadata *meta)
{
return orb_subscribe_multi_nonwakeup(meta, 0);
return orb_subscribe_multi_wakeup(meta, 0);
}

/****************************************************************************
Expand Down
Loading