Deutsch English Français Italiano |
<20240619155514.0de69cf3@officepc> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!feed.opticnetworks.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Scott Pitcher <scotty@svptechnicalservices.com.au> Newsgroups: comp.lang.tcl Subject: Re: How do I to detect ACTIVE serial communications ports in Linux? Date: Wed, 19 Jun 2024 15:55:25 +1000 Organization: SVP TECHNICAL SERVICES Lines: 51 Message-ID: <20240619155514.0de69cf3@officepc> References: <ld3sb0Fm1o7U1@mid.individual.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Date: Wed, 19 Jun 2024 07:55:27 +0200 (CEST) Injection-Info: dont-email.me; posting-host="03af1b289d35786ddf12eefeeb5b1710"; logging-data="1907419"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+A7oO72sqVnQTG+LfVssVJwkfTdRRRZ7Q=" Cancel-Lock: sha1:OsHlqM8zWVktLKeejV/CsXIM23s= X-Newsreader: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Bytes: 2575 On Fri, 14 Jun 2024 14:51:28 -0700 tcl@use.invalid 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