[SerialPort] existing port must be the same device #144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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, butwith 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.