• How do I to detect ACTIVE serial communications ports in Linux?

    From [email protected]@21:1/5 to All on Fri Jun 14 14:51:28 2024
    How do I to detect ACTIVE serial communications ports in Linux?


    I know about the Windows process, but don't know about the process to find active communication ports in Linux.

    TIA.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Pitcher@21:1/5 to All on Wed Jun 19 15:55:25 2024
    On Fri, 14 Jun 2024 14:51:28 -0700
    [email protected]d wrote:

    You might have come across a discussion on stackexchange but if not: https://stackoverflow.com/questions/2530096/how-to-find-all-serial-devices-ttys-ttyusb-on-linux-without-opening-them#9914339

    I implemented this code which looks in /sys/class/tty, and for each
    console device checks for the existance of a device/id file. You could
    also look for device/resources. Those two seem to only exist for
    devices which are present on the system. I haven't confirmed how
    portable this is. Certainly on this desktop is shows only ttyS0. On the
    server which has no serial port it shows nothing. On the other server
    it also shows only ttyS0. I haven't confirmed USB devices yet.

    proc getSystemSerialPortList {} {
    variable Logkey

    set result ""

    set sysdir "/sys/class/tty"

    if {[file exists $sysdir] && [file isdirectory $sysdir]} {
    foreach tty [glob -dir $sysdir -tails *] {
    set ttydevid [file join $sysdir $tty device id]
    if {[file exists $ttydevid] && [file isfile $ttydevid]} {
    lappend result $tty
    }
    }
    }

    return $result
    }

    How do I to detect ACTIVE serial communications ports in Linux?


    I know about the Windows process, but don't know about the process to
    find active communication ports in Linux.

    TIA.




    --
    +---------|------------------------+
    | --+-- |
    | ___|_____ |
    | ~~~~~\_______/~~~~~~~~~~~~~~~~~ |
    +----------------------------------+d

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)