-
Notifications
You must be signed in to change notification settings - Fork 646
uorb: add generator tool. #3214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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 Signed-off-by: likun17 <likun17@xiaomi.com>
| return -EINVAL; | ||
| } | ||
|
|
||
| data = kmm_zalloc(sensor_gen->obj.meta->o_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| data = kmm_zalloc(sensor_gen->obj.meta->o_size); | |
| data = malloc(sensor_gen->obj.meta->o_size); |
| } | ||
|
|
||
| orb_unadvertise(fd); | ||
| kmm_free(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| kmm_free(data); | |
| free(data); |
| int ret; | ||
| int fd; | ||
|
|
||
| line = kmm_zalloc(GENERATOR_CACHE_BUFF); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
| if (fd < 0) | ||
| { | ||
| uorbinfo_raw("Playback orb advertise failed[%d]!", fd); | ||
| kmm_free(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
|
|
||
| int main(int argc, FAR char *argv[]) | ||
| { | ||
| FAR struct sensor_gen_info_s sensor_tmp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| FAR struct sensor_gen_info_s sensor_tmp; | |
| struct sensor_gen_info_s sensor_tmp; |
| return -EINVAL; | ||
| } | ||
|
|
||
| data = kmm_zalloc(sensor_gen->obj.meta->o_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| data = kmm_zalloc(sensor_gen->obj.meta->o_size); | |
| data = zalloc(sensor_gen->obj.meta->o_size); |
| nxsig_usleep(interval); | ||
| } | ||
|
|
||
| kmm_free(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge, return ret?
|
link issue: apache/nuttx#17343 @acassis please review~ |
|
@Donny9 I think @Otpvondoiats closed the PR before get it merged and removed the branch, so it is impossible to review |
|
@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. |
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 [arguments...]
Commands:
<topics_name> The playback topic name.
[-h ] Listener commands help.
[-f ] File path to be played back(absolute path).
[-n ] Number of playbacks(fake model), default: 1
[-r ] The rate for playing fake data is only valid when parameter 's' is used.
default:10hz.
[-s ] Playback fake data.
[-t ] 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
Testing
e.g.: