Skip to content

Implement Serial.available() function - #79

Closed
tanakamasayuki wants to merge 1 commit into
openwch:mainfrom
tanakamasayuki:patch-1
Closed

Implement Serial.available() function#79
tanakamasayuki wants to merge 1 commit into
openwch:mainfrom
tanakamasayuki:patch-1

Conversation

@tanakamasayuki

Copy link
Copy Markdown

-1 means if(Serial.available()) is always true.
Returns reception status.

Implement available function.
@maxint-rd

Copy link
Copy Markdown
Contributor

That's an interesting PR.
Seems like you took a much simpler approach than my convoluted attempt to reintroduce the receive buffer to enable available() and peek().
Nice!

@tanakamasayuki

Copy link
Copy Markdown
Author

https://gist.github.com/tanakamasayuki/56251790ad3c06a9837895054fd2f15e

I actually want to use reception interrupts.
It's currently being tested.

@maxint-rd

maxint-rd commented Apr 12, 2024

Copy link
Copy Markdown
Contributor

I actually want to use reception interrupts.

Excellent! I'm looking forward to do some testing of your code as soon as I can find the time.

For my I2C slave implementation I managed to enable interrupts. For enabling Serial.peek() that would be a welcome improvement, as my feeble attempt without interrupts certainly limits data reception.

@maxint-rd

Copy link
Copy Markdown
Contributor

FYI - Some time ago i submitted PR #145, which implements interrupt driven Serial1. It enables Serial.available(), Serial.peek() and improves Serial.read() to prevent lost data. Tested mainly on CH32V003, but also confirmed to work on other CH32 chips. Would be nice if more CH32 chips could be tested.

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