통신
-
[Ubuntu] USB 인식오류 해결(CH340 serial converter)LINUX 2022. 9. 23. 23:18
USB 포트에 시리얼 통신케이블을 연결했다. lsusb 명령어를 통해 보면 분명 인식은 되어있었다. lsusb Bus 001 Device 008: ID 1a86:7523 QinHeng Electronics CH340 serial converter 그런데 통신을 하려보면 cat /dev/ttyUSB 이러고 탭 키를 눌러보면 단 한개도! 안나왔다...ㅎ;;; 그냥 넘어가는 일 이 하나도 없다.. 그래서 폭풍 구글링 결과 찾았다. https://unix.stackexchange.com/questions/670636/unable-to-use-usb-dongle-based-on-usb-serial-converter-chip Unable to use USB dongle based on USB-serial conve..
-
파이썬에서 시리얼 데이터 받기 (Hex Data)Python 2022. 9. 23. 23:02
여기는 Hex 형태의 시리얼 데이터를 받는 예제입니다. String 데이터는 이전 글을 보세요. 선행작업 pip install pyserial pip가 설치가 안된경우 pip 를 먼저 설치 합니다. apt install python3-pip import serial seru = serial.Serial('/dev/ttyUSB0', 115200) while True: if seru.readable(): s = seru.read() hex_string = binascii.hexlify(s).decode('utf-8') print(hex_string)
-
파이썬에서 시리얼 데이터 받기 (String Data)Python 2022. 9. 23. 22:59
여기는 String 형태의 시리얼 데이터를 받는 예제입니다. Hex 데이터는 다음 글을 보세요. 선행작업 pip install pyserial pip가 설치가 안된경우 pip 를 먼저 설치 합니다. apt install python3-pip 코드 import serial ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS) while True: if ser.readable(): res = ser.readline() print(res.decode()[:len(res) - 1]) 엄청 간단하죠? 설명이 필요 없을정..