656 PDFsam PythonNotesForProfessionals
656 PDFsam PythonNotesForProfessionals
(pyserial)
parameter details
port Device name e.g. /dev/ttyUSB0 on GNU/Linux or COM3 on Windows.
baudrate type: int default: 9600 standard values: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
baudrate
4800, 9600, 19200, 38400, 57600, 115200
import serial
#Serial takes two parameters: serial device and baudrate
ser = serial.Serial('/dev/ttyUSB0', 9600)
data = ser.read()
data = ser.read(size=5)
data = ser.readline()
to read the data from serial device while something is being written over it.
#for python2.7
data = ser.read(ser.inWaiting())
#for python3
ser.read(ser.inWaiting)
python -m serial.tools.list_ports
at a command prompt or