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

Fixed read timeout checks, added timeout parameter #7

Merged
merged 2 commits into from
Jun 6, 2023
Merged

Fixed read timeout checks, added timeout parameter #7

merged 2 commits into from
Jun 6, 2023

Conversation

gsokoll
Copy link
Contributor

@gsokoll gsokoll commented May 21, 2023

The QBaseSerialWitmotionSensorReader::ReadData() function performs a check to detect if no data has been received for a period of time. Specifically, it checks whether the number of bytes currently available from the serial stream is the same as the number of bytes available on the previous call to the function, and if this occurs several times it raises an error.

However the logic of this check is incorrect - the number of bytes available now and in the past is not an indication of the absence of data. The code has been amended to check whether there are ZERO bytes available on the serial stream, and if this occurs over a specified timeout period, it raises an error.

The timeout period has been added as a parameter also.

@twdragon
Copy link
Collaborator

@gsokoll this PR seemed to copy a lot of commits. Please rebase the PR to start the review without including the previous commits which are not made by you

@gsokoll
Copy link
Contributor Author

gsokoll commented May 28, 2023

I had made the PR against "master" instead of "main" branch. Fixed now. Can you perhaps delete the old master branch also?

@gsokoll gsokoll changed the base branch from master to main May 29, 2023 00:08
@twdragon
Copy link
Collaborator

@gsokoll I agreed with my colleagues to keep it for historical purposes. However, thanks for rebasing. I will need some time to review the changes.

@twdragon twdragon self-requested a review May 29, 2023 10:36
@twdragon
Copy link
Collaborator

twdragon commented Jun 5, 2023

@gsokoll did you see the changes I listed here?

@gsokoll
Copy link
Contributor Author

gsokoll commented Jun 6, 2023

@gsokoll did you see the changes I listed here?

No, I don't see any changes. Where were they made??

@twdragon
Copy link
Collaborator

twdragon commented Jun 6, 2023

@gsokoll I meant the review I opened before. Please let's resolve it before merging

@gsokoll
Copy link
Contributor Author

gsokoll commented Jun 6, 2023

Sorry I'm not very familiar with github review process. Looks like only you can review the PR?
image

@twdragon
Copy link
Collaborator

twdragon commented Jun 6, 2023

@gsokoll no, everything is fine. We should just resolve the discussion on the line I started here, after that I will merge the PR. I am just kindly asking you if you consider keeping the existing behaviour of the node if the timeout is not specified.

@gsokoll
Copy link
Contributor Author

gsokoll commented Jun 6, 2023

Sorry I am still missing something. I do not see any comments in the "Files changed" tab.

@twdragon
Copy link
Collaborator

twdragon commented Jun 6, 2023

img

Please refer here, just above

@gsokoll
Copy link
Contributor Author

gsokoll commented Jun 6, 2023

Ah, ok. I think I can't see your comments because they are still Pending (https://github.com/orgs/community/discussions/10369) ?

But in reply to your question about retaining the repeat-counting check if timeout is not specified:
when I was testing the PR code, I found that specifying the timeout as zero (hence having the function ignore timeout events) was quite useful. I could physically disconnect the IMU from the serial cable, and then reconnect it, and your library would continue working nicely and ROS messages would start again. I can see situations where for reliability, the user would prefer code that can tolerate interruptions and continues once the problem goes away, rather than exit with an error.

I did include a default timeout value of 1000 ms, which is probably too long for most people. It can certainly be changed to something smaller (like 100 ms).

One alternative may be to set a default timeout period to 3 times the polling interval? Then, if the user does not specify timeout explicitly, use this default value. This may be a bit messy to implement though.

@gsokoll
Copy link
Contributor Author

gsokoll commented Jun 6, 2023

Have made changes to check for a user-defined timeout. If no timeout defined, then defaults to timeout equal to 3 times the polling interval which should replicate the previous repeat-count check approach.

@twdragon
Copy link
Collaborator

twdragon commented Jun 6, 2023

@thank you a lot! Great contribution! I will merge the PR very soon

@twdragon twdragon merged commit 5c2e86d into ElettraSciComp:main Jun 6, 2023
twdragon added a commit to ElettraSciComp/witmotion_IMU_ros that referenced this pull request Jun 14, 2023
Added data timeout parameter for port after [improvement](ElettraSciComp/witmotion_IMU_QT#7) of the underlying library
twdragon added a commit to ElettraSciComp/witmotion_IMU_ros that referenced this pull request Jun 14, 2023
	- Added support for serial port timeout behaviour (`timeout_ms`)
	- Updated README.md
	- Merged pull request #27
	- Version bump to 1.3.0
	- Matched versions for ROS node and underlying library after
	  merging pull request
	  ElettraSciComp/witmotion_IMU_QT#7
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