flutter_libserialport icon indicating copy to clipboard operation
flutter_libserialport copied to clipboard

sync error

Open GuiWolff opened this issue 3 years ago • 0 comments

Hello Friend! I'm having trouble configuring the serial port. When I test connecting an arduino through Putty, the Flutter serial connection works. If I disconnect the arduino from the USB port and connect right after, the connection reads the data without sync.

My code:

          void conectarNaSerial(int address) {
            final port = SerialPort.fromAddress(address);
            port.open(mode: 1);
            if(port.isOpen) {
              port.config.baudRate = 115200;
              port.config.stopBits = 1;
              port.config.bits = 8;
              port.config.parity = SerialPortParity.none;
              port.config.setFlowControl(SerialPortFlowControl.none);

              reader = SerialPortReader(port);
              if(reader != null){
                reader!.stream.listen((d){
                  print("${utf8.decode(d)}");
                  var number = double.tryParse(utf8.decode(d));
                  if(number == null){
                    return;
                  } else {
                    valorSerial.value = number;
                  }
                });
              }
            }
          }

I must configure the serial port right after connecting, right?

GuiWolff avatar Nov 12 '21 03:11 GuiWolff