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

Fix for Serial flush() returning before transmission has completed #328

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Hsubtnarg
Copy link

Problem: flush() would return when the transmission buffer was empty, but the txBuffer was not being used so flush() would return straight away. write() would wait until it had sent all bytes to the UART before returning, but there would still be bytes in the UART that had not been sent, so it would return 1-11 bytes early

Fix: Used the UART_EVENT_TX_COMPLETE call back to determine when the UART has finished transmitting and use this to determine when flush() should return

Renamed tx_done to tx_empty
Created tx_complete
Separated call back events UART_EVENT_TX_COMPLETE and UART_EVENT_TX_DATA_EMPTY and used UART_EVEN_TX_COMPLETE to determine when flush() should return
@CLAassistant
Copy link

CLAassistant commented May 28, 2024

CLA assistant check
All committers have signed the CLA.

@per1234 per1234 linked an issue May 29, 2024 that may be closed by this pull request
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels May 29, 2024
Removed old comment
Added a timeout to flush() because BLE.begin() on the Uno R4 Wifi, would hang without it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serial[x].flush() does not wait until transmission is finished
3 participants