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

Symlink b #41

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Symlink b #41

wants to merge 6 commits into from

Conversation

mechsin
Copy link

@mechsin mechsin commented Mar 5, 2021

I submitted a pull request on the official sigrok repo with this same change but it seems like your repo gets a bit more action. So I though I would post a PR here as well. I am new to this so let me know if there are any issues with what I have done.

I like to add the ability for libserialport to recognize and use symlinks on Linux. This is primarily in support of the Arduino IDE which uses libserialport to enumerate and list serial ports however it seems like it would be beneficial to any libserialport users. Symlinks are created on Linux when udev rules are used to map a specific device or class of devices to a symlink. In order to accommodate this I have added code to find symlinks base on TTY devices found and then I removed a block of code that ensure a real path was passed to the serial port creator and moved this call in the Linux only portion of the code. Based on some research Mac OSX doesn't seem allow for symlink serial ports and there was a guard on the code already to stop it from running on Windows so that leaves BSD which I am unfamiliar with. I am sure BSD allows for symlinks but it doesn't look like it uses the same path searching method to determine port characteristics so I though moving that bit of code would be safe. I have another version of this feature where I added a realpath element to the sp_port struct. This would leave that realpath block in place but assign that real path to the struct there however that seemed more error prone. I was able to get all of the examples to run with my code modifications.

The only other note is that there is two commits here the first adds the code to allow the symlinks to be found. The second moves the realpath code to allow the symlink port names to pass through.

uwehermann and others added 6 commits March 26, 2020 22:38
The above function must always return an 'enum sp_transport'. So, return
NATIVE if no port is present because its effective meaning within the
API is "you shouldn't call any transport-specific functions for this
port handle".

Fixes bug #1531.

Signed-off-by: Wolfram Sang <[email protected]>
The comment and code are out of sync. The comments say "leave control
lines alone on close." The HUPCL bit, when set, will "Lower modem control
lines after last process closes the device (hang up)."

To match the intent captured in the comment, the HUPCL bit should be
cleared.

Signed-off-by: Ben Gardiner <[email protected]>
This code as commited allows the symlinks for a any device to
be found. I only need to add a few variables and reuse ones from
the device finder loop.
This is a slightly different approch to fixing the issue with the
way the port details are resovled on linux. Currently the symlink
is converted to a real path in the serialport.c however if I
remove this code and move it to the get_port_details in the
linux.c everything seems to work fine. I don't believe this
will effect Mac and there was a Windows guard on the code
any way so the only implementation this might cause problems
for is BSD. Otherwise this is less envasive because we aren't
updating the port struct.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants