• Find all COM ports (Windows)

    From Helmut Giese@hgiese@ratiosoft.com to comp.lang.tcl on Thu Jun 13 10:14:09 2024
    From Newsgroup: comp.lang.tcl

    Hello out there,
    is there a way to find all COM ports which currently exist on a
    Windows machine? IIRC I once had a twapi routine which could do that
    but either I am wrong or I cannot find it anymore.
    Any help will be greatly appreciated
    Helmut
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Ralf Fassel@ralfixx@gmx.de to comp.lang.tcl on Thu Jun 13 10:40:28 2024
    From Newsgroup: comp.lang.tcl

    * Helmut Giese <hgiese@ratiosoft.com>
    | is there a way to find all COM ports which currently exist on a
    | Windows machine? IIRC I once had a twapi routine which could do that
    | but either I am wrong or I cannot find it anymore.
    | Any help will be greatly appreciated

    Using the registry package:

    # Retrieve actually available com-ports from Windows registry.
    proc get_serial_ports_from_windows_registry {{hwpath 0}} {
    set ComPorts [list]
    #
    # Get available com-ports from windows registry
    #
    package require registry
    set serial_base "HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\SERIALCOMM"

    if {![catch { registry values $serial_base } values]} {
    foreach valueName $values {
    if {![catch {string trim [registry get $serial_base $valueName]} port]} {
    if {$hwpath} {
    lappend ComPorts "\\\\.\\$port"
    } else {
    lappend ComPorts $port
    }
    }
    }
    set ComPorts [lsort $ComPorts]
    }
    return $ComPorts
    }

    HTH
    R'
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From greg@gregor.ebbing@gmx.de to comp.lang.tcl on Thu Jun 13 20:52:53 2024
    From Newsgroup: comp.lang.tcl

    Am 13.06.24 um 10:14 schrieb Helmut Giese:
    Hello out there,
    is there a way to find all COM ports which currently exist on a
    Windows machine? IIRC I once had a twapi routine which could do that
    but either I am wrong or I cannot find it anymore.
    Any help will be greatly appreciated
    Helmut

    Hello,

    https://wiki.tcl-lang.org/page/serial+ports+on+Windows

    Gregor
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Helmut Giese@hgiese@ratiosoft.com to comp.lang.tcl on Fri Jun 14 17:09:18 2024
    From Newsgroup: comp.lang.tcl

    Hello Ralf;
    Using the registry package:

    # Retrieve actually available com-ports from Windows registry.
    proc get_serial_ports_from_windows_registry {{hwpath 0}} {
    set ComPorts [list]
    #
    # Get available com-ports from windows registry
    #
    package require registry
    set serial_base "HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\SERIALCOMM"

    if {![catch { registry values $serial_base } values]} {
    foreach valueName $values {
    if {![catch {string trim [registry get $serial_base $valueName]} port]} {
    if {$hwpath} {
    lappend ComPorts "\\\\.\\$port"
    } else {
    lappend ComPorts $port
    }
    }
    }
    set ComPorts [lsort $ComPorts]
    }
    return $ComPorts
    }

    HTH
    R'
    thanks a lot - this was really helpful. Alas, it turned out that this
    wasn't my real problem, so I will probably be back shortly - but then
    with another thread.
    Thanks again and have a nice weekend
    Helmut
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Helmut Giese@hgiese@ratiosoft.com to comp.lang.tcl on Fri Jun 14 17:15:34 2024
    From Newsgroup: comp.lang.tcl

    Hello Gregor
    Hello,

    https://wiki.tcl-lang.org/page/serial+ports+on+Windows

    wow, this page really seems to not let any question open. Alas, as I
    mentioned in my answer to Ralf I meanwhile discovered that this was
    not the real problem. But at least this question is solved once and
    for all - and tucked away in my archive.
    Thanks and have a nice weekend
    Helmut
    --- Synchronet 3.20a-Linux NewsLink 1.114