Skip to content

Conversation

@Otpvondoiats
Copy link
Contributor

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

    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

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data = kmm_zalloc(sensor_gen->obj.meta->o_size);
data = malloc(sensor_gen->obj.meta->o_size);

}

orb_unadvertise(fd);
kmm_free(data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
kmm_free(data);
free(data);

int ret;
int fd;

line = kmm_zalloc(GENERATOR_CACHE_BUFF);
Copy link
Contributor

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);
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data = kmm_zalloc(sensor_gen->obj.meta->o_size);
data = zalloc(sensor_gen->obj.meta->o_size);

nxsig_usleep(interval);
}

kmm_free(data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge, return ret?

@Donny9
Copy link
Contributor

Donny9 commented Nov 19, 2025

link issue: apache/nuttx#17343 @acassis please review~

@Donny9 Donny9 requested a review from acassis November 19, 2025 08:10
@Otpvondoiats Otpvondoiats deleted the lk_gen branch November 19, 2025 08:46
@acassis
Copy link
Contributor

acassis commented Nov 19, 2025

@Donny9 I think @Otpvondoiats closed the PR before get it merged and removed the branch, so it is impossible to review

@acassis
Copy link
Contributor

acassis commented Nov 19, 2025

@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

@Otpvondoiats
Copy link
Contributor Author

@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.

@acassis
Copy link
Contributor

acassis commented Nov 20, 2025

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants