/dev/tty.usbmodemXXXX与位置ID之间的映射

时间:2016-01-19 19:46:12

标签: xcode macos mono serial-port monomac

我正在尝试在OSX计算机上识别特定的USB设备。 该设备是一个arduino设备,具有轻微修改的驱动程序,它自己的PID和VID。

我可以使用bash命令“system_profiler SPUSBDataType”列出设备:

Powerbrain      :

  Product ID: 0x4243
  Vendor ID: 0x2bfd
  Version: 1.00
  Speed: Up to 12 Mb/sec
  Manufacturer: Kinematics 
  Location ID: 0x14200000 / 27
  Current Available (mA): 1000
  Current Required (mA): 500
  Extra Operating Current (mA): 0

我也可以使用bash命令“ioreg -p IOUSB -l -b”列出设备:

Powerbrain      @14200000  <class AppleUSBDevice, id 0x100000d1b, registered, matched, active, busy 0 (8 ms), retain 15>
    {
      "sessionID" = 34690005456990
      "iManufacturer" = 1
      "bNumConfigurations" = 1
      "idProduct" = 16963
      "bcdDevice" = 256
      "Bus Power Available" = 500
      "USB Address" = 27
      "bMaxPacketSize0" = 64
      "iProduct" = 2
      "iSerialNumber" = 0
      "bDeviceClass" = 2
      "Built-In" = No
      "locationID" = 337641472
      "bDeviceSubClass" = 0
      "bcdUSB" = 512
      "USB Product Name" = "Powerbrain      "
      "PortNum" = 2
      "non-removable" = "no"
      "IOCFPlugInTypes" = {"9dc7b780-9ec0-11d4-a54f-000a27052861"="IOUSBFamily.kext/Contents/PlugIns/IOUSBLib.bundle"}
      "bDeviceProtocol" = 0
      "IOUserClientClass" = "IOUSBDeviceUserClientV2"
      "IOPowerManagement" = {"DevicePowerState"=0,"CurrentPowerState"=3,"CapabilityFlags"=65536,"MaxPowerState"=4,"DriverPowerState"=3}
      "Device Speed" = 1
      "USB Vendor Name" = "Kinematics "
      "idVendor" = 11261
      "IOGeneralInterest" = "IOCommand is not serializable"
      "IOClassNameOverride" = "IOUSBDevice"
    }

我也可以看到端口名称“/dev/tty.usbmodem1421”并与之通信。

问题是 - 位置ID“0x14200000 / 27”如何映射到“usbmodem1421”?

如果还有另一种使用Mono C#/ Xcode存档的方法,请告诉我。

1 个答案:

答案 0 :(得分:0)

我使用IOKit解决了这个问题 - 有一种方法可以迭代所有调制解调器服务,另一种方法可以找到该通信设备的相应USB设备。

代码可与MonoMac一起使用,可在GitHub上访问:https://github.com/Lunatix89/MonoMac-IOKit-USBDevice