在系統開啟并有日志打印的前提下,插入USB設備,就會打印USB設備和虛擬串口信息。
打印信息如下:
供應商ID(VID):idVendor=1234,產品ID(PID): idProduct=5678
Product、Manufacturer、SerialNumber,這三項暫時用不到。
ttyACM0:虛擬出來的串口,也有可能是ttySx、ttyGSx(x為0/1/2/3.。..。.)
[ 99.373774] usb 3-1.3: new full-speed USB device number 3 using usb20_host
[ 99.473868] usb 3-1.3: New USB device found, idVendor=1234, idProduct=5678
[ 99.473970] usb 3-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 99.473997] usb 3-1.3: Product: USBKey Module
[ 99.474016] usb 3-1.3: Manufacturer: USBKey Chip
[ 99.474033] usb 3-1.3: SerialNumber: 202730041341
[ 99.483763] cdc_acm 3-1.3:1.0: This device cannot do calls on its own. It is not a modem.
[ 99.491455] cdc_acm 3-1.3:1.0: ttyACM0: USB ACM device
先手動測試此虛擬串口能否使用(以虛擬串口的掃描槍為例)
$ adb shell
// 查看虛擬的串口是否存在
root@xxx:/ # ls /dev/ttyACM0
ls /dev/ttyACM0
/dev/ttyACM0
// 如果不是 root 權限,此時使用 su 獲取 root 權限
// 修改此虛擬串口為最高權限
root@xxx:/ # chmod 777 /dev/ttyACM0
chmod 777 /dev/ttyACM0
root@xxx:/ # cat dev/ttyACM0
cat dev/ttyACM0
// 開始掃碼
DS610018C18021
DS610018C18021
確定虛擬串口可以使用,將設備添加到代碼中。
同時添加了ttyACM0-3,為了防止插入多個設備而導致虛擬串口變動。
將VID和PID添加到數組 option_ids[] 中。USB_DEVICE(VID, PID)
diff --git a/device/rockchip/common/ueventd.rockchip.rc b/device/rockchip/common/ueventd.rockchip.rc
old mode 100644
new mode 100755
index 34f7ad1..d82fad3
--- a/device/rockchip/common/ueventd.rockchip.rc
+++ b/device/rockchip/common/ueventd.rockchip.rc
@@ -116,3 +116,8 @@
/dev/i2c-2 0660 system system
/dev/i2c-3 0660 system system
/dev/i2c-4 0660 system system
+
+/dev/ttyACM0 0666 system system
+/dev/ttyACM1 0666 system system
+/dev/ttyACM2 0666 system system
+/dev/ttyACM3 0666 system system
diff --git a/kernel/drivers/usb/serial/option.c b/kernel/drivers/usb/serial/option.c
index e7ecdc3..9f1a6b6 100755
--- a/kernel/drivers/usb/serial/option.c
+++ b/kernel/drivers/usb/serial/option.c
@@ -1766,6 +1766,8 @@ static const struct usb_device_id option_ids[] = {
{USB_DEVICE(0x0E8D,0x00A5)},
{USB_DEVICE(0x05C6,0x9025)},
+ {USB_DEVICE(0x1234,0x5678)},//掃描槍
{ } /* Terminating entry */
};
評論
查看更多