14 #include <IOKit/IOKitLib.h>
15 #include <IOKit/serial/IOSerialKeys.h>
16 #include <IOKit/usb/USBSpec.h>
23 "title" :
"VuoSerialDevices",
25 "CoreFoundation.framework",
30 "VuoList_VuoSerialDevice",
44 CFStringRef valueCF = (CFStringRef)IORegistryEntryCreateCFProperty(o, property, NULL, 0);
53 kern_return_t ret = IORegistryEntryGetParentIterator(o, kIOServicePlane, &it);
54 if (ret != KERN_SUCCESS)
56 VUserLog(
"Error: Couldn't get parent iterator: %d", ret);
61 while ( (po = IOIteratorNext(it)) )
82 CFMutableDictionaryRef match = IOServiceMatching(kIOSerialBSDServiceValue);
85 VUserLog(
"Error: Couldn't create serial matching dictionary.");
88 CFDictionarySetValue(match, CFSTR(kIOSerialBSDTypeKey), CFSTR(kIOSerialBSDAllTypes));
91 kern_return_t ret = IOServiceGetMatchingServices(kIOMasterPortDefault, match, &it);
92 if (ret != KERN_SUCCESS)
94 VUserLog(
"Error: Couldn't get serial device list: %d", ret);
100 while ( (o = IOIteratorNext(it)) )
103 device.
matchType = VuoSerialDevice_MatchPath;
108 VUserLog(
"Error: Device %d has no path.", o);
113 if (strstr(device.
path,
"-Wireless")
114 || strstr(device.
path,
"Bluetooth-"))
129 if (vendorName && productName && serialNumber)
131 else if (vendorName && productName)
133 else if (vendorName && serialNumber)
135 else if (productName && serialNumber)
139 else if (productName)
145 device.
name = ttyDevice;
171 while (IOIteratorNext(it));
190 VUserLog(
"Error: Couldn't create serial notification port.");
195 if (!notificationSource)
197 VUserLog(
"Error: Couldn't get serial notification source.");
201 CFRunLoopAddSource(CFRunLoopGetMain(), notificationSource, kCFRunLoopCommonModes);
204 CFMutableDictionaryRef match = IOServiceMatching(kIOSerialBSDServiceValue);
207 VUserLog(
"Error: Couldn't create serial matching dictionary.");
210 CFDictionarySetValue(match, CFSTR(kIOSerialBSDTypeKey), CFSTR(kIOSerialBSDAllTypes));
218 if (ret != KERN_SUCCESS)
220 VUserLog(
"Error: Couldn't create serial-add notification: %d", ret);
224 while (IOIteratorNext(it));
228 if (ret != KERN_SUCCESS)
230 VUserLog(
"Error: Couldn't create serial-remove notification: %d", ret);
234 while (IOIteratorNext(it));
247 VUserLog(
"Error: Unbalanced VuoSerial_use() / _disuse() calls.");