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

Eliminate write(c) from UARTDrivers #12643

Closed

Conversation

peterbarker
Copy link
Contributor

This is cleanup I've wanted to do for a while.

This seems to be a leftover from our APM days; who would want to write char-at-a-time if they could avoid it?

Well, that was partly rhetorical; snprintf does, so this may make snprintf marginally slower. I've put a patch in which should spit out the %s-replaced strings in one shot, 'though. There are other optimisations available in there - e.g. remembering the start of a chunk of bytes to send through from the format string with a write(...) call; basically anything which loops around write(c)

This also fixes a bug with the existing Linux UARTDriver where you can't actually send out a bunch of bytes to the console. I will be creating a second, simpler PR to fix that in case this one has problems going in (and to highlight where the problem is).

@peterbarker peterbarker force-pushed the pr/eliminate-char-write branch 2 times, most recently from 589c534 to aa9ebc4 Compare October 25, 2019 13:42
@lucasdemarchi
Copy link
Contributor

On a quick look this seems good to me

Copy link
Contributor

@WickedShell WickedShell left a comment

Choose a reason for hiding this comment

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

Not even remotely a real review, just posting the comment.

libraries/AP_HAL/Util.cpp Show resolved Hide resolved
@peterbarker
Copy link
Contributor Author

I've tested this on a Pixhawk and things seem to work as expected.

@rmackay9
Copy link
Contributor

As discussed on the dev call we will leave this one for @tridge to review before merging.

@peterbarker peterbarker deleted the pr/eliminate-char-write branch January 21, 2020 03:41
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.

None yet

6 participants