(revised) test for linux serial ports


Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2541
Posted: 12:59pm 12 Dec 2024      

looks like with the release of kernel 6.8 the naming convention for fixed serial port driver has changed. this will cause problems for any program that makes use of the driver name being "serial8250" to determine if a port is fixed or removable. the symptom you see is a list of all 32 "/dev/ttySxx" being detected as live ports.

i found this out after moving from 21.3 to Linux Mint 22, which will only run with a 6.8 or later kernel  

attached is a test program that (maybe?) gets around this by (1) accepting a driver path starting with "/sys/bus/serial-base/" as indication that a port is fixed, (2) then making two different tests to see if there is hardware present - first attempting to read the pseudo-file /sys/class/tty/DeviceName/type, and if that fails falling back to using ioctl TIOCGSERIAL to get the port 'type'.

attached is a 64-bit LINUX CONSOLE test program to list the ports using the above 'revised' method. FPC source is included. i'd very much appreciate it if folks with 64-bit linux systems (both the pre-6.8 and later kernels) could try it out and post back to this thread the output generated. note: the test program should produce correct output for both old and new kernels.

ports (inc source).zip


cheers,
rob   :-)