Skip to content

Add missing cast to SoftwareSerial::peek() when returning buffered value #4669

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 2 commits into from
Mar 31, 2016

Conversation

sandeepmistry
Copy link
Contributor

Resolves #2858.

Prior to this, read and peek would return different values if the byte value was greater than 127.

For example, if the buffered byte was 180, read would return 180, but peek would return -76.

@sandeepmistry sandeepmistry added Library: SoftwareSerial The SoftwareSerial Arduino library feature request A request to make an enhancement (not a bug fix) labels Mar 9, 2016
@matthijskooijman
Copy link
Collaborator

I wonder if it would not be better to change the buffer to an uint8_t instead, removing the need for these casts. I don't see any reason for the buffer to use char, as it does now (even more because char is ambiguous in signedness, if is must be signed it should at least use signed char or int8_t).

@sandeepmistry
Copy link
Contributor Author

Yes, I agree. It can be changed to unsigned char (this is what HardwareSerial uses) or uint8_t. This will also slightly clean up the read method.

I'll work on this, and then update the PR.

@sandeepmistry sandeepmistry force-pushed the software-serial-peek-cast branch from 05573af to 98699df Compare March 10, 2016 15:24
@sandeepmistry
Copy link
Contributor Author

@matthijskooijman I've pushed the changes, if things look good, I will go ahead and squash the commits.

@agdl agdl merged commit a7ca976 into arduino:master Mar 31, 2016
@sandeepmistry sandeepmistry deleted the software-serial-peek-cast branch July 18, 2016 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A request to make an enhancement (not a bug fix) Library: SoftwareSerial The SoftwareSerial Arduino library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants