我想读取串行输入(例如这里)在linux命令行中,但我无法找到附加设备(Arduino)路径。
我可以识别该设备:
# lsusb
Bus 005 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 2341:0043 Arduino SA Uno R3 (CDC ACM) <- this one
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
但 dmesg 仅显示此消息相关
# dmesg | grep usb
[15026545.556311] usb 4-1: new full-speed USB device number 3 using xhci-hcd
[15026545.697929] usb 4-1: ep 0x82 - rounding interval to 1024 microframes, ep desc says 2040 microframes
同样让我困惑的是 lspci 没有显示该设备:
# lspci
00:01.0 PCI bridge: Marvell Technology Group Ltd. Device 6820 (rev 04)
00:02.0 PCI bridge: Marvell Technology Group Ltd. Device 6820 (rev 04)
00:03.0 PCI bridge: Marvell Technology Group Ltd. Device 6820 (rev 04)
01:00.0 Network controller: Qualcomm Atheros AR9287 Wireless Network Adapter (PCI-Express) (rev 01)
02:00.0 Network controller: Qualcomm Atheros QCA986x/988x 802.11ac Wireless Network Adapter
查看/dev目录:
# ls /dev/
autofs kmsg network_latency ram4 ttyS12
btrfs-control log network_throughput ram5 ttyS13
bus mapper null ram6 ttyS14
console mem port ram7 ttyS15
cpu_dma_latency memory_bandwidth ppp ram8 ttyS2
full mmcblk0 ptmx ram9 ttyS3
fuse mmcblk0boot0 pts random ttyS4
hwrng mmcblk0boot1 ram0 root ttyS5
i2c-0 mmcblk0p1 ram1 rtc0 ttyS6
i2c-1 mmcblk0rpmb ram10 shm ttyS7
i2c-2 mtd0 ram11 snd ttyS8
i2c-3 mtd0ro ram12 spidev0.2 ttyS9
i2c-4 mtd1 ram13 tty ubi_ctrl
i2c-5 mtd1ro ram14 ttyS0 urandom
i2c-6 mtdblock0 ram15 ttyS1 watchdog
i2c-7 mtdblock1 ram2 ttyS10 watchdog0
i2c-8 net ram3 ttyS11 zero
我能够找出这些事情:
- 未创建 ttyUSB*/ttyACM* 路径
- 设备的路径是/dev/bus/usb/004/003
- USB 3.0 应该使用 xhci-hcd
还有一个输出,这让我更加困惑(iProduct 行显示 2(错误)):
# lsusb -v -s 004:003
Bus 004 Device 003: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 2 Communications
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x2341 Arduino SA
idProduct 0x0043 Uno R3 (CDC ACM)
bcdDevice 0.01
iManufacturer 1 Arduino (www.arduino.cc)
iProduct 2 (error)
iSerial 220 8553130343135121F1A0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 62
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 2 Communications
bInterfaceSubClass 2 Abstract (modem)
bInterfaceProtocol 1 AT-commands (v.25ter)
iInterface 0
CDC Header:
bcdCDC 10.01
CDC ACM:
bmCapabilities 0x06
sends break
line coding and serial state
CDC Union:
bMasterInterface 0
bSlaveInterface 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 255
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 10 CDC Data
bInterfaceSubClass 0 Unused
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Device Status: 0x0000
(Bus Powered)
这是否表明设备在这种环境下出现故障?您能帮我找出如何找到该设备的附加地址吗?
背景信息:我在这里运行的系统是TurriOS(基于OpenWrt)。还测试了 Debian/Mint/Ubuntu/Manjaro,所有这些都可以毫无问题地连接 USB(设备本身没有损坏)。
编辑:这是安装 USB 串行驱动程序时与 dmesg 相关的输出:
[15707335.904584] usbserial: USB Serial support registered for carelink
[15707335.904622] usbserial: USB Serial support registered for zio
[15707335.904657] usbserial: USB Serial support registered for funsoft
[15707335.904686] usbserial: USB Serial support registered for flashloader
[15707335.904714] usbserial: USB Serial support registered for google
[15707335.904743] usbserial: USB Serial support registered for libtransistor
[15707335.904771] usbserial: USB Serial support registered for vivopay
[15707335.904802] usbserial: USB Serial support registered for moto_modem
[15707335.904832] usbserial: USB Serial support registered for motorola_tetra
[15707335.904863] usbserial: USB Serial support registered for novatel_gps
[15707335.904891] usbserial: USB Serial support registered for hp4x
[15707335.904917] usbserial: USB Serial support registered for suunto
[15707335.904944] usbserial: USB Serial support registered for siemens_mpi
[15707336.867539] usbcore: registered new interface driver ti_usb_3410_5052
[15707336.867582] usbserial: USB Serial support registered for TI USB 3410 1 port adapter
[15707336.867611] usbserial: USB Serial support registered for TI USB 5052 2 port adapter
[15721145.188760] usb 4-1: new full-speed USB device number 4 using xhci-hcd
[15721145.330360] usb 4-1: ep 0x82 - rounding interval to 1024 microframes, ep desc says 2040 microframes
编辑2: 当我谷歌搜索时,我发现了这个脚本它明确声称,我需要:
opkg install kmod-usb-acm
为了连接这些设备。
答案1
您需要能够识别 Arduino 并自动创建串行端口设备的内核模块。
根据 OpenWrt 的文档:将 Arduino 连接到 OpenWrt:
请安装以下软件包(如果您使用终端或使用 LuCi 软件页面,请使用“opkg install”)
kmod-usb-串口 kmod-usb-serial-ark3116 kmod-usb-serial-belkin kmod-usb-serial-ch341 kmod-usb-serial-cp210x kmod-usb-serial-ftdi kmod-usb-serial-mct kmod-usb -serial-mos7720 kmod-usb-serial-oti6858 kmod-usb-serial-pl2303 kmod-usb-serial-simple kmod-usb-serial-ti-usb
实际上,如果您可以识别 arduino(或克隆)中使用的 USB 转串口芯片是什么,您可能只需要其中之一。无论如何,它们不需要太多空间,所以如果您不确定或懒惰,您可以全部安装。
正如评论中所述,您可能还需要在该列表中添加kmod-usb-acm
.