Serial port added notification
01/09/04 18:43
Any code for the task ?
Is there a way of being notified when a serial port has been added or removed (think plugging in and out a Keyspan serial adapter or something). I'd like to get away from polling…
void FTSWSerialPortRegistry_SerialPortServicePublished(void *refcon, io_iterator_t iterator)
{
io_object_t serialPortService;
while (serialPortService = IOIteratorNext(iterator)) {
[(FTSWSerialPortRegistry*)refcon serialPortServicePublished:serialPortService];
IOObjectRelease(serialPortService);
}
}
void FTSWSerialPortRegistry_SerialPortServiceTerminated(void *refcon, io_iterator_t iterator)
{
io_object_t serialPortService;
while (serialPortService = IOIteratorNext(iterator)) {
[(FTSWSerialPortRegistry*)refcon serialPortServiceTerminated:serialPortService];
IOObjectRelease(serialPortService);
}
}
See also Apple's USBNotification Example (for add/remove notifications) and SerialPortSample (for general serial port stuff) at ADC.
void FTSWSerialPortRegistry_SerialPortServicePublished(void *refcon, io_iterator_t iterator)
{
io_object_t serialPortService;
while (serialPortService = IOIteratorNext(iterator)) {
[(FTSWSerialPortRegistry*)refcon serialPortServicePublished:serialPortService];
IOObjectRelease(serialPortService);
}
}
void FTSWSerialPortRegistry_SerialPortServiceTerminated(void *refcon, io_iterator_t iterator)
{
io_object_t serialPortService;
while (serialPortService = IOIteratorNext(iterator)) {
[(FTSWSerialPortRegistry*)refcon serialPortServiceTerminated:serialPortService];
IOObjectRelease(serialPortService);
}
}
See also Apple's USBNotification Example (for add/remove notifications) and SerialPortSample (for general serial port stuff) at ADC.