私はIOUSBDeviceInterface245
を経由して、いくつかの情報(製品名)を取得しようとしている経由で中断したUSBデバイスに関する情報を収集します。
コード#1(IOKitのからのMac OS X上で)IOUSBDeviceInterface245
io_iterator_t iterator;
io_object_t usb_device
SInt32 score = 0;
kern_return_t kr = IOServiceGetMatchingServices(kIOMasterPortDefault,
IOServiceNameMatching("AppleUSBOHCI"),
&iterator);
IOCFPlugInInterface **plugin_interface = NULL;
IOUSBDeviceInterface245 **usb_interface = NULL;
// ...
// enumerate devices (usb_device = IOIteratorNext(iterator))
// ...
IOReturn return_code = IOCreatePlugInInterfaceForService(usb_device,
kIOUSBDeviceUserClientTypeID,
kIOCFPlugInInterfaceID,
&plugin_interface,
&score);
HRESULT h_result = (*pluginInterface)->QueryInterface(pluginInterface,
CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID245),
(LPVOID)&usb_interface);
IODestroyPlugInInterface(pluginInterface);
UInt8 product_string_index;
return_code = (*usb_interface)->USBGetProductStringIndex(usb_interface,
&product_string_index);
// Next, getting a product string by string's index. To do so, we need to send
// IOUSBDevRequest (with type "kUSBRqGetDescriptor") to the current USB-device.
// Code bellow - is a pseudocode:
char *product_name = malloc(128);
get_string_by_index(usb_interface, product_string_index, product_string, 128);
このコードはすべての現用デバイスでうまくいきますが、中断(「スリープ」)のためには機能しません。
デバイス(product_name
は空の文字列です)。
しかし、私はこのコードを使用している場合:すべてですべてのデバイスのために働いて
コード#2
CFMutableDictionaryRef child_properties = CFDictionaryCreateMutable(NULL, 0,
NULL,NULL);
kern_return_t kr;
io_service_t io_service;
// iterator = iterator for "AppleUSBOHCI" or "AppleUSBEHCI" services
while((io_service = IOIteratorNext(iterator))) {
io_iterator_t children_iterator;
kernel_return = IORegistryEntryGetChildIterator(io_service, kIOServicePlane,
&children_iterator);
io_registry_entry_t child;
while((child = IOIteratorNext(children_iterator))) {
// Create a CFDictionary with usb-device's properties
IORegistryEntryCreateCFProperties(child, &child_properties,
kCFAllocatorDefault,
kNilOptions);
NSLog(@"%@",[(NSDictionary*)child_properties valueForKey:@"USB Product Name"]);
}
}
(私は理由を知りませんが)。
は、私は(コード#1を使用して)このコードによって中断デバイスをウェイクアップしてみました:(*usb_interface)->USBDeviceSuspend(usb_interface, false);
が、それは何も変わっていないです。私が気づい
一つのこと - コード#1が完全に(文字列の インデックスで取得)文字列値を除いて、眠っているデバイスのすべてのプロパティ のために働いています。
UPDATE:だから、私の質問は、私が最初のコードブロックで使用するための装置を一時停止を解除することができますどのように
ですか?
ありがとうございます。
ありがとうございます。はい、すでに2番目のコードを使用していますが、最初のコードを使用するためにデバイスを停止解除するにはどうすればよいですか? 'USBDeviceSuspend(x、** false **)'で可能でなければなりませんが、実際には動作しません。 –
'USBDeviceSuspend'呼び出しが返すのは何ですか?また、完全に別として、EHCI/OCHI/UHCIなどの子ではなく、IOUSBDeviceを反復することができます。 – Hasturkun
'USBDeviceSuspend'が' kIOReturnNotOpen'を返し、 'USBDeviceOpen'が' kIOReturnExclusiveAccess'を返します。すでに開いていますか?)。私はIOKitに全く入っていないので、IOUSBDeviceとAppleUSBEHCIを使って検索することの違いを教えてください(USBデバイスの階層を作るため)。 –