flutter_libserialport
flutter_libserialport copied to clipboard
can not set baudrate
when I set baudrate it does not work at all.
I have same issue when I attempt to set SerialPortConfig on Linux:
port.config.baudRate = 9600;
No such file or directory, errno = 2
When the exception was thrown, this was the stack:
#0 Util.call (package:libserialport/src/util.dart:39:7)
#1 _SerialPortImpl.config (package:libserialport/src/port.dart:335:12)
...
var config = SerialPortConfig();
config.baudRate = 9600;
port.config = config;
No such file or directory, errno = 2
When the exception was thrown, this was the stack:
#0 Util.call (package:libserialport/src/util.dart:39:7)
#1 _SerialPortImpl.config= (package:libserialport/src/port.dart:347:10)
...
UPD: As I seen in libserialport examples, seems the config should be set after opening the port.
Thanks @katyo for sharing that discovery. Setting the config after opening the port, solve my issue also. Great!
Hi, I may be late to answer to this, but thinking it will help others who end up at this problem. The port.config needs to be set only after opening the port.
SerialPort port = SerialPort(availablePorts[widget.comPort]);
final portconfig = SerialPortConfig();
portconfig.baudRate = 115200;
SerialPortReader reader = SerialPortReader(port, timeout: 10000);
port.openReadWrite();
port.config = portconfig;
Thanks @VinayakaKS I'll check it further to avoid issues when config is set before opening