Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SerialPort] existing port must be the same device #144

Merged
merged 2 commits into from
Jun 14, 2019

Conversation

KevinVitale
Copy link
Contributor

@KevinVitale KevinVitale commented Apr 25, 2019

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.

1 /dev/cu.usbserial-1410 (29987, 6790) 48643
2 /dev/cu.usbserial-1410 (9223372036854775807, 9223372036854775807) 48643

However, when applying this change, IORegistryEntryCreateIterator will work correctly:

1 /dev/cu.usbserial-1410 (29987, 6790) 48643
2 /dev/cu.usbserial-1410 (29987, 6790) 59155

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 the
`ORSSerialPortManager` to keep ports with valid paths, but
invalid `ioKitDevice` values, thus making subsequent calls to
`IORegistryEntryCreateIterator` ineffectual.
@KevinVitale
Copy link
Contributor Author

@armadsen ping (╹◡╹)

@armadsen armadsen self-assigned this Jun 14, 2019
@armadsen armadsen added the bug label Jun 14, 2019
@armadsen armadsen added this to the 2.0.3 milestone Jun 14, 2019
@armadsen armadsen merged commit e54482a into armadsen:master Jun 14, 2019
@armadsen
Copy link
Owner

Thanks so much for this, Kevin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants