-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Serial.flush() have a problem #2502
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
Milestone
Comments
Hi @jyzhkj from your code looks like you are using an USART to RS485, I've found the same behavior and the last byte is not send as the flush doesn't empty the send queue before moving to the next instruction. |
I have also found the same issue. |
igrr
pushed a commit
that referenced
this issue
Oct 15, 2017
* Add a workaround-delay in Serial.flush() In relation to #2536 and #2502 Tested at 80MHz and 160MHz with flash-frequency at both 40MHz and 80MHz, the bug mentioned in the above issues manifests in all cases. The proposed workaround seems to work fine, I tested at 2400bps, 9600bps, 115200bps, 230400bps and 2Mbps and didn't see anomalous output. * Remove extraneous character * Update HardwareSerial.cpp
d-a-v
pushed a commit
to d-a-v/Arduino
that referenced
this issue
Oct 15, 2017
* Add a workaround-delay in Serial.flush() In relation to esp8266#2536 and esp8266#2502 Tested at 80MHz and 160MHz with flash-frequency at both 40MHz and 80MHz, the bug mentioned in the above issues manifests in all cases. The proposed workaround seems to work fine, I tested at 2400bps, 9600bps, 115200bps, 230400bps and 2Mbps and didn't see anomalous output. * Remove extraneous character * Update HardwareSerial.cpp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
void loop()
{
digitalWrite(12, 1);
Serial.print("abcdffew");
Serial.flush();
digitalWrite(12, 0);
delay(100); // wait for a second
}
see the 12 pin when down, the last byte is not Send End.
so I try to change the HardwareSerial.cpp to:
void HardwareSerial::flush()
{
if(!_uart || !uart_tx_enabled(_uart)) {
return;
}
uart_wait_tx_empty(_uart);
long tt =uart_get_baudrate(_uart);
tt=12000000/tt;
delayMicroseconds(tt);
}
The text was updated successfully, but these errors were encountered: