Closed Jookia closed 2 months ago
I did some more testing and it seems like this isn't related to Wi-Fi at all. This example will corrupt on output (looping to print numbers and a new line):
void setup() {
Serial.begin(115200);
}
void loop() {
for(int i = 0; i < 10; ++i)
Serial.write(0x30 + i);
Serial.write("\r\n");
//delay(10); // adding delay 'fixes'
}
Running this in Linux will print broken lines:
stty -F /dev/ttyUSB0 raw 115200
head -100 /dev/ttyUSB0 | grep -v '0123456789'
Adding a non-scheduling delay to wait for the FIFO to clear seems to fix this problem for the simple sketch:
void setup() {
Serial.begin(115200);
}
void loop() {
for(int i = 0; i < 10; ++i) {
Serial.write(0x30 + i);
ets_delay_us(100);
}
Serial.write("\r\n");
}
Unfortunately trying to integrate this in to the Wi-Fi example doesn't work, I still get data loss. Making the baud higher to 1.5M gives the exact same corrupted output, even with a delay of 100us.
What about Serial.flush() before writing next chunk of data?
I'll give it a look. I took out a logic analyzer and probed the output and it looks like the ESP8266 is outputting all data correctly, but the CH340 giving corrupted data over USB and serial. I tried an FTDI cable and had the same results.
Looking at the programmer, there's 6.7k between TX and GND and 4.7k between TX and 3.3v. I'm guessing what's happening here is a hardware design fault. Sorry for the noise.
Basic Infos
Note: There are no instructions for building and using the latest git with arduino-cli so I couldn't do it.
Platform
Settings in IDE
Problem Description
I'm currently working on a Wi-Fi to UART sketch, and during testing I found that while Serial to Serial, Wi-Fi to Wi-Fi, and Serial to Wi-Fi work, the case of Wi-Fi to Serial drops characters. This only happens under very high load.
MCVE Sketch
I'm using this script in Linux to test:
With this file: DMESG.txt (rename to DMESG)
The failure seems intermittent, but after a few runs it will fail.
Debug Messages
Instead of this:
I get this: