- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestPySerial.py
More file actions
Latest commit
21 lines (15 loc) · 646 Bytes
/
Copy pathTestPySerial.py
File metadata and controls
21 lines (15 loc) · 646 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""
"""
importserial# pip3 install pyserial
importserial.tools.list_ports
importbinascii
if__name__=='__main__':
#print(serial.tools.list_ports.comports())
#print([port.device for port in serial.tools.list_ports.comports()])
ser=serial.Serial(port='COM60', baudrate=19200, parity=serial.PARITY_EVEN, timeout=2) # open serial port
print('{0} is open'.format(ser.name)) # check which port was really used
whileTrue:
x=ser.read(size=24)
print('{0} bytes, {1}'.format(len(x), binascii.hexlify(bytearray(x)).decode('ascii')))
ser.close() # close port
print('Done.')