Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:32 28 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Serial Port Tracker for Windows

Author Message
pwillard
Senior Member

Joined: 07/06/2022
Location: United States
Posts: 292
Posted: 02:47pm 15 Aug 2023
Copy link to clipboard 
Print this post

There are times when I want to know which serial ports are active on my windows PC.

While I *could* fire up TeraTerm to see the list... I sort of wanted to have a little window where I could see active ports.

Result: This super-simple python script...

I figured I would just share it.

#-------------------------------------------------------------------------------
# Name:        SerialTracker.py
# Purpose:     Simple tracker for active serial ports attached to windows PC
#
# Author:      Pete Willard
#
# Created:     15/08/2023
# Copyright:   (c) willard 2023
# Licence:     CC BY-NC-SA
#-------------------------------------------------------------------------------
import serial.tools.list_ports
import time
import PySimpleGUI as sg

def main():
   layout = [
       [sg.Text("Available Serial Ports:")],
       [sg.Listbox(values=[], size=(40, 10), key="-PORTS-")],
       [sg.Button("Exit")]
   ]

   window = sg.Window("Port Tracker", layout)

   while True:
       event, values = window.read(timeout=1000)  # Auto-update every 1000 milliseconds

       if event == sg.WINDOW_CLOSED or event == "Exit":
           break

       refresh_ports(window)

   window.close()

def refresh_ports(window):
   ports = [port.device for port in serial.tools.list_ports.comports()]
   window["-PORTS-"].update(values=ports)

if __name__ == "__main__":
   main()



github
 
DaveJacko
Regular Member

Joined: 25/07/2019
Location: United Kingdom
Posts: 76
Posted: 10:04pm 15 Aug 2023
Copy link to clipboard 
Print this post

I'm a purist..
could this be done with MMBasic for DOS ?
Thanks Pete,
personally think MMBasic could run the world.
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1057
Posted: 11:10pm 15 Aug 2023
Copy link to clipboard 
Print this post

TassyJim's MMCC also gives a good indication of ports added or removed but that would need firing up as well.

I also use this Windows one here

Brian
Edited 2023-08-16 09:58 by Chopperp
ChopperP
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024