Closed Aloomenon closed 3 years ago
I think the problem is the wrong baud rate. I changed it to 9600 and it works correctly now. But I still can't figure out why I saw batches of correct data and then only zeros.
Looks like the zeros were not received by the port but were already in your array of bytes
But why port.bytesAvailable()
returns something > 0 and output is zeros? Zeros prints infinitely.
And one more thing: I changed baudrate and code is working perfectly.
That's not a totally unexpected result when using the incorrect baud rate. Many drivers will return either 0s or garbage values when trying to read serial data with a mismatched speed. Glad changing the baud rate worked for you!
Hello everyone. I'm trying to get bytes from a serial port, but it returns real data only for the first 3 batches then only zeros.
my code snippet:
output is:
000D022B30303030323330314103022B30303030323330314103022B303030303233303141030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
and then only zeros for every read.
But If I connect to this port with putty, I see a lot of non-zero values, like this: 022B30303030323330314103.
Any ideas?