From 820cffa34181a301eae8e3e2397aa4240fab0387 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Sat, 18 Apr 2020 22:22:31 +0100 Subject: [PATCH] Added doc for new USB Product field (windows-only) --- enumerator/enumerator.go | 5 ++++- portlist/portlist.go | 16 +++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/enumerator/enumerator.go b/enumerator/enumerator.go index 91bb6e3..41f88fe 100644 --- a/enumerator/enumerator.go +++ b/enumerator/enumerator.go @@ -18,7 +18,10 @@ type PortDetails struct { SerialNumber string // Manufacturer string - Product string + + // Product is an OS-dependent string that describes the serial port, it may + // be not always available and it may be different across OS. + Product string } // GetDetailedPortsList retrieve ports details like USB VID/PID. diff --git a/portlist/portlist.go b/portlist/portlist.go index 5a55435..cbf4c8c 100644 --- a/portlist/portlist.go +++ b/portlist/portlist.go @@ -15,9 +15,12 @@ // package main -import "fmt" -import "log" -import "go.bug.st/serial/enumerator" +import ( + "fmt" + "log" + + "go.bug.st/serial/enumerator" +) func main() { ports, err := enumerator.GetDetailedPortsList() @@ -29,9 +32,12 @@ func main() { } for _, port := range ports { fmt.Printf("Port: %s\n", port.Name) + if port.Product != "" { + fmt.Printf(" Product Name: %s\n", port.Product) + } if port.IsUSB { - fmt.Printf(" USB ID %s:%s\n", port.VID, port.PID) - fmt.Printf(" USB serial %s\n", port.SerialNumber) + fmt.Printf(" USB ID : %s:%s\n", port.VID, port.PID) + fmt.Printf(" USB serial : %s\n", port.SerialNumber) } } }