i have a usb device and am writing an OS X app which sends it commands. it shows up in the ioRegistry as a IOUSBMassStorageDriver. i want to send it some commands but can't find specific enough information about how to do this. the following code finds a plain vanilla usb driver which apparently is not able to actually deliver my commands to the device. any help is appreciated. a book, a tutorial, sample code, anything which is specific about IOUSBMassStorageDriver
let matchingDict = { IOProviderClass : IOUSBDevice, idProduct : 58113, idVendor : 1238 }
var matchedIterator:io_iterator_t = 0
var removalIterator:io_iterator_t = 0
let notifyPort:IONotificationPortRef = IONotificationPortCreate(kIOMasterPortDefault)
IONotificationPortSetDispatchQueue(notifyPort, DispatchQueue(label: "IODetector"))
let matchingCallback:IOServiceMatchingCallback = { (userData, iterator) in
// Convert self to a void pointer, store that in the context, and convert it
let this = Unmanaged<TLUSBDeviceMonitor>.fromOpaque(userData!).takeUnretainedValue()
this.rawDeviceAdded(iterator: iterator)
}
let removalCallback: IOServiceMatchingCallback = {
(userData, iterator) in
let this = Unmanaged<TLUSBDeviceMonitor>.fromOpaque(userData!).takeUnretainedValue()
this.rawDeviceRemoved(iterator: iterator)
}
let selfPtr = Unmanaged.passUnretained(self).toOpaque()
IOServiceAddMatchingNotification(notifyPort, kIOFirstMatchNotification, matchingDict, matchingCallback, selfPtr, &matchedIterator)
IOServiceAddMatchingNotification(notifyPort, kIOTerminatedNotification, matchingDict, removalCallback, selfPtr, &removalIterator)