You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "Otpvondoiats (via GitHub)" <gi...@apache.org> on 2025/11/19 07:46:17 UTC
[PR] uorb: add generator tool. [nuttx-apps]
Otpvondoiats opened a new pull request, #3214:
URL: https://github.com/apache/nuttx-apps/pull/3214
## Summary
uorb_generator this tool can be used in conjunction with uorb_listener.
Before using the tool, it is necessary to set the CONFIG_LINE_MAX parameter to a sufficiently long length to ensure that the terminal can accept complete input data. A recommendation is to set it to 256 or 512.
Incoming data can be printed via uorb_listener or concatenated manually using format information, but it must be ensured that the string and struct information are consistent. Topics saved using uorb_listener -f can be pulled and imported into the simulator for debugging (mount -t hostfs -o fs=/home/xxx/ /data).
Parameter Description:
-f specifies the path to the input playback file. -n specifies the number of times to playback the data. This option is only effective when -s is enabled. -r specifies the playback frequency (in HZ, e.g., 5hz, 20hz). This option is only effective when -s is enabled. -t specifies the topic for playback, with the option to specify a specific instance value afterward. -s enables playback of simulated (fake) data, generating struct data from input entered via the terminal. It will modify the timestamp of the current data to real-time. Simulated data should be placed at the end of the entire command.
By following these instructions, users can effectively utilize the Generator debugging tool in conjunction with uorb_listener for system debugging and verification.
The tool publishes topic data via uorb.
Notice:LINE_MAX must be set to 128 or more.
generator <command> [arguments...]
Commands:
<topics_name> The playback topic name.
[-h ] Listener commands help.
[-f <val> ] File path to be played back(absolute path).
[-n <val> ] Number of playbacks(fake model), default: 1
[-r <val> ] The rate for playing fake data is only valid when parameter 's' is used.
default:10hz.
[-s <val> ] Playback fake data.
[-t <val> ] Playback topic.
e.g.:
sim - sensor_accel0:
uorb_generator -n 100 -r 5 -s -t sensor_accel0 timestamp:23191100,x:0.1,y:9.7,z:0.81,temperature:22.15
sim - sensor_baro0:
uorb_generator -n 100 -r 5 -s -t sensor_baro0 timestamp:23191100,pressure:999.12,temperature:26.34
fies - sensor_accel1
uorb_generator -f /data/uorb/20240823061723/sensor_accel0.csv -t sensor_accel1
## Testing
e.g.:
1. uorb_generator -f /data/sensor/19700101000003/sensor_accel_uncal0.csv -t sensor_accel_uncal2
2. uorb_generator -s -r 5 -n 200 -t sensor_accel_uncal2 timestamp:1,x:-2.0,y:3,z:4,temperature:5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] uorb: add generator tool. [nuttx-apps]
Posted by "Donny9 (via GitHub)" <gi...@apache.org>.
Donny9 commented on code in PR #3214:
URL: https://github.com/apache/nuttx-apps/pull/3214#discussion_r2540944105
##########
system/uorb/generator.c:
##########
@@ -0,0 +1,391 @@
+/****************************************************************************
+ * apps/system/uorb/generator.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/signal.h>
+#include <nuttx/streams.h>
+
+#include <ctype.h>
+#include <uORB/uORB.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define GENERATOR_CACHE_BUFF 4096
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sensor_gen_info_s
+{
+ struct orb_object obj;
+ FAR FILE *file;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_should_exit = false;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static void usage(void)
+{
+ uorbinfo_raw("\n\
+The tool publishes topic data via uorb.\n\
+Notice:NSH_LINELEN must be set to 128 or more.\n\
+\n\
+generator <command> [arguments...]\n\
+ Commands:\n\
+\t<topics_name> The playback topic name.\n\
+\t[-h ] Listener commands help.\n\
+\t[-f <val> ] File path to be played back(absolute path).\n\
+\t[-n <val> ] Number of playbacks(fake model), default: 1\n\
+\t[-r <val> ] The rate for playing fake data is only valid\
+ when parameter 's' is used. default:10hz.\n\
+\t[-s <val> ] Playback fake data.\n\
+\t[-t <val> ] Playback topic.\n\
+\t e.g.:\n\
+\t\tsim - sensor_accel0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_accel0 timestamp:23191100,\
+x:0.1,y:9.7,z:0.81,temperature:22.15\n\n\
+\t\tsim - sensor_baro0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_baro0 timestamp:23191100,\
+pressure:999.12,temperature:26.34\n\n\
+\t\tfies - sensor_accel1\n\
+\t\t uorb_generator -f /data/uorb/20240823061723/sensor_accel0.csv\
+ -t sensor_accel1\
+\t\t\n\
+ ");
+}
+
+static void exit_handler(int signo)
+{
+ g_should_exit = true;
+}
+
+static int get_play_orb_id(FAR const char *filter,
+ FAR struct sensor_gen_info_s *info)
+{
+ struct orb_object object;
+
+ if (filter)
+ {
+ object.meta = orb_get_meta(filter);
+ if (object.meta == NULL)
+ {
+ uorbinfo_raw("Input error built-in name:[%s]", filter);
+ return ERROR;
+ }
+
+ object.instance = 0;
+ if (isdigit(filter[strlen(filter) - 1]))
+ {
+ object.instance = filter[strlen(filter) - 1] - '0';
+ }
+
+ info->obj = object;
+ return OK;
+ }
+
+ uorbinfo_raw("The entered built-in topic name is empty.");
+ return ERROR;
+}
+
+/****************************************************************************
+ * Name: replay_worker
+ *
+ * Description:
+ * Playback data files.
+ *
+ * Input Parameters:
+ * sensor_gen Generator objects.
+ *
+ * Returned Value:
+ * 0 on success, otherwise -1
+ ****************************************************************************/
+
+static int replay_worker(FAR struct sensor_gen_info_s *sensor_gen)
+{
+ struct lib_meminstream_s meminstream;
+ bool is_frist = true;
+ uint64_t last_time;
+ uint64_t tmp_time;
+ FAR uint8_t *data;
+ FAR char *line;
+ int sleep_time;
+ int lastc;
+ int ret;
+ int fd;
+
+ line = kmm_zalloc(GENERATOR_CACHE_BUFF);
+ if (line == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ if (fgets(line, GENERATOR_CACHE_BUFF, sensor_gen->file) != NULL)
+ {
+ if (strstr(line, sensor_gen->obj.meta->o_name) == NULL)
+ {
+ uorbinfo_raw("Topic and file do not match!");
+ return -EINVAL;
+ }
+ }
+ else
+ {
+ uorbinfo_raw("Playback file format error!");
+ return -EINVAL;
+ }
+
+ data = kmm_zalloc(sensor_gen->obj.meta->o_size);
Review Comment:
```suggestion
data = malloc(sensor_gen->obj.meta->o_size);
```
##########
system/uorb/generator.c:
##########
@@ -0,0 +1,391 @@
+/****************************************************************************
+ * apps/system/uorb/generator.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/signal.h>
+#include <nuttx/streams.h>
+
+#include <ctype.h>
+#include <uORB/uORB.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define GENERATOR_CACHE_BUFF 4096
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sensor_gen_info_s
+{
+ struct orb_object obj;
+ FAR FILE *file;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_should_exit = false;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static void usage(void)
+{
+ uorbinfo_raw("\n\
+The tool publishes topic data via uorb.\n\
+Notice:NSH_LINELEN must be set to 128 or more.\n\
+\n\
+generator <command> [arguments...]\n\
+ Commands:\n\
+\t<topics_name> The playback topic name.\n\
+\t[-h ] Listener commands help.\n\
+\t[-f <val> ] File path to be played back(absolute path).\n\
+\t[-n <val> ] Number of playbacks(fake model), default: 1\n\
+\t[-r <val> ] The rate for playing fake data is only valid\
+ when parameter 's' is used. default:10hz.\n\
+\t[-s <val> ] Playback fake data.\n\
+\t[-t <val> ] Playback topic.\n\
+\t e.g.:\n\
+\t\tsim - sensor_accel0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_accel0 timestamp:23191100,\
+x:0.1,y:9.7,z:0.81,temperature:22.15\n\n\
+\t\tsim - sensor_baro0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_baro0 timestamp:23191100,\
+pressure:999.12,temperature:26.34\n\n\
+\t\tfies - sensor_accel1\n\
+\t\t uorb_generator -f /data/uorb/20240823061723/sensor_accel0.csv\
+ -t sensor_accel1\
+\t\t\n\
+ ");
+}
+
+static void exit_handler(int signo)
+{
+ g_should_exit = true;
+}
+
+static int get_play_orb_id(FAR const char *filter,
+ FAR struct sensor_gen_info_s *info)
+{
+ struct orb_object object;
+
+ if (filter)
+ {
+ object.meta = orb_get_meta(filter);
+ if (object.meta == NULL)
+ {
+ uorbinfo_raw("Input error built-in name:[%s]", filter);
+ return ERROR;
+ }
+
+ object.instance = 0;
+ if (isdigit(filter[strlen(filter) - 1]))
+ {
+ object.instance = filter[strlen(filter) - 1] - '0';
+ }
+
+ info->obj = object;
+ return OK;
+ }
+
+ uorbinfo_raw("The entered built-in topic name is empty.");
+ return ERROR;
+}
+
+/****************************************************************************
+ * Name: replay_worker
+ *
+ * Description:
+ * Playback data files.
+ *
+ * Input Parameters:
+ * sensor_gen Generator objects.
+ *
+ * Returned Value:
+ * 0 on success, otherwise -1
+ ****************************************************************************/
+
+static int replay_worker(FAR struct sensor_gen_info_s *sensor_gen)
+{
+ struct lib_meminstream_s meminstream;
+ bool is_frist = true;
+ uint64_t last_time;
+ uint64_t tmp_time;
+ FAR uint8_t *data;
+ FAR char *line;
+ int sleep_time;
+ int lastc;
+ int ret;
+ int fd;
+
+ line = kmm_zalloc(GENERATOR_CACHE_BUFF);
+ if (line == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ if (fgets(line, GENERATOR_CACHE_BUFF, sensor_gen->file) != NULL)
+ {
+ if (strstr(line, sensor_gen->obj.meta->o_name) == NULL)
+ {
+ uorbinfo_raw("Topic and file do not match!");
+ return -EINVAL;
+ }
+ }
+ else
+ {
+ uorbinfo_raw("Playback file format error!");
+ return -EINVAL;
+ }
+
+ data = kmm_zalloc(sensor_gen->obj.meta->o_size);
+ if (data == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ fd = orb_advertise_multi_queue_persist(sensor_gen->obj.meta,
+ data, &sensor_gen->obj.instance, 1);
+ if (fd < 0)
+ {
+ uorbinfo_raw("Playback orb advertise failed[%d]!", fd);
+ kmm_free(data);
+ return fd;
+ }
+
+ while (fgets(line, GENERATOR_CACHE_BUFF, sensor_gen->file) != NULL)
+ {
+ lib_meminstream(&meminstream, line, GENERATOR_CACHE_BUFF);
+ ret = lib_bscanf(&meminstream.common, &lastc,
+ sensor_gen->obj.meta->o_format, data);
+ if (ret >= 0)
+ {
+ tmp_time = *(uint64_t *)data;
+ if (is_frist)
+ {
+ last_time = *(uint64_t *)data;
+ is_frist = false;
+ }
+ else
+ {
+ sleep_time = tmp_time - last_time;
+ if (sleep_time > 0)
+ {
+ nxsig_usleep(sleep_time);
+ }
+
+ last_time = tmp_time;
+ }
+
+ if (OK != orb_publish(sensor_gen->obj.meta, fd, data))
+ {
+ uorbinfo_raw("Topic publish error!");
+ break;
+ }
+ }
+ else
+ {
+ uorbinfo_raw("[ignore] The text data for this line is wrong![%s]!",
+ line);
+ }
+ }
+
+ orb_unadvertise(fd);
+ kmm_free(data);
Review Comment:
```suggestion
free(data);
```
##########
system/uorb/generator.c:
##########
@@ -0,0 +1,391 @@
+/****************************************************************************
+ * apps/system/uorb/generator.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/signal.h>
+#include <nuttx/streams.h>
+
+#include <ctype.h>
+#include <uORB/uORB.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define GENERATOR_CACHE_BUFF 4096
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sensor_gen_info_s
+{
+ struct orb_object obj;
+ FAR FILE *file;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_should_exit = false;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static void usage(void)
+{
+ uorbinfo_raw("\n\
+The tool publishes topic data via uorb.\n\
+Notice:NSH_LINELEN must be set to 128 or more.\n\
+\n\
+generator <command> [arguments...]\n\
+ Commands:\n\
+\t<topics_name> The playback topic name.\n\
+\t[-h ] Listener commands help.\n\
+\t[-f <val> ] File path to be played back(absolute path).\n\
+\t[-n <val> ] Number of playbacks(fake model), default: 1\n\
+\t[-r <val> ] The rate for playing fake data is only valid\
+ when parameter 's' is used. default:10hz.\n\
+\t[-s <val> ] Playback fake data.\n\
+\t[-t <val> ] Playback topic.\n\
+\t e.g.:\n\
+\t\tsim - sensor_accel0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_accel0 timestamp:23191100,\
+x:0.1,y:9.7,z:0.81,temperature:22.15\n\n\
+\t\tsim - sensor_baro0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_baro0 timestamp:23191100,\
+pressure:999.12,temperature:26.34\n\n\
+\t\tfies - sensor_accel1\n\
+\t\t uorb_generator -f /data/uorb/20240823061723/sensor_accel0.csv\
+ -t sensor_accel1\
+\t\t\n\
+ ");
+}
+
+static void exit_handler(int signo)
+{
+ g_should_exit = true;
+}
+
+static int get_play_orb_id(FAR const char *filter,
+ FAR struct sensor_gen_info_s *info)
+{
+ struct orb_object object;
+
+ if (filter)
+ {
+ object.meta = orb_get_meta(filter);
+ if (object.meta == NULL)
+ {
+ uorbinfo_raw("Input error built-in name:[%s]", filter);
+ return ERROR;
+ }
+
+ object.instance = 0;
+ if (isdigit(filter[strlen(filter) - 1]))
+ {
+ object.instance = filter[strlen(filter) - 1] - '0';
+ }
+
+ info->obj = object;
+ return OK;
+ }
+
+ uorbinfo_raw("The entered built-in topic name is empty.");
+ return ERROR;
+}
+
+/****************************************************************************
+ * Name: replay_worker
+ *
+ * Description:
+ * Playback data files.
+ *
+ * Input Parameters:
+ * sensor_gen Generator objects.
+ *
+ * Returned Value:
+ * 0 on success, otherwise -1
+ ****************************************************************************/
+
+static int replay_worker(FAR struct sensor_gen_info_s *sensor_gen)
+{
+ struct lib_meminstream_s meminstream;
+ bool is_frist = true;
+ uint64_t last_time;
+ uint64_t tmp_time;
+ FAR uint8_t *data;
+ FAR char *line;
+ int sleep_time;
+ int lastc;
+ int ret;
+ int fd;
+
+ line = kmm_zalloc(GENERATOR_CACHE_BUFF);
+ if (line == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ if (fgets(line, GENERATOR_CACHE_BUFF, sensor_gen->file) != NULL)
+ {
+ if (strstr(line, sensor_gen->obj.meta->o_name) == NULL)
+ {
+ uorbinfo_raw("Topic and file do not match!");
+ return -EINVAL;
+ }
+ }
+ else
+ {
+ uorbinfo_raw("Playback file format error!");
+ return -EINVAL;
+ }
+
+ data = kmm_zalloc(sensor_gen->obj.meta->o_size);
+ if (data == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ fd = orb_advertise_multi_queue_persist(sensor_gen->obj.meta,
+ data, &sensor_gen->obj.instance, 1);
+ if (fd < 0)
+ {
+ uorbinfo_raw("Playback orb advertise failed[%d]!", fd);
+ kmm_free(data);
+ return fd;
+ }
+
+ while (fgets(line, GENERATOR_CACHE_BUFF, sensor_gen->file) != NULL)
+ {
+ lib_meminstream(&meminstream, line, GENERATOR_CACHE_BUFF);
+ ret = lib_bscanf(&meminstream.common, &lastc,
+ sensor_gen->obj.meta->o_format, data);
+ if (ret >= 0)
+ {
+ tmp_time = *(uint64_t *)data;
+ if (is_frist)
+ {
+ last_time = *(uint64_t *)data;
+ is_frist = false;
+ }
+ else
+ {
+ sleep_time = tmp_time - last_time;
+ if (sleep_time > 0)
+ {
+ nxsig_usleep(sleep_time);
+ }
+
+ last_time = tmp_time;
+ }
+
+ if (OK != orb_publish(sensor_gen->obj.meta, fd, data))
+ {
+ uorbinfo_raw("Topic publish error!");
+ break;
+ }
+ }
+ else
+ {
+ uorbinfo_raw("[ignore] The text data for this line is wrong![%s]!",
+ line);
+ }
+ }
+
+ orb_unadvertise(fd);
+ kmm_free(data);
+ return 0;
+}
+
+/****************************************************************************
+ * Name: fake_worker
+ *
+ * Description:
+ * Publish fake data.
+ *
+ * Input Parameters:
+ * sensor_gen Generator objects.
+ * nb_cycle Number of publications.
+ * topic_rate Publish frequency.
+ * buffer String data to publish.
+ *
+ * Returned Value:
+ * 0 on success, otherwise -1
+ ****************************************************************************/
+
+static int fake_worker(FAR struct sensor_gen_info_s *sensor_gen,
+ int nb_cycle, float topic_rate, FAR char *buffer)
+{
+ struct lib_meminstream_s meminstream;
+ FAR uint8_t *data;
+ uint64_t interval;
+ int lastc;
+ int fd;
+ int i;
+
+ if (buffer == NULL)
+ {
+ return -EINVAL;
+ }
+
+ data = kmm_zalloc(sensor_gen->obj.meta->o_size);
+ if (data == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ lib_meminstream(&meminstream, buffer, strlen(buffer));
+ if (lib_bscanf(&meminstream.common, &lastc,
+ sensor_gen->obj.meta->o_format, data) < 0)
+ {
+ uorbinfo_raw("Input string data parsing error![%s]", buffer);
+ goto error;
+ }
+
+ fd = orb_advertise_multi_queue_persist(sensor_gen->obj.meta,
+ data, &sensor_gen->obj.instance, 1);
+ if (fd < 0)
+ {
+ uorbinfo_raw("Fake orb advertise failed[%d]!", fd);
+ goto error;
+ }
+
+ interval = topic_rate ? (1000000 / topic_rate) : 500000;
+
+ for (i = 0; i < nb_cycle; ++i)
+ {
+ *(uint64_t *)data = orb_absolute_time();
+ if (OK != orb_publish(sensor_gen->obj.meta, fd, data))
+ {
+ uorbinfo_raw("Topic publish error!");
+ goto error;
+ }
+
+ nxsig_usleep(interval);
+ }
+
+ kmm_free(data);
Review Comment:
merge, return ret?
##########
system/uorb/generator.c:
##########
@@ -0,0 +1,391 @@
+/****************************************************************************
+ * apps/system/uorb/generator.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/signal.h>
+#include <nuttx/streams.h>
+
+#include <ctype.h>
+#include <uORB/uORB.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define GENERATOR_CACHE_BUFF 4096
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sensor_gen_info_s
+{
+ struct orb_object obj;
+ FAR FILE *file;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_should_exit = false;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static void usage(void)
+{
+ uorbinfo_raw("\n\
+The tool publishes topic data via uorb.\n\
+Notice:NSH_LINELEN must be set to 128 or more.\n\
+\n\
+generator <command> [arguments...]\n\
+ Commands:\n\
+\t<topics_name> The playback topic name.\n\
+\t[-h ] Listener commands help.\n\
+\t[-f <val> ] File path to be played back(absolute path).\n\
+\t[-n <val> ] Number of playbacks(fake model), default: 1\n\
+\t[-r <val> ] The rate for playing fake data is only valid\
+ when parameter 's' is used. default:10hz.\n\
+\t[-s <val> ] Playback fake data.\n\
+\t[-t <val> ] Playback topic.\n\
+\t e.g.:\n\
+\t\tsim - sensor_accel0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_accel0 timestamp:23191100,\
+x:0.1,y:9.7,z:0.81,temperature:22.15\n\n\
+\t\tsim - sensor_baro0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_baro0 timestamp:23191100,\
+pressure:999.12,temperature:26.34\n\n\
+\t\tfies - sensor_accel1\n\
+\t\t uorb_generator -f /data/uorb/20240823061723/sensor_accel0.csv\
+ -t sensor_accel1\
+\t\t\n\
+ ");
+}
+
+static void exit_handler(int signo)
+{
+ g_should_exit = true;
+}
+
+static int get_play_orb_id(FAR const char *filter,
+ FAR struct sensor_gen_info_s *info)
+{
+ struct orb_object object;
+
+ if (filter)
+ {
+ object.meta = orb_get_meta(filter);
+ if (object.meta == NULL)
+ {
+ uorbinfo_raw("Input error built-in name:[%s]", filter);
+ return ERROR;
+ }
+
+ object.instance = 0;
+ if (isdigit(filter[strlen(filter) - 1]))
+ {
+ object.instance = filter[strlen(filter) - 1] - '0';
+ }
+
+ info->obj = object;
+ return OK;
+ }
+
+ uorbinfo_raw("The entered built-in topic name is empty.");
+ return ERROR;
+}
+
+/****************************************************************************
+ * Name: replay_worker
+ *
+ * Description:
+ * Playback data files.
+ *
+ * Input Parameters:
+ * sensor_gen Generator objects.
+ *
+ * Returned Value:
+ * 0 on success, otherwise -1
+ ****************************************************************************/
+
+static int replay_worker(FAR struct sensor_gen_info_s *sensor_gen)
+{
+ struct lib_meminstream_s meminstream;
+ bool is_frist = true;
+ uint64_t last_time;
+ uint64_t tmp_time;
+ FAR uint8_t *data;
+ FAR char *line;
+ int sleep_time;
+ int lastc;
+ int ret;
+ int fd;
+
+ line = kmm_zalloc(GENERATOR_CACHE_BUFF);
+ if (line == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ if (fgets(line, GENERATOR_CACHE_BUFF, sensor_gen->file) != NULL)
+ {
+ if (strstr(line, sensor_gen->obj.meta->o_name) == NULL)
+ {
+ uorbinfo_raw("Topic and file do not match!");
+ return -EINVAL;
+ }
+ }
+ else
+ {
+ uorbinfo_raw("Playback file format error!");
+ return -EINVAL;
+ }
+
+ data = kmm_zalloc(sensor_gen->obj.meta->o_size);
+ if (data == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ fd = orb_advertise_multi_queue_persist(sensor_gen->obj.meta,
+ data, &sensor_gen->obj.instance, 1);
+ if (fd < 0)
+ {
+ uorbinfo_raw("Playback orb advertise failed[%d]!", fd);
+ kmm_free(data);
Review Comment:
ditto
##########
system/uorb/generator.c:
##########
@@ -0,0 +1,391 @@
+/****************************************************************************
+ * apps/system/uorb/generator.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/signal.h>
+#include <nuttx/streams.h>
+
+#include <ctype.h>
+#include <uORB/uORB.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define GENERATOR_CACHE_BUFF 4096
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sensor_gen_info_s
+{
+ struct orb_object obj;
+ FAR FILE *file;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_should_exit = false;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static void usage(void)
+{
+ uorbinfo_raw("\n\
+The tool publishes topic data via uorb.\n\
+Notice:NSH_LINELEN must be set to 128 or more.\n\
+\n\
+generator <command> [arguments...]\n\
+ Commands:\n\
+\t<topics_name> The playback topic name.\n\
+\t[-h ] Listener commands help.\n\
+\t[-f <val> ] File path to be played back(absolute path).\n\
+\t[-n <val> ] Number of playbacks(fake model), default: 1\n\
+\t[-r <val> ] The rate for playing fake data is only valid\
+ when parameter 's' is used. default:10hz.\n\
+\t[-s <val> ] Playback fake data.\n\
+\t[-t <val> ] Playback topic.\n\
+\t e.g.:\n\
+\t\tsim - sensor_accel0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_accel0 timestamp:23191100,\
+x:0.1,y:9.7,z:0.81,temperature:22.15\n\n\
+\t\tsim - sensor_baro0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_baro0 timestamp:23191100,\
+pressure:999.12,temperature:26.34\n\n\
+\t\tfies - sensor_accel1\n\
+\t\t uorb_generator -f /data/uorb/20240823061723/sensor_accel0.csv\
+ -t sensor_accel1\
+\t\t\n\
+ ");
+}
+
+static void exit_handler(int signo)
+{
+ g_should_exit = true;
+}
+
+static int get_play_orb_id(FAR const char *filter,
+ FAR struct sensor_gen_info_s *info)
+{
+ struct orb_object object;
+
+ if (filter)
+ {
+ object.meta = orb_get_meta(filter);
+ if (object.meta == NULL)
+ {
+ uorbinfo_raw("Input error built-in name:[%s]", filter);
+ return ERROR;
+ }
+
+ object.instance = 0;
+ if (isdigit(filter[strlen(filter) - 1]))
+ {
+ object.instance = filter[strlen(filter) - 1] - '0';
+ }
+
+ info->obj = object;
+ return OK;
+ }
+
+ uorbinfo_raw("The entered built-in topic name is empty.");
+ return ERROR;
+}
+
+/****************************************************************************
+ * Name: replay_worker
+ *
+ * Description:
+ * Playback data files.
+ *
+ * Input Parameters:
+ * sensor_gen Generator objects.
+ *
+ * Returned Value:
+ * 0 on success, otherwise -1
+ ****************************************************************************/
+
+static int replay_worker(FAR struct sensor_gen_info_s *sensor_gen)
+{
+ struct lib_meminstream_s meminstream;
+ bool is_frist = true;
+ uint64_t last_time;
+ uint64_t tmp_time;
+ FAR uint8_t *data;
+ FAR char *line;
+ int sleep_time;
+ int lastc;
+ int ret;
+ int fd;
+
+ line = kmm_zalloc(GENERATOR_CACHE_BUFF);
+ if (line == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ if (fgets(line, GENERATOR_CACHE_BUFF, sensor_gen->file) != NULL)
+ {
+ if (strstr(line, sensor_gen->obj.meta->o_name) == NULL)
+ {
+ uorbinfo_raw("Topic and file do not match!");
+ return -EINVAL;
+ }
+ }
+ else
+ {
+ uorbinfo_raw("Playback file format error!");
+ return -EINVAL;
+ }
+
+ data = kmm_zalloc(sensor_gen->obj.meta->o_size);
+ if (data == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ fd = orb_advertise_multi_queue_persist(sensor_gen->obj.meta,
+ data, &sensor_gen->obj.instance, 1);
+ if (fd < 0)
+ {
+ uorbinfo_raw("Playback orb advertise failed[%d]!", fd);
+ kmm_free(data);
+ return fd;
+ }
+
+ while (fgets(line, GENERATOR_CACHE_BUFF, sensor_gen->file) != NULL)
+ {
+ lib_meminstream(&meminstream, line, GENERATOR_CACHE_BUFF);
+ ret = lib_bscanf(&meminstream.common, &lastc,
+ sensor_gen->obj.meta->o_format, data);
+ if (ret >= 0)
+ {
+ tmp_time = *(uint64_t *)data;
+ if (is_frist)
+ {
+ last_time = *(uint64_t *)data;
+ is_frist = false;
+ }
+ else
+ {
+ sleep_time = tmp_time - last_time;
+ if (sleep_time > 0)
+ {
+ nxsig_usleep(sleep_time);
+ }
+
+ last_time = tmp_time;
+ }
+
+ if (OK != orb_publish(sensor_gen->obj.meta, fd, data))
+ {
+ uorbinfo_raw("Topic publish error!");
+ break;
+ }
+ }
+ else
+ {
+ uorbinfo_raw("[ignore] The text data for this line is wrong![%s]!",
+ line);
+ }
+ }
+
+ orb_unadvertise(fd);
+ kmm_free(data);
+ return 0;
+}
+
+/****************************************************************************
+ * Name: fake_worker
+ *
+ * Description:
+ * Publish fake data.
+ *
+ * Input Parameters:
+ * sensor_gen Generator objects.
+ * nb_cycle Number of publications.
+ * topic_rate Publish frequency.
+ * buffer String data to publish.
+ *
+ * Returned Value:
+ * 0 on success, otherwise -1
+ ****************************************************************************/
+
+static int fake_worker(FAR struct sensor_gen_info_s *sensor_gen,
+ int nb_cycle, float topic_rate, FAR char *buffer)
+{
+ struct lib_meminstream_s meminstream;
+ FAR uint8_t *data;
+ uint64_t interval;
+ int lastc;
+ int fd;
+ int i;
+
+ if (buffer == NULL)
+ {
+ return -EINVAL;
+ }
+
+ data = kmm_zalloc(sensor_gen->obj.meta->o_size);
Review Comment:
```suggestion
data = zalloc(sensor_gen->obj.meta->o_size);
```
##########
system/uorb/generator.c:
##########
@@ -0,0 +1,391 @@
+/****************************************************************************
+ * apps/system/uorb/generator.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/signal.h>
+#include <nuttx/streams.h>
+
+#include <ctype.h>
+#include <uORB/uORB.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define GENERATOR_CACHE_BUFF 4096
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sensor_gen_info_s
+{
+ struct orb_object obj;
+ FAR FILE *file;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_should_exit = false;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static void usage(void)
+{
+ uorbinfo_raw("\n\
+The tool publishes topic data via uorb.\n\
+Notice:NSH_LINELEN must be set to 128 or more.\n\
+\n\
+generator <command> [arguments...]\n\
+ Commands:\n\
+\t<topics_name> The playback topic name.\n\
+\t[-h ] Listener commands help.\n\
+\t[-f <val> ] File path to be played back(absolute path).\n\
+\t[-n <val> ] Number of playbacks(fake model), default: 1\n\
+\t[-r <val> ] The rate for playing fake data is only valid\
+ when parameter 's' is used. default:10hz.\n\
+\t[-s <val> ] Playback fake data.\n\
+\t[-t <val> ] Playback topic.\n\
+\t e.g.:\n\
+\t\tsim - sensor_accel0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_accel0 timestamp:23191100,\
+x:0.1,y:9.7,z:0.81,temperature:22.15\n\n\
+\t\tsim - sensor_baro0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_baro0 timestamp:23191100,\
+pressure:999.12,temperature:26.34\n\n\
+\t\tfies - sensor_accel1\n\
+\t\t uorb_generator -f /data/uorb/20240823061723/sensor_accel0.csv\
+ -t sensor_accel1\
+\t\t\n\
+ ");
+}
+
+static void exit_handler(int signo)
+{
+ g_should_exit = true;
+}
+
+static int get_play_orb_id(FAR const char *filter,
+ FAR struct sensor_gen_info_s *info)
+{
+ struct orb_object object;
+
+ if (filter)
+ {
+ object.meta = orb_get_meta(filter);
+ if (object.meta == NULL)
+ {
+ uorbinfo_raw("Input error built-in name:[%s]", filter);
+ return ERROR;
+ }
+
+ object.instance = 0;
+ if (isdigit(filter[strlen(filter) - 1]))
+ {
+ object.instance = filter[strlen(filter) - 1] - '0';
+ }
+
+ info->obj = object;
+ return OK;
+ }
+
+ uorbinfo_raw("The entered built-in topic name is empty.");
+ return ERROR;
+}
+
+/****************************************************************************
+ * Name: replay_worker
+ *
+ * Description:
+ * Playback data files.
+ *
+ * Input Parameters:
+ * sensor_gen Generator objects.
+ *
+ * Returned Value:
+ * 0 on success, otherwise -1
+ ****************************************************************************/
+
+static int replay_worker(FAR struct sensor_gen_info_s *sensor_gen)
+{
+ struct lib_meminstream_s meminstream;
+ bool is_frist = true;
+ uint64_t last_time;
+ uint64_t tmp_time;
+ FAR uint8_t *data;
+ FAR char *line;
+ int sleep_time;
+ int lastc;
+ int ret;
+ int fd;
+
+ line = kmm_zalloc(GENERATOR_CACHE_BUFF);
Review Comment:
ditto
##########
system/uorb/generator.c:
##########
@@ -0,0 +1,391 @@
+/****************************************************************************
+ * apps/system/uorb/generator.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/signal.h>
+#include <nuttx/streams.h>
+
+#include <ctype.h>
+#include <uORB/uORB.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define GENERATOR_CACHE_BUFF 4096
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct sensor_gen_info_s
+{
+ struct orb_object obj;
+ FAR FILE *file;
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_should_exit = false;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static void usage(void)
+{
+ uorbinfo_raw("\n\
+The tool publishes topic data via uorb.\n\
+Notice:NSH_LINELEN must be set to 128 or more.\n\
+\n\
+generator <command> [arguments...]\n\
+ Commands:\n\
+\t<topics_name> The playback topic name.\n\
+\t[-h ] Listener commands help.\n\
+\t[-f <val> ] File path to be played back(absolute path).\n\
+\t[-n <val> ] Number of playbacks(fake model), default: 1\n\
+\t[-r <val> ] The rate for playing fake data is only valid\
+ when parameter 's' is used. default:10hz.\n\
+\t[-s <val> ] Playback fake data.\n\
+\t[-t <val> ] Playback topic.\n\
+\t e.g.:\n\
+\t\tsim - sensor_accel0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_accel0 timestamp:23191100,\
+x:0.1,y:9.7,z:0.81,temperature:22.15\n\n\
+\t\tsim - sensor_baro0:\n\
+\t\t uorb_generator -n 100 -r 5 -s -t sensor_baro0 timestamp:23191100,\
+pressure:999.12,temperature:26.34\n\n\
+\t\tfies - sensor_accel1\n\
+\t\t uorb_generator -f /data/uorb/20240823061723/sensor_accel0.csv\
+ -t sensor_accel1\
+\t\t\n\
+ ");
+}
+
+static void exit_handler(int signo)
+{
+ g_should_exit = true;
+}
+
+static int get_play_orb_id(FAR const char *filter,
+ FAR struct sensor_gen_info_s *info)
+{
+ struct orb_object object;
+
+ if (filter)
+ {
+ object.meta = orb_get_meta(filter);
+ if (object.meta == NULL)
+ {
+ uorbinfo_raw("Input error built-in name:[%s]", filter);
+ return ERROR;
+ }
+
+ object.instance = 0;
+ if (isdigit(filter[strlen(filter) - 1]))
+ {
+ object.instance = filter[strlen(filter) - 1] - '0';
+ }
+
+ info->obj = object;
+ return OK;
+ }
+
+ uorbinfo_raw("The entered built-in topic name is empty.");
+ return ERROR;
+}
+
+/****************************************************************************
+ * Name: replay_worker
+ *
+ * Description:
+ * Playback data files.
+ *
+ * Input Parameters:
+ * sensor_gen Generator objects.
+ *
+ * Returned Value:
+ * 0 on success, otherwise -1
+ ****************************************************************************/
+
+static int replay_worker(FAR struct sensor_gen_info_s *sensor_gen)
+{
+ struct lib_meminstream_s meminstream;
+ bool is_frist = true;
+ uint64_t last_time;
+ uint64_t tmp_time;
+ FAR uint8_t *data;
+ FAR char *line;
+ int sleep_time;
+ int lastc;
+ int ret;
+ int fd;
+
+ line = kmm_zalloc(GENERATOR_CACHE_BUFF);
+ if (line == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ if (fgets(line, GENERATOR_CACHE_BUFF, sensor_gen->file) != NULL)
+ {
+ if (strstr(line, sensor_gen->obj.meta->o_name) == NULL)
+ {
+ uorbinfo_raw("Topic and file do not match!");
+ return -EINVAL;
+ }
+ }
+ else
+ {
+ uorbinfo_raw("Playback file format error!");
+ return -EINVAL;
+ }
+
+ data = kmm_zalloc(sensor_gen->obj.meta->o_size);
+ if (data == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ fd = orb_advertise_multi_queue_persist(sensor_gen->obj.meta,
+ data, &sensor_gen->obj.instance, 1);
+ if (fd < 0)
+ {
+ uorbinfo_raw("Playback orb advertise failed[%d]!", fd);
+ kmm_free(data);
+ return fd;
+ }
+
+ while (fgets(line, GENERATOR_CACHE_BUFF, sensor_gen->file) != NULL)
+ {
+ lib_meminstream(&meminstream, line, GENERATOR_CACHE_BUFF);
+ ret = lib_bscanf(&meminstream.common, &lastc,
+ sensor_gen->obj.meta->o_format, data);
+ if (ret >= 0)
+ {
+ tmp_time = *(uint64_t *)data;
+ if (is_frist)
+ {
+ last_time = *(uint64_t *)data;
+ is_frist = false;
+ }
+ else
+ {
+ sleep_time = tmp_time - last_time;
+ if (sleep_time > 0)
+ {
+ nxsig_usleep(sleep_time);
+ }
+
+ last_time = tmp_time;
+ }
+
+ if (OK != orb_publish(sensor_gen->obj.meta, fd, data))
+ {
+ uorbinfo_raw("Topic publish error!");
+ break;
+ }
+ }
+ else
+ {
+ uorbinfo_raw("[ignore] The text data for this line is wrong![%s]!",
+ line);
+ }
+ }
+
+ orb_unadvertise(fd);
+ kmm_free(data);
+ return 0;
+}
+
+/****************************************************************************
+ * Name: fake_worker
+ *
+ * Description:
+ * Publish fake data.
+ *
+ * Input Parameters:
+ * sensor_gen Generator objects.
+ * nb_cycle Number of publications.
+ * topic_rate Publish frequency.
+ * buffer String data to publish.
+ *
+ * Returned Value:
+ * 0 on success, otherwise -1
+ ****************************************************************************/
+
+static int fake_worker(FAR struct sensor_gen_info_s *sensor_gen,
+ int nb_cycle, float topic_rate, FAR char *buffer)
+{
+ struct lib_meminstream_s meminstream;
+ FAR uint8_t *data;
+ uint64_t interval;
+ int lastc;
+ int fd;
+ int i;
+
+ if (buffer == NULL)
+ {
+ return -EINVAL;
+ }
+
+ data = kmm_zalloc(sensor_gen->obj.meta->o_size);
+ if (data == NULL)
+ {
+ return -ENOMEM;
+ }
+
+ lib_meminstream(&meminstream, buffer, strlen(buffer));
+ if (lib_bscanf(&meminstream.common, &lastc,
+ sensor_gen->obj.meta->o_format, data) < 0)
+ {
+ uorbinfo_raw("Input string data parsing error![%s]", buffer);
+ goto error;
+ }
+
+ fd = orb_advertise_multi_queue_persist(sensor_gen->obj.meta,
+ data, &sensor_gen->obj.instance, 1);
+ if (fd < 0)
+ {
+ uorbinfo_raw("Fake orb advertise failed[%d]!", fd);
+ goto error;
+ }
+
+ interval = topic_rate ? (1000000 / topic_rate) : 500000;
+
+ for (i = 0; i < nb_cycle; ++i)
+ {
+ *(uint64_t *)data = orb_absolute_time();
+ if (OK != orb_publish(sensor_gen->obj.meta, fd, data))
+ {
+ uorbinfo_raw("Topic publish error!");
+ goto error;
+ }
+
+ nxsig_usleep(interval);
+ }
+
+ kmm_free(data);
+ return 0;
+
+error:
+ kmm_free(data);
+ return -1;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+int main(int argc, FAR char *argv[])
+{
+ FAR struct sensor_gen_info_s sensor_tmp;
Review Comment:
```suggestion
struct sensor_gen_info_s sensor_tmp;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] uorb: add generator tool. [nuttx-apps]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #3214:
URL: https://github.com/apache/nuttx-apps/pull/3214#issuecomment-3552259082
@Donny9 I think @Otpvondoiats closed the PR before get it merged and removed the branch, so it is impossible to review
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] uorb: add generator tool. [nuttx-apps]
Posted by "Donny9 (via GitHub)" <gi...@apache.org>.
Donny9 commented on PR #3214:
URL: https://github.com/apache/nuttx-apps/pull/3214#issuecomment-3551337574
link issue: https://github.com/apache/nuttx/issues/17343 @acassis please review~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] uorb: add generator tool. [nuttx-apps]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #3214:
URL: https://github.com/apache/nuttx-apps/pull/3214#issuecomment-3557567314
> > @Otpvondoiats you don't need to close the PR to fix the issues in the review, just create a new PR with modifications and use "git rebase -i HEAD~2" to squash it and "git push -f" to force a push to replace the older commit in the repo.
> > This process is explained here: https://nuttx.apache.org/docs/latest/contributing/making-changes.html#how-to-include-the-suggestions-on-your-pull-request
>
> The reason I closed this PR is that I plan to merge these two submissions into one. Donny9 suggested I keep these, but my own repository branch for the for loop has been deleted, so there will be two PR.
Thank you for explanation. It is a good practice to add the reason the PR was closed, it avoid confusion like in the case of nxinit closed PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] uorb: add generator tool. [nuttx-apps]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #3214:
URL: https://github.com/apache/nuttx-apps/pull/3214#issuecomment-3554385704
@Otpvondoiats you don't need to close the PR to fix the issues in the review, just create a new PR with modifications and use "git rebase -i HEAD~2" to squash it and "git push -f" to force a push to replace the older commit in the repo.
This process is explained here: https://nuttx.apache.org/docs/latest/contributing/making-changes.html#how-to-include-the-suggestions-on-your-pull-request
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] uorb: add generator tool. [nuttx-apps]
Posted by "Otpvondoiats (via GitHub)" <gi...@apache.org>.
Otpvondoiats commented on PR #3214:
URL: https://github.com/apache/nuttx-apps/pull/3214#issuecomment-3557521905
> @Otpvondoiats you don't need to close the PR to fix the issues in the review, just create a new PR with modifications and use "git rebase -i HEAD~2" to squash it and "git push -f" to force a push to replace the older commit in the repo.
>
> This process is explained here: https://nuttx.apache.org/docs/latest/contributing/making-changes.html#how-to-include-the-suggestions-on-your-pull-request
The reason I closed this PR is that I plan to merge these two submissions into one. Donny9 suggested I keep these, but my own repository branch for the for loop has been deleted, so there will be two PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] uorb: add generator tool. [nuttx-apps]
Posted by "Otpvondoiats (via GitHub)" <gi...@apache.org>.
Otpvondoiats closed pull request #3214: uorb: add generator tool.
URL: https://github.com/apache/nuttx-apps/pull/3214
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org