Skip to content
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

Add loopback test example #69

Merged
merged 2 commits into from
Dec 6, 2022
Merged

Conversation

mlsvrts
Copy link
Contributor

@mlsvrts mlsvrts commented Nov 7, 2022

This example performs a loopback test using real hardware ports

Additionally, some data will be collected and logged during the test to provide some
rudimentary benchmarking information. When 'split-port' is specified, the serial port will be split into two channels that read/write "simultaneously" from multiple threads.

You can also provide the length (in bytes) of data to test with, and the number of iterations to perform or a list of raw bytes to transmit.

To run this example:

  1. cargo run --example loopback /dev/ttyUSB0
  2. cargo run --example loopback /dev/ttyUSB0 --split-port
  3. cargo run --example loopback /dev/ttyUSB0 -i 100 -l 32 -b 9600
  4. cargo run --example loopback /dev/ttyUSB8 --bytes 222,173,190,239

@mlsvrts mlsvrts mentioned this pull request Nov 7, 2022
Adds a new example with support for running loopback tests on a port and
printing some timing statistics. Loopback test supports running in
split or standard serial port modes, and specifiying the data and iterations
of test to perform.

Signed-off-by: mlsvrts <[email protected]>
Copy link
Member

@jessebraham jessebraham left a comment

Choose a reason for hiding this comment

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

Thank you for the PR, sorry for the delay in getting to this!

It looks good to me overall, however in its current state we get a panic when running due to both baudrate and bytes using -b as their short flag; removing short from one of these options gets the example to a working state.

Could you please just make that one fix (I removed short from --bytes but it probably doesn't matter too much)? After that we can get this merged.

Supporting '-b' for both 'bytes' and 'baudrate' could cause a collision,
this update prevents the issue.

Signed-off-by: mlsvrts <[email protected]>
@mlsvrts
Copy link
Contributor Author

mlsvrts commented Dec 4, 2022

Could you please just make that one fix (I removed short from --bytes but it probably doesn't matter too much)? After that we can get this merged.

Done!

Copy link
Member

@jessebraham jessebraham left a comment

Choose a reason for hiding this comment

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

Thanks!

@jessebraham jessebraham merged commit 5abb165 into serialport:main Dec 6, 2022
sirhcel pushed a commit to sirhcel/serialport-rs that referenced this pull request May 10, 2023
* Add a loopback test example

Adds a new example with support for running loopback tests on a port and
printing some timing statistics. Loopback test supports running in
split or standard serial port modes, and specifiying the data and iterations
of test to perform.

Signed-off-by: mlsvrts <[email protected]>

* Remove 'short' from loopback test 'bytes' argument.

Supporting '-b' for both 'bytes' and 'baudrate' could cause a collision,
this update prevents the issue.

Signed-off-by: mlsvrts <[email protected]>

Signed-off-by: mlsvrts <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants