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

/serial/tools/list_ports_linux.py: find ALL serial ports #709

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

Conversation

maartenbrock
Copy link

  • /serial/tools/list_ports_linux.py: find ALL serial ports Instead of creating some random set of patterns ask Linux what patterns it supports.
  • /serial/tools/list_ports_linux.py: optionally hide subsystems Instead of statically filtering out all 'platform' subsystem devices, accept a list of subsystems to hide. Many (embedded?) systems have real platform serial devices.

Instead of creating some random set of patterns ask Linux what
patterns it supports.
Instead of statically filtering out all 'platform' subsystem
devices, accept a list of subsystems to hide. Many (embedded?)
systems have real platform serial devices.
@Williangalvani
Copy link

Is there anything blocking this from being merged?


if include_links:
devices.update(list_ports_common.list_links(devices))
return [info
for info in [SysFS(d) for d in devices]
if info.subsystem != "platform"] # hide non-present internal serial ports
if not info.subsystem in hide_subsystems] # hide non-present internal serial ports

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

    return [info
            for info in map(SysFS, devices)
            if info.subsystem not in hide_subsystems]    # hide non-present internal serial ports

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way, as long as it gets fixed.

@patrickelectric
Copy link

ping @zsquareplusc

devices.update(glob.glob('/dev/rfcomm*')) # BT serial devices
devices.update(glob.glob('/dev/ttyAP*')) # Advantech multi-port serial controllers
devices.update(glob.glob('/dev/ttyGS*')) # https://www.kernel.org/doc/Documentation/usb/gadget_serial.txt
drivers = open('/proc/tty/drivers').readlines()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're leaking the fd here:

Suggested change
drivers = open('/proc/tty/drivers').readlines()
with open('/proc/tty/drivers') as drivers_file:
drivers = drivers_file.readlines()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! When can this be applied?

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

5 participants