-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Describe the bug
When you run the following code, and start spamming words (followed by the enter key) on your keyboard, eventually it stops reading data. You can also lock it up by just hitting enter without any letters. The USART1 interrupt stops firing, because the code seems to fail to set TXEIE. It also appears to only happen when there's an overrun error as verified by looking at USART_SR with gdb.
To Reproduce
#include <Arduino.h>
void setup() {
Serial.begin(9600);
Serial.println("hello");
}
void loop() {
if (Serial.available() > 0) {
printf("Serial available: %d\n", Serial.available());
char buf[128] = {0};
char *line = buf;
size_t nbytes;
if ((nbytes = Serial.readBytesUntil('\n', buf, sizeof buf)) == 0) {
printf("# error: no data read from serial\n");
return;
}
printf("# read %d [%s]\n", nbytes, line);
printf("rest = %d\n", Serial.available());
}
}
Steps to reproduce the behavior:
- Run code
- Open a serial monitor (e.g.
pio device monitor
) - Spam stuff into the serial console. (Or just hit enter)
- See it lock up and refuse to take more input.
Expected behavior
Continue receiving input, possibly by dropping the next character.
Desktop (please complete the following information):
- OS: Mac OS 10.14.3
- Platformio: 3.6.6
- STM32 core version: 1.5.0
- Upload method: STLink
Board (please complete the following information):
- Name: Bluepill 128k
Metadata
Metadata
Assignees
Labels
No labels