USB设备没有出现在macOS下,甚至在USB Prober中也没有出现

时间:2019-05-28 17:45:27

标签: macos serial-port usb iokit pyusb

我正在尝试让一个简单的USB设备在macOS上工作。该设备可通过使用usbser.sys驱动程序在Windows上运行:提供了一个简单的.inf文件,并且似乎可以解决问题(使用.cat文件)。我对usbser.sys的理解是,它将拥有USB通信设备类(CDC)设备的所有权。

在解构macOS上的USB设备之前,我已经为许多不同的设备编写了用户空间驱动程序。我的策略一直是相同的:使用USB Prober.app(或更近期的PyUSB)获取USB设备及其所有配置参数,接口,管道和端点的列表。所获得的信息足以完全掌握设备:我可以查看设备是否可以序列化(即通过某些驱动程序获取/dev/cu.serialxxx),也可以看到USB配置和USB接口。当然,在可能的情况下(即,当USB内核扩展获得设备的所有权并对其进行序列化时),我使用POSIX库作为序列化版本,因为它更简单。但是,在需要时,我可以使用IOKit直接访问设备,并在经过反复试验后找到正确的通信管道/端点。

但是我完全不知所措:虽然连接该设备(这是Cobolt Lasers的激光),但它完全不显示,即使是USB原始设备也没有显示,尽管它在Windows上运行得很好(每次) 10机。正如我在Windows上验证的那样,它是CDC设备。它至少应由AppleUSBCDC.kext接收,但不能:它不会显示在系统报告,USB Prober或PyUSB列表中,因此,它根本不会显示在/ dev /中。我很困惑,因为尽管我不是USB专家,但我认为我知道驱动程序不需要USB设备显示在系统报告中的至少,这足以我可以使用IOKit编写自己的用户空间驱动程序(过去我已经在其他设备上做到过)。

我的问题:

  1. 我是否希望我的设备至少在没有驱动程序的情况下显示在系统报告中?如果我缺少某些东西,该怎么办?
  2. AppleUSBCDC.kext为什么不将CDC设备作为最后手段?
  3. 如果不是AppleUSBCDC.kext,在macOS(Mojave)上是否有与usbser.sys等效的内容?

编辑1: 在评论之后,我使用了sudo dmesg并在枚举过程中看到了错误(请参见下文)。我目前的工作假设是USB设备描述符不是很有效,尽管在macOS上,但在Windows上这不是问题。

编辑2: 尽管我无法在描述符中找到确切的错误,但Ot似乎是无效的USB设备描述符。我发布了另一个有关USB设备描述符验证器的问题。

我在此处粘贴通过将设备连接到Windows机器获得的USB信息,对我来说,这清楚地表明AppleUSBCDC.kext应该真正使用该设备并对其进行序列化,因为CDC设备(总是?)可序列化:



    =========================== USB Port8 ===========================

Connection Status        : 0x01 (Device is connected)
Port Chain               : 3-8

      ======================== USB Device ========================

        +++++++++++++++++ Device Information ++++++++++++++++++
Friendly Name            : Cobolt Laser (COM7)
Device Description       : Cobolt Laser
Device Path              : \\?\usb#vid_25dc&pid_0006#000013245678#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
Device ID                : USB\VID_25DC&PID_0006\000013245678
Hardware IDs             : USB\VID_25DC&PID_0006&REV_0100 USB\VID_25DC&PID_0006
Driver KeyName           : {4d36e978-e325-11ce-bfc1-08002be10318}\0006 (GUID_DEVCLASS_PORTS)
Driver                   : system32\DRIVERS\usbser.sys (Version: 6.1.7601.18247  Date: 2013-08-28)
Driver Inf               : C:\Windows\inf\oem107.inf
Legacy BusType           : PNPBus
Class                    : Ports
Class GUID               : {4d36e978-e325-11ce-bfc1-08002be10318} (GUID_DEVCLASS_PORTS)
Interface GUID           : {a5dcbf10-6530-11d2-901f-00c04fb951ed} (GUID_DEVINTERFACE_USB_DEVICE)
Service                  : usbser
Enumerator               : USB
Location Info            : Port_#0008.Hub_#0001
Location IDs             : PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(8)
Container ID             : {1ddbadd3-ec62-5d3a-a00a-64685c39b2e8}
Manufacturer Info        : Cobolt AB
Capabilities             : 0x94 (Removable, UniqueID, SurpriseRemovalOK)
Status                   : 0x0180600A (DN_DRIVER_LOADED, DN_STARTED, DN_DISABLEABLE, DN_REMOVABLE, DN_NT_ENUMERATOR, DN_NT_DRIVER)
Problem Code             : 0
Power State              : D0 (supported: D0, D3, wake from D0)
COM-Port                 : COM7 (\Device\USBSER000)

        +++++++++++++++++ Registry USB Flags +++++++++++++++++
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\UsbFlags\25DC00060100
 osvc                    : REG_BINARY 00 00
 SkipContainerIdQuery    : REG_BINARY 01 00 00 00

        ---------------- Connection Information ---------------
