当我的 USB 设备连接时,我得到以下信息:
$ dmesg | tail
[ 79.612133] usb 2-2: new full-speed USB device number 3 using ohci-pci
[ 79.937340] usb 2-2: New USB device found, idVendor=238b, idProduct=0a21
[ 79.937343] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 79.937344] usb 2-2: Product: DMR Radio
[ 79.937346] usb 2-2: Manufacturer: Hytera Communications
[ 80.282770] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[ 80.286007] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[ 80.399206] usbcore: registered new interface driver cdc_ether
[ 80.404402] usbcore: registered new interface driver rndis_host
[ 80.421516] usbcore: registered new interface driver rndis_wlan
没有类似“cdc_subset 1-4.4.2:1.1: usb0: register 'cdc_subset' at usb-0000:00:02.1-4.4.2, Linux Device”之类的消息。
所以没有名为 usb0 的以太网。
$ uname -a
Linux VB1804 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
显示为未知设备。
$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 238b:0a21
Bus 002 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
$ lsmod | grep usbnet
usbnet 45056 3 rndis_host,cdc_ether,rndis_wlan
mii 16384 1 usbnet
我在物理 Linux 上也得到了同样的结果。
还有,
$ usb-devices
--------- other usb devices ----
T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 3 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=fe Prot=fe MxPS= 8 #Cfgs= 1
P: Vendor=238b ProdID=0a21 Rev=00.00
S: Manufacturer=Hytera Communications
S: Product=DMR Radio
C: #Ifs= 3 Cfg#= 1 Atr=c0 MxPwr=4mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=02 Prot=ff Driver=(none)
I: If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=(none)
I: If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
我将 idVendor 和 idProduct 添加到文件 rndis_host.c 中结构体数组 prodocts[] 的白名单中。
static const struct usb_device_id products [] = {
{ /* DMR Radio*/
USB_DEVICE_AND_INTERFACE_INFO(0x238b, 0x0a21,
USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
.driver_info = (unsigned long) &rndis_info,
}, {
而且,它有效。
我用这个补丁连接了 Hytera,它在我的 Linux 上被检测为 RNDIS。您知道我如何控制 Hytera DMR 吗? 我有一个 x86 Windows .Net DLL 和 C++ Lib(没有源代码),你对 Linux 有什么想法吗?