libudev-dev, finding serial ports
C.G.
crisgyorgus at gmail.com
Tue Nov 19 17:37:45 GMT 2019
Dear maintainers,
I apologize if there was a better source for the information I search,
than writing to you (I imagine you are busy enough...).
I try to write a C function to identify the available real serial
(UART) ports on a PC without trying to open them, but I cannot figure
out the best way. I also googled (duckduckgo-ed :) ) the internet, but
no real answers.
I tried 2 approaches: one by using libudev and the other by reading
information directly from /sys/class/tty/ file system (and following
the symlinks). In both approaches I can easily isolate the tty
subsystem and list devices, but in the end I need to open the remaining
ports in order to check their status.
The closest I came was by reading /sys/class/tty and eliminating all
virtual entries, but I still remain with up to 32 serial ports of type
serial8250, depending on linux distribution.
The USB-serial converters are easy to identify, but with built-in
serial ports it's not that easy.
Please tell what is the right way to find the available serial ports on
a system, without trying to open them all.
Thank you!
Best regards,
Cristian
More information about the Pkg-systemd-maintainers
mailing list