-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: master
Are you sure you want to change the base?
Conversation
maartenbrock
commented
Jul 18, 2023
- /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.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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() |
There was a problem hiding this comment.
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:
drivers = open('/proc/tty/drivers').readlines() | |
with open('/proc/tty/drivers') as drivers_file: | |
drivers = drivers_file.readlines() |
There was a problem hiding this comment.
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?