Closed ludesert closed 6 months ago
Solved ... I did not configure the port correctly (at all, in fact).
Made some attempts and looks like I had to configure the dtr to 1 with libserialport while pyserial somehow did it for me. I still don't know why not configuring the baudrate does not cause any problem, but I do it anyway.
SerialPortConfig conf = port.config;
confg;baudrate = 9600;
conf.dtr = 1;
port.config = conf;
This solved everything.
Does it work with 115200 baudrate?
If I set my serial device to 115200, yes of course.
I'm using Windows 10 with a serial port I can manually write data to via a terminal to test the following code:
It works when the serial port's buffer is empty: the raw data is sent back to the serial port.
When I send 3 bytes or more via my device BEFORE starting the previous code, nothing happens: dart/flutter can't read any new byte i send via my device. With 2 bytes before starting the code, it's ok, but if it's more than 3, the data somehow gets stuck.
I tried using the flush() and the drain() methods but none of them change anything. If I try to print port.bytesAvailable, I get 0.
The only way to get my code to work again is to: 1) unplug and plug the device 2) connect to the device with Putty which displays the bytes I send, then closing Putty. These 2 workarounds are just 2 ways of flushing the buffer before starting the code ...
Please note that this is not related to my device as I don't have this issue while using PySerial on Python.
Any idea ?