728x90 serial1 [Python] Serial 통신(읽기/쓰기), 사용가능한 시리얼 포트 검색 시리얼 포트 열어서 데이터 읽기 쓰기 - While로 루프돌면서 읽기 있을 때마다 데이터 찍기 - 데이터 쓸 때는 ser.write로 작성 import serial ser = serial.Serial( port=SerialPort, baudrate=int(SerialBaudRate), parity=serial.PARITY_ODD, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=0) ser.write(binascii.unhexlify(datas)) # 시리얼 쓰기(입력) if ser.readable(): # 시리얼 읽기 res = ser.readline() print(res.decode()[:len(res) - 1]) 사용가능한 시리얼 .. 2021. 2. 2. 이전 1 다음 728x90