flutter_libserialport
flutter_libserialport copied to clipboard
sync error
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?