PDA

View Full Version : Getting system to re-recognize an "unknown" Firewire device




brianus
Aug 30, 2007, 03:53 PM
I'm writing a small command line utility that does nothing but disconnect and reconnect a badly behaved FireWire device (I often have to do this physically, so I want a software equivalent that can be automated). I've gotten the disconnection down (using the firewire device interface's Seize() function), but I can't get the system to re-recognize the device. I'm told by the ADC documentation that calling Close() and IOServiceRequestProbe() after having Seize()'d the device, will '[make] it appear that the device has been "re-plugged"', but it doesn't seem to have that effect. Instead, the device shows up in SystemProfiler as "Unknown Device." It can still be accessed programmatically, but the system no longer recognizes it. Any ideas?


io_object_t aDevice;
IOCFPlugInInterface **cfPlugInInterface(0);
SInt32 theScore;
IOFireWireLibDeviceRef fwDeviceInterface(0);
bool found(false);
while (aDevice = IOIteratorNext(iterator)) {
if ((kIOReturnSuccess == IOCreatePlugInInterfaceForService(
aDevice,
kIOFireWireLibTypeID,
kIOCFPlugInInterfaceID,
&cfPlugInInterface,
&theScore
)
) && cfPlugInInterface && (kIOReturnSuccess == (*cfPlugInInterface)->QueryInterface(
cfPlugInInterface,
CFUUIDGetUUIDBytes(kIOFireWireDeviceInterfaceID),
reinterpret_cast<void **>(&fwDeviceInterface)
)
)) {
found = true;
break;
}
}
if (found) {
(*fwDeviceInterface)->Seize(fwDeviceInterface, NULL);
(*fwDeviceInterface)->Open(fwDeviceInterface);
(*fwDeviceInterface)->Close(fwDeviceInterface);
IOServiceRequestProbe(aDevice, 0);
}