nub:
an object that defines an access point and communication channel for a phyiscal device(such as disk drive and bus) or a logical service(such as driver matcing)
I/O registry: track live(instantiated) object
I/O category: track all I/O kit classes available on the system
(1) get the i/o kit master port
use kIOMasterPortDefault ( pass kIOMasterPortDefault to the function that requires master port)
(2) create a matching dictionary:
method 1( match IOProviderClass):
ex:
CFMutableDictionaryRef myUSBMatchDictionary = NULL;
myUSBMatchDictionary = IOServiceMatching("IOUSBInterface");
find the devices with IOProviderClass = "IOUSBInterface"
method 2:
create a matching dictionary that defines which device to access
a matching directory is a CFMutableDictionaryRef object, containing a set of key-value pairs that describe device properties
use CFDictionaryCreateMutable to create. CFDictionaryCreateMutable is defined in CoreFoundation.
use CFDictionarySetValue to set property.
ex:
CFMutableDictionaryRef mySubDictionary;
mySubDictionary = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(mySubDictionary, CFSTR(kMyDevicePropertyKey),
CFSTR(kMyDevicePropertyValue));
CFMutableDictionaryRef myMatchingDictionary;
myMatchingDictionary = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(myMatchingDictionary, CFSTR(kIOPropertyMatchKey),
mySubDictionary);
(3) looking up devices in I/O registry
use IOServiceGetMatchingServices to find devices that match the passed-in matching dictionary. It suppies IOIterator object that you can use to access matching devices
2008年1月13日 星期日
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言