Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

brianus

macrumors 6502
Original poster
Jun 17, 2005
401
0
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?

Code:
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) {
	[b](*fwDeviceInterface)->Seize(fwDeviceInterface, NULL);
	(*fwDeviceInterface)->Open(fwDeviceInterface);
	(*fwDeviceInterface)->Close(fwDeviceInterface);
	IOServiceRequestProbe(aDevice, 0);[/b]
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.