-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Print not Aborting on Write() failure #3651
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
Conversation
Print::write(const uint8_t *buffer, size_t size) and Print::print(const __FlashStringHelper *ifsh) would continue calling write(char) after a failed write(char) this behavior would render returned count unuseable see arduino/Arduino issue #3614
Hi @stickbreaker , your proposal is interesting but the code won't work with cdc serials (like Leonardo/Micro) as |
@facchinm , this fix is for the What are cdc serials? reference please :) I'll check it out. chuck |
@stickbreaker, the CDC serial (virtual serial over USB) for AVR is here: https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/CDC.cpp#L164-L191 (there is also one for SAM). @facchinm, I'm not sure what you mean with Note that this PR modifies the virtual You might want to modify your commit message to say "Closes #3614" in the last line, so the issue will be automatically closed when merging the PR. |
Sorry @stickbreaker , your solution is ok, I was blinded by the difference between |
bad transcription
Pushed as single commit as 25d81c9 |
The current 1.6.5 Print library report the total count of characters send during operations. The assumption is that this count is of contiguous characters. If you printed a buffer of 45 characters and the print command returned 44 as the number of characters sent, the assumption is that the last character was not sent. But, this is not a valid assumption. The two low level functions through which all of the helper print funtions work (
size_t Print::write(const uint8_t *buffer, size_t size)
andsize_t Print::print(const __FlashStringHelper *ifsh)
) do not exit when a write failure is detected. They just attempt to write the next character from the input buffer. This renders any positional transmit information useless.I propose to change the behavior of these two routines. When a write error is encountered these function return with the count of sent characters. If the calling procedure wants to retry sending then ~buffer[sentCount] is the next character needing to be send.
see arduino/Arduino issue #3614
Chuck Todd