Skip to content
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

Serial.available() not working properly #57

Open
VitorBoss opened this issue Mar 29, 2018 · 3 comments
Open

Serial.available() not working properly #57

VitorBoss opened this issue Mar 29, 2018 · 3 comments

Comments

@VitorBoss
Copy link

VitorBoss commented Mar 29, 2018

Looking on SerialUART.cpp the function is returning a bool condition instead os number of available bytes, a lot of libs use that like Nexion.
This is the current code:

int HardwareSerial::available() {
    return rxEnd != rxStart;
}

This is the fix:

int HardwareSerial::available() {
    //return rxEnd != rxStart;
    int size = (rxEnd % BUFFER_SIZE) - (rxStart % BUFFER_SIZE);
    if (size < 0) size += BUFFER_SIZE;
    return size;
}

Tested and working properly now.

@VitorBoss
Copy link
Author

Updated code, now working with Nextion

@Tjeerdie
Copy link

Hi, The current version does not have this fix yet. Manually adding the this code to the core works fine! I had problems with a project and this little thing. Can you please add the fix to the master branch?

@VitorBoss
Copy link
Author

int HardwareSerial::available() {
if (rxEnd >= rxStart) return (rxEnd - rxStart);
return BUFFER_SIZE + rxEnd - rxStart;
}

That work better

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

No branches or pull requests

2 participants