-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Print not aborting when Write(char) returns Error #3614
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
Comments
That looks like a nice simple fix. However is it compatible with what is already happening. I can think of one case: Maybe the class needs a toggle to 'turn on' this behavior if the return value is needed to find where the stream stopped. But the return value really only has meaning when using |
@Chris--A, This is a change that could potentially break things, though nothing comes to mind directly. @stickbreaker perhaps you could propose this change on the developer's mailing list too, see if anyone there objects? If not, it would be great if you could prepare a pullrequest with the changes (be sure to remove the old code instead of commenting it if you do). The changes proposed look good to me. Perhaps the code shouldn't have |
Nope, it is not compatible, because what it is doing now is a bug. This fixes the bug.
But, if the programmer checks the return value, it should have the expected meaning. If the return value is unknown, why return it?
How do I access this mailing list?
I can do this, but should I wait to make the pull until after the developers approve? Chuck. |
See https://www.arduino.cc/en/Main/ContactUs
Depends - having a pullrequest might make it easier to motivate your question, but it might mean a bit more work on your end if things have to be changed or end up being rejected, so that's your call :-) |
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 arduino#3614
Solved by #3651 |
the
Print::write(const uint8_t *buffer, size_t size)
andPrint::print(const __FlashStringHelper *ifsh)
continue callingwrite(char)
afterwrite(char)
has returned a 0 (zero) to mark a write failure. This creates a unexpected result when a block of characters is printed.I implemented cts/rts handshaking in
HardwareSerial
, if !cts and the tx buffer is full and a timeout has occured, theHardwareSerial::write(char)
returns 0(zero) to mark the failure. The CurrentPrint
object continues sending until the buffer has been send towrite(char)
if buffer space becomes free or cts clears, thewrite()
failed characters are lost, but the rest of the buffer is sent. SincePrint
functions returns the number of characters sent, the expectation is that if len!=sent, the last (len-sent) characters were not sent. This expectation is incorrect. With the currentPrint
library if len!=sent, there is no way to identify which character were not sent!Included is the simple fix for this problem.
Chuck Todd
The text was updated successfully, but these errors were encountered: