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

AP_Proximity: avoid use of int16_t-read call #27445

Closed

Conversation

peterbarker
Copy link
Contributor

@peterbarker peterbarker commented Jul 4, 2024

Tested in SITL using gdb and the simulated devices

@peterbarker peterbarker force-pushed the pr/int16-t-lifghtwaresf45b branch from 2948c2f to e654096 Compare July 4, 2024 01:17
int16_t c = _uart->read();
if (c==-1) {
return false;
for (auto i=0; i<INT16_MAX; i++) { // process at most n bytes
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it might make sense for this to be 1024 as well. I can imagine being hesitant to include functional changes that would require testing but what we have now is a bit dangerous.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it might make sense for this to be 1024 as well. I can imagine being hesitant to include functional changes that would require testing but what we have now is a bit dangerous.

Yes, bearing in mind I don't have the hardware to test this on :-)

INT16_MAX isn't disastrous - 32,000 iterations in here won't kill a vehicle.

Now AP_Proximity_Cygbot_D1 is a much greater concern - it's iterating up to UINT32_MAX, which will cause us to fall out of the sky. It's a good thing out UARTDriver layer is well-behaved :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

i think 1024 limit would be good

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.

4 participants