jpnurmi / flutter_libserialport

Serial Port for Flutter
https://pub.dev/packages/flutter_libserialport
MIT License
139 stars 80 forks source link

How to configure baudrate and port #97

Closed tkumark closed 2 months ago

tkumark commented 4 months ago

I am trying to rewrite below python code in flutter/dart. I would like to how to set port,baudrate,parity,bytesize and open readline connection?

import time
import serial
import re

ser = serial.Serial(
    port='/dev/ttyS0',
    baudrate=115200,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.SEVENBITS,
)

ser.isOpen()
out = ''
for i in range(10):
    waitingQueue = ser.inWaiting()
    if waitingQueue == 0:
        weight = "-- kg"
    else:
        out = ser.readline()
        if out != '':
            print(str(out))
            m = re.search('\s\s(.+?)\s\s\s\s', str(out))
            if m != None:
                weight = m.group(1)
            else:
                weight = "Extract Error"
    print(weight.strip())

ser.close()
sayanp23 commented 3 months ago

Hi, Did anyone got solution for setting the Baudrate?? If you've found any solution please help me out, thanks.

lucafabbri commented 2 months ago

Please se #29