Comparing only the path between an existing port and a new port is not enough when considering equality. Doing so causes the ORSSerialPortManager to keep ports with valid paths, but
with invalid (terminated) IOKitDevice objects, thus making subsequent calls to IORegistryEntryCreateIterator ineffectual.
Shown below is my own output for this code example to retrieve product and vendor IDs. After being removed at least once, calls to the IORegistryEntryCreateCFProperties function will no longer return any attributes for the port's IOKitDevice, since that object has become invalid (terminated). Yet, KVO changes on availablePorts continue to include the ORSSerialPort port, so long as it is connected to the same path.
1 is the rawValue for the KVO Kind change;
/dev/cu.usbserial-1410 is the port's path;
the tuple is kUSBProductID & kUSBVendorID, respectively; and
48643 is the io_object_t's numeric value.
Note: I'm defaulting to NSNotFound when ID values return nil.
Notice that the io_object_t's numeric value has been changed to the valid (connected) port, and that the product and vendor ID's are now correct. The path hasn't changed.
Comparing only the
path
between an existing port and a new port is not enough when considering equality. Doing so causes theORSSerialPortManager
to keep ports with valid paths, but with invalid (terminated)IOKitDevice
objects, thus making subsequent calls toIORegistryEntryCreateIterator
ineffectual.Shown below is my own output for this code example to retrieve product and vendor IDs. After being removed at least once, calls to the
IORegistryEntryCreateCFProperties
function will no longer return any attributes for the port'sIOKitDevice
, since that object has become invalid (terminated). Yet, KVO changes onavailablePorts
continue to include theORSSerialPort
port, so long as it is connected to the samepath
.1
is therawValue
for the KVOKind
change;/dev/cu.usbserial-1410
is the port'spath
;kUSBProductID
&kUSBVendorID
, respectively; and48643
is theio_object_t
's numeric value.However, when applying this change,
IORegistryEntryCreateIterator
will work correctly:Notice that the
io_object_t
's numeric value has been changed to the valid (connected) port, and that the product and vendor ID's are now correct. Thepath
hasn't changed.