Connection Index         : 0x08 (8)
Connection Status        : 0x01 (DeviceConnected)
Current Config Value     : 0x01
Device Address           : 0x0B (11)
Is Hub                   : 0x00 (no)
Number Of Open Pipes     : 0x03 (3)
Device Bus Speed         : 0x01 (Full-Speed)
Pipe0ScheduleOffset      : 0x00 (0)
Pipe1ScheduleOffset      : 0x00 (0)
Pipe2ScheduleOffset      : 0x00 (0)
Data (HexDump)           : 08 00 00 00 12 01 00 02 02 00 00 08 DC 25 06 00   .............%..
                           00 01 01 02 03 01 01 01 00 0B 00 03 00 00 00 01   ................
                           00 00 00 07 05 82 03 40 00 08 00 00 00 00 07 05   .......@........
                           01 02 40 00 01 00 00 00 00 07 05 81 02 40 00 01   ..@..........@..
                           00 00 00 00                                       ....

    ---------------------- Device Descriptor ----------------------
bLength                  : 0x12 (18 bytes)
bDescriptorType          : 0x01 (Device Descriptor)
bcdUSB                   : 0x200 (USB Version 2.00)
bDeviceClass             : 0x02 (Communications and CDC Control)
bDeviceSubClass          : 0x00
bDeviceProtocol          : 0x00 (No class specific protocol required)
bMaxPacketSize0          : 0x08 (8 bytes)
idVendor                 : 0x25DC
idProduct                : 0x0006
bcdDevice                : 0x0100
iManufacturer            : 0x01 (String Descriptor 1)
 Language 0x0409         : "Cobolt AB"
iProduct                 : 0x02 (String Descriptor 2)
 Language 0x0409         : "Cobolt Laser Driver MLD"
iSerialNumber            : 0x03 (String Descriptor 3)
 Language 0x0409         : "000013245678"
bNumConfigurations       : 0x01 (1 Configuration)
Data (HexDump)           : 12 01 00 02 02 00 00 08 DC 25 06 00 00 01 01 02   .........%......
                           03 01                                             ..

    ------------------ Configuration Descriptor -------------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x02 (Configuration Descriptor)
wTotalLength             : 0x0043 (67 bytes)
bNumInterfaces           : 0x02 (2 Interfaces)
bConfigurationValue      : 0x01 (Configuration 1)
iConfiguration           : 0x00 (No String Descriptor)
bmAttributes             : 0x80
 D7: Reserved, set 1     : 0x01
 D6: Self Powered        : 0x00 (no)
 D5: Remote Wakeup       : 0x00 (no)
 D4..0: Reserved, set 0  : 0x00
MaxPower                 : 0x32 (100 mA)
Data (HexDump)           : 09 02 43 00 02 01 00 80 32 09 04 00 00 01 02 02   ..C.....2.......
                           01 00 05 24 00 10 01 05 24 01 01 01 04 24 02 06   ...$....$....$..
                           05 24 06 00 01 07 05 82 03 40 00 08 09 04 01 00   .$.......@......
                           02 0A 00 00 00 07 05 01 02 40 00 01 07 05 81 02   .........@......
                           40 00 01                                          @..

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x00
bAlternateSetting        : 0x00
bNumEndpoints            : 0x01 (1 Endpoint)
bInterfaceClass          : 0x02 (Communications and CDC Control)
bInterfaceSubClass       : 0x02 (Abstract Control Model)
bInterfaceProtocol       : 0x01 (AT Commands defined by ITU-T V.250 etc)
iInterface               : 0x00 (No String Descriptor)
Data (HexDump)           : 09 04 00 00 01 02 02 01 00                        .........

        -------------- CDC Interface Descriptor ---------------
bFunctionLength          : 0x05 (5 bytes)
bDescriptorType          : 0x24 (Interface)
bDescriptorSubType       : 0x00 (Header Functional Descriptor)
bcdCDC                   : 0x110 (CDC Version 1.10)
Data (HexDump)           : 05 24 00 10 01                                    .$...

        -------------- CDC Interface Descriptor ---------------
bFunctionLength          : 0x05 (5 bytes)
bDescriptorType          : 0x24 (Interface)
bDescriptorSubType       : 0x01 (Call Management Functional Descriptor)
bmCapabilities           : 0x01
 D7..2:                  : 0x00 (Reserved)
 D1   :                  : 0x00 (sends/receives call management information only over the Communication Class interface)
 D0   :                  : 0x01 (handles call management itself)
bDataInterface           : 0x01
Data (HexDump)           : 05 24 01 01 01                                    .$...

        -------------- CDC Interface Descriptor ---------------
bFunctionLength          : 0x04 (4 bytes)
bDescriptorType          : 0x24 (Interface)
bDescriptorSubType       : 0x02 (Abstract Control Management Functional Descriptor)
bmCapabilities           : 0x06
 D7..4:                  : 0x00 (Reserved)
 D3   :                  : 0x00 (not supports the notification Network_Connection)
 D2   :                  : 0x01 (supports the request Send_Break)
 D1   :                  : 0x01 (supports the request combination of Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State)
 D0   :                  : 0x00 (not supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature)
Data (HexDump)           : 04 24 02 06                                       .$..

        -------------- CDC Interface Descriptor ---------------
bFunctionLength          : 0x05 (5 bytes)
bDescriptorType          : 0x24 (Interface)
bDescriptorSubType       : 0x06 (Union Functional Descriptor)
bControlInterface        : 0x00
bSubordinateInterface[0] : 0x01
Data (HexDump)           : 05 24 06 00 01                                    .$...

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x82 (Direction=IN EndpointID=2)
bmAttributes             : 0x03 (TransferType=Interrupt)
wMaxPacketSize           : 0x0040 (64 bytes)
bInterval                : 0x08 (8 ms)
Data (HexDump)           : 07 05 82 03 40 00 08                              ....@..

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x01
bAlternateSetting        : 0x00
bNumEndpoints            : 0x02 (2 Endpoints)
bInterfaceClass          : 0x0A (CDC-Data)
bInterfaceSubClass       : 0x00
bInterfaceProtocol       : 0x00
iInterface               : 0x00 (No String Descriptor)
Data (HexDump)           : 09 04 01 00 02 0A 00 00 00                        .........

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x01 (Direction=OUT EndpointID=1)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x0040 (64 bytes)
bInterval                : 0x01 (ignored)
Data (HexDump)           : 07 05 01 02 40 00 01                              ....@..

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x81 (Direction=IN EndpointID=1)
bmAttributes             : 0x02 (TransferType=Bulk)
wMaxPacketSize           : 0x0040 (64 bytes)
bInterval                : 0x01 (ignored)
Data (HexDump)           : 07 05 81 02 40 00 01                              ....@..

    ----------------- Device Qualifier Descriptor -----------------
Error                    : ERROR_GEN_FAILURE

      -------------------- String Descriptors -------------------
             ------ String Descriptor 0 ------
bLength                  : 0x04 (4 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language ID[0]           : 0x0409 (English - United States)
Data (HexDump)           : 04 03 09 04                                       ....
             ------ String Descriptor 1 ------
bLength                  : 0x14 (20 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "Cobolt AB"
Data (HexDump)           : 14 03 43 00 6F 00 62 00 6F 00 6C 00 74 00 20 00   ..C.o.b.o.l.t. .
                           41 00 42 00                                       A.B.
             ------ String Descriptor 2 ------
bLength                  : 0x30 (48 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "Cobolt Laser Driver MLD"
Data (HexDump)           : 30 03 43 00 6F 00 62 00 6F 00 6C 00 74 00 20 00   0.C.o.b.o.l.t. .
                           4C 00 61 00 73 00 65 00 72 00 20 00 44 00 72 00   L.a.s.e.r. .D.r.
                           69 00 76 00 65 00 72 00 20 00 4D 00 4C 00 44 00   i.v.e.r. .M.L.D.
             ------ String Descriptor 3 ------
bLength                  : 0x1A (26 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : "000013245678"
Data (HexDump)           : 1A 03 30 00 30 00 30 00 30 00 31 00 33 00 32 00   ..0.0.0.0.1.3.2.
                           34 00 35 00 36 00 37 00 38 00                     4.5.6.7.8.
             ----- String Descriptor 0xEE -----
bLength                  : 0x02 (2 bytes)
bDescriptorType          : 0x03 (String Descriptor)
Language 0x0409          : ""  *!*CAUTION  zero length
Data (HexDump)           : 02 03                                             ..

0 个答案:

没有答案