flutter_libserialport icon indicating copy to clipboard operation
flutter_libserialport copied to clipboard

can not set baudrate

Open csj-libs opened this issue 4 years ago • 5 comments
trafficstars

when I set baudrate it does not work at all.

csj-libs avatar Oct 03 '21 14:10 csj-libs

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.

katyo avatar Nov 22 '21 13:11 katyo

Thanks @katyo for sharing that discovery. Setting the config after opening the port, solve my issue also. Great!

mortenboye avatar Jun 17 '22 09:06 mortenboye

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;

VinayakaKS avatar Sep 05 '23 10:09 VinayakaKS

Thanks @VinayakaKS I'll check it further to avoid issues when config is set before opening

lucafabbri avatar Feb 21 '24 12:02 lucafabbri