监控Thunderbolt端口连接上的更改 [英] Monitor changes on Thunderbolt port connection

查看:166
本文介绍了监控Thunderbolt端口连接上的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一项需要监视Thunderbolt端口连接更改的要求. (当连接或断开Thunderbolt电缆时.)

I am working on a requirement where i need to monitor changes in Thunderbolt port connection. (When Thunderbolt cable is connected or disconnected).

我尝试使用 IOKit框架中的 IOServiceMatching(kIOUSBInterfaceClassName),但是我无法监视Thunderbolt端口上的更改.

I tried to use IOServiceMatching(kIOUSBInterfaceClassName) from IOKit framework but i cannot monitor changes on Thunderbolt port.

有什么办法可以实现?感谢您的帮助.

Is there any way i can achieve it? Any help is appreciated.

推荐答案

Thunderbolt设备(使用Thunderbolt端口的DisplayPort部分的显示器除外)是PCI设备,而不是USB,因此它们将在IOService注册表中显示为IOPCIDevice s.但是,它们还将在Thunderbolt子树中显示为IOThunderboltPort对象,其中的"PCI Path"属性将指示到相关IOPCIDevice的IOService路径.通过监视IOThunderboltPort服务的出现和消失,并检查它们的PCI Path属性,可以避免匹配其他类型的PCI设备.

Thunderbolt devices (except displays that use the DisplayPort portion of the Thunderbolt port) are PCI devices, not USB, so they will show up in the IOService registry as IOPCIDevices. They will however also show up as IOThunderboltPort objects in the Thunderbolt subtree, where the "PCI Path" property will indicate the IOService path to the relevant IOPCIDevice. By monitoring the appearance and disappearance of IOThunderboltPort services, and checking their PCI Path property, you can avoid matching other kinds of PCI devices.

为说明我在说什么,请打开IORegistryExplorer或IOJones并热插入Thunderbolt设备;您应该同时看到IOThunderboltPort(和许多其他类型的相关对象,例如AppleThunderboltPCIUpAdapter等)和IOPCIDevice(以及通过Thunderbolt总线工作的PCI2PCI桥). (或者,您可以使用ioreg在热插拔之前和之后拍摄快照.)

To illustrate what I'm talking about, open up IORegistryExplorer or IOJones and hotplug a Thunderbolt device; you should see both the IOThunderboltPort (and a bunch of other types of related object, such as AppleThunderboltPCIUpAdapter etc.) and the IOPCIDevice (as well as the PCI2PCI bridges via which the Thunderbolt bus works) appear. (Alternatively you can use ioreg to take snapshots before and after the hotplug.)

因此,总而言之,我将匹配IOThunderboltPort服务,忽略没有PCI路径属性的任何服务,并在IO注册表中查找相应的IOPCIDevice以使它们到达实际设备.

So in summary, I would match IOThunderboltPort services, ignore any without a PCI path property, and look up the corresponding IOPCIDevice in the IO Registry for the ones that have it to get to the actual device.

这篇关于监控Thunderbolt端口连接上的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