Skip to content

Update readBytesUntil.adoc #697

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

Merged
merged 5 commits into from
Sep 6, 2019
Merged

Update readBytesUntil.adoc #697

merged 5 commits into from
Sep 6, 2019

Conversation

Arnold-n
Copy link
Contributor

As a side note, a function readBytesTill() which also copies the supplied terminator into the array (assuming it fits) would be convenient to add as it does allow to distinguish a time-out from a termination detection.

As a side note, a function readBytesTill() which also copies the supplied terminator into the array (assuming it fits) would be convenient to add as it does allow to distinguish a time-out from a termination detection.
Added note that millis()/timer0 is being used.
@@ -49,7 +49,7 @@ Data type: `size_t`.

[float]
=== Notes and Warnings
The terminator character is discarded from the serial buffer.
The terminator character is discarded from the serial buffer, unless the return value equals `length`. If the return value is less than `length`, it cannot be determined whether this is due to a time-out or due to the detection of the supplied terminator. This function relies on millis() which uses timer0's overflow interrupt.
Copy link
Collaborator

Choose a reason for hiding this comment

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

unless the return value equals `length`. 

I think this is a reasonable clarification to add to the documentation, but the approach of talking about the return value made it a bit hard for me to understand when I put my "beginner glasses" on. I think it can be reworded to be more clear.

What do you think about this:

unless the number of characters read equals length.


If the return value is less than `length`, it cannot be determined whether this is due to a time-out or due to the detection of the supplied terminator.

I feel that this information is already provided by the main description:

The function terminates if the terminator character is detected, the determined length has been read, or it times out


This function relies on millis() which uses timer0's overflow interrupt.

Is this true for all architectures officially supported by Arduino?:

We need to be careful to not assume that Arduino == AVR because it's much more than that. However, we don't need to worry about covering 3rd party cores in the Arduino Language Reference. It is the responsibility of their authors to document where there are differences from the official Arduino documentation.

@Arnold-n
Copy link
Contributor Author

Arnold-n commented Sep 5, 2019

@per1234, I made some further changes for your consideration: the meaning of a returned 0 has been corrected, and the functional description has been improved by connecting two lines to indicate that "returns the characters up to the last character before the supplied terminator" only applies in case the supplied terminator was detected - it does not necessarily apply to a time out situation or a length limit detection.

@Arnold-n Arnold-n requested a review from per1234 September 5, 2019 20:02

`Serial.readBytesUntil()` returns the number of characters read into the buffer. A 0 means no valid data was found.
`Serial.readBytesUntil()` returns the number of characters read into the buffer. A 0 means that supplied length < = 0, or that a time out occured or a termination character was found before any other input.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
`Serial.readBytesUntil()` returns the number of characters read into the buffer. A 0 means that supplied length < = 0, or that a time out occured or a termination character was found before any other input.
`Serial.readBytesUntil()` returns the number of characters read into the buffer. A 0 means that the `length` parameter <= 0, a time out occurred, or a termination character was found before any other input.

@Arnold-n Arnold-n requested a review from per1234 September 6, 2019 06:02
@per1234 per1234 merged commit 1e29ea8 into arduino:master Sep 6, 2019
@per1234
Copy link
Collaborator

per1234 commented Sep 6, 2019

Thanks so much @Arnold-n!

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.

2 participants