Closed manishbuttan closed 2 months ago
same issue here plz if u solve it reply
Try applying the port config when your port is already opened. Like so:
var port = SerialPort(gateway.port);
port.openReadWrite();
port.config = SerialPortConfig()
..baudRate = 9600
..bits = 8
..stopBits = 1
..parity = SerialPortParity.none
..setFlowControl(SerialPortFlowControl.none);
same here. I have to open serial port with putty first. After that I am able to receive data with this package. Without no data are received. Testet on windows 11
Update: After some testing I have found an solution that works for me. I have to set some flow controls. It was a lot of try and error and I have not tested which one did the trick, but with this config it works:
_serialPort.config = SerialPortConfig()
..rts = SerialPortRts.flowControl
..cts = SerialPortCts.flowControl
..dsr = SerialPortDsr.flowControl
..dtr = SerialPortDtr.flowControl
..setFlowControl(SerialPortFlowControl.rtsCts);
Thank you moodstubos. These settings worked for me as well. Import information to add to the documentation.
set the config after openReadWrite
or other "open" port methods work for me.
Sattha is right here. The SerialPortConfig class documentation states the following:
@note A port must be opened before you can change its settings.
Solved my issue as well :)
hahahahahahahaha
Refers to #29
Hi, when I open the port in flutter to my USB serial port, it opens fine. But the port won't listen for incoming messages. If I close the port in the app and open it from Tera Term and close it, then open it again in the app, the communcation works fine and the incoming messages are working.
What is the proper way of opening the port and starting communication with the serial port without opening it externally?
Platform : Windows. Flutter.
if (!port.openReadWrite()) { print("Port not opened: ${SerialPort.lastError}"); }
try { serialPortReader = SerialPortReader(port); serialPortReader.stream.listen((data) { String message = String.fromCharCodes(data); _processUSBData(message); }); } catch (e) { print(SerialPort.lastError); }