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

Open
wants to merge 9 commits into
base: master
from

Conversation

@peterbarker
Copy link
Contributor

peterbarker commented Oct 24, 2019

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 peterbarker:pr/eliminate-char-write branch 2 times, most recently from 589c534 to aa9ebc4 Oct 25, 2019
@peterbarker peterbarker force-pushed the peterbarker:pr/eliminate-char-write branch from aa9ebc4 to 1a4f6ad Oct 25, 2019
@lucasdemarchi

This comment has been minimized.

Copy link
Contributor

lucasdemarchi commented Oct 26, 2019

On a quick look this seems good to me

Copy link
Contributor

WickedShell left a comment

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

libraries/AP_HAL/Util.cpp Show resolved Hide resolved
@peterbarker peterbarker force-pushed the peterbarker:pr/eliminate-char-write branch from 831a550 to 1a4f6ad Oct 28, 2019
@peterbarker peterbarker force-pushed the peterbarker:pr/eliminate-char-write branch from 1a4f6ad to ecb83c7 Nov 8, 2019
@peterbarker

This comment has been minimized.

Copy link
Contributor Author

peterbarker commented Nov 9, 2019

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

@rmackay9

This comment has been minimized.

Copy link
Contributor

rmackay9 commented Nov 11, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.