-
Notifications
You must be signed in to change notification settings - Fork 86
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
Simplify determination of transport #9
Conversation
Cross-referencing discussion at: https://sigrok.org/bugzilla/show_bug.cgi?id=1698 |
@martinling is there any progress regarding this issue? We're currently implementing libserialport into the Avrdude project for supporting "Automatic port discovery", and no Silabs USB to serial adapter chip (I've tried with CP2102N and CP2104) can be used with libserialport on MacOS (10.14). I've tried a bunch of other adapters, both "standard" ones (FT232R, PL2303, FT231X, CH340, CP210x) and manufacturer-specific ones (Arduino UNO/MEGA/UNO Wifi Rev2/Nano Every, Microchip ATmega4809 Curiosity Nano), and I've only had issues with the CP210x chips. It would be awesome if someone could look into this! |
For the Avrdude project, it's very convenient that libserialport is able to list ports that are native as well. It's nice to provide a list to the user of all available serial ports, not just those that are native. Determining if a port is native is as simple as checking if |
It looks like I was a bit too quick to conclude. After a bit of testing, it seems like this PR works great, and it's still able to find and list native serial ports (in my case, So after all, it might be a good idea to flag a port as native if there's no VID and PID. |
@martinling Sorry for all the noise, but I went down the rabbit hole to try to figure out why the Silabs chips isn't "detected" by And it turns out that it's a very easy fix to all this. Have a look at the following code: Lines 65 to 87 in 6f9b03e
It turns out that the The string The second string, The reason why this works for other USB to serial chips is that their CFSTR("IOProviderClass") is So this is the solution: diff --git a/macosx.c b/macosx.c
index a0df84e..6c93d2c 100644
--- a/macosx.c
+++ b/macosx.c
@@ -36,7 +36,7 @@ SP_PRIV enum sp_return get_port_details(struct sp_port *port)
io_object_t ioport, ioparent;
CFTypeRef cf_property, cf_bus, cf_address, cf_vendor, cf_product;
Boolean result;
- char path[PATH_MAX], class[16];
+ char path[PATH_MAX], class[64];
DEBUG("Getting serial port list");
if (!(classes = IOServiceMatching(kIOSerialBSDServiceValue))) |
I have tested this PR and it is working with CH340, under macOS 14.3 with Mac Mini M1 2020. Current git does not work. |
This PR also works with FT232R.
Current git does not work.
|
This PR works with CP2102 as well.
Current git does not work.
|
Closing this PR as #9 has been merged instead. Thanks to everyone who worked on this topic! |
This code change makes so that a port is a considered a USB port if and only if it has a USB Vendor ID / Product ID combo. The old method was more complicated and was failing for the CP2102 chip.