-
Notifications
You must be signed in to change notification settings - Fork 87
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
Increase max class string length to 64 #14
Conversation
@gsigh it would be great if you could have a look at this PR. It resolved an obvious overflow error that causes libserialport not not behave the way it should. |
Tested to be working with CH340, under macOS 14.3 with Mac Mini M1 2020. Take note 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.
|
@gsigh @martinling please have a look at this when you have time. Currently, libserialport does not work with several USB to serial chips on the latest macOS 14.3, due to the descriptor string being longer than 16 characters. Most likely because Apple has made some changes to the serial driver(s). #9 is a different approach to the same problem. However, this one is a lot simpler, and just fixes the bug. |
Increase max class string length to 64 See sigrokproject#14 for details
Does the merging of this PR mean that #9 can be closed without merging or are there any other issues that this PR doesn't cover? |
Thanks for merging @abraxa! Would it be possible to do a new release? This is kind of a big deal on macOS, since lots of USB to serial adapters doesn't work with macOS without this PR (CP210x, CH340, etc). Avrdude is using libserialport, and the only alternative for macOS users is to recommend them to installed a patched version of libavrdude before building and installing Avrdude. You can safely close #9. I did a lot of research before I created this PR, and the root cause was that Apple had changed the device descriptor, so that it would no longer fit inside the 16 byte buffer. |
Yeah, I'm currently merging what can be safely merged so that I can make a release. Thanks, I'll close #9 then. |
That's great news! Thank you for doing this @abraxa! EDIT: I forgot to mention that when I first submitted this PR, I was using macOS 10.14 (Mojave), and only the Silabs CH210x chips were affected by the bug. However, when I upgraded to macOS 12 (Monterey), the CH340 chips was suddenly also affected. |
#9 points out that Silabs CP210x chips don't work properly with libserialport. However, the attempted fix is a bit drastic, and only fix the symptom and not the problem.
After a bit of research, I'm pretty sure I've figured out the root cause.
libserialport/macosx.c
Line 39 in 6f9b03e
The
class
string can only hold 16 characters, and this is fine if the assigned string is 16 characters long or less. However, the SilabsCFSTR("IOProviderClass")
returns "IOUSBHostInterface", which is longer than 16 characters. Other USB to serial chips returns "IOUSBInterface", which is barely less than 16 bytes.So all this simple PR does is increase the maximum length the
class
string can have.Here's the output from the port_info example:
Without this PR:
With this PR:
@martinling it would be great if you could review this and hopefully merge it. It would be awesome to have a libserialport version that works with Silabs chips on macOS!