最後更新: 2023-10-04
目錄
CH340
USB to serial port control chip
lsusb | grep CH340
Bus 003 Device 004: ID 1a86:7523 QinHeng Electronics CH340 serial converter
dmsg
... usb 3-13: ch341-uart converter now attached to ttyUSB0
lsmod | grep ch34
ch341 28672 0 usbserial 61440 1 ch341
Troubleshoot
情況
stty -F /dev/ttyUSB0
stty: /dev/ttyUSB0: Inappropriate ioctl for device
原因
After unplugging the USB device, the "/dev/ttyUSB?" file still exists
Fix
rmmod ch341
rm /dev/ttyUSB? -f
modprobe ch341
STM8S103F
Spec
- 8-bit MCU, 16MHz
- Program memory: 8KBytes
- Data memory: 640 Bytes # EEPROM
- RAM: 1 KBytes
Program memory(ROM) vs data memory
應用
LCUS-4
Serial Port Settings: 9600bps
狀態查詢:
發送 0xff 到 serial port
echo -n -e '\xFF' > /dev/ttyUSB0
cat -A /dev/ttyUSB0
CH1: OFF\r\nCH2: OFF\r\n
Open / Close
Open1: A0 01 01 A2
Close1: A0 01 00 A1
Open2: A0 02 01 A3
Close2: A0 02 00 A2
i.e. 將 CH1: ON
echo -n -e '\xA0\x01\x01\xA2' > /dev/ttyUSB0
cat -A /dev/ttyUSB0
CH1: ON $ $ CH2: OFF$ $