From b8ef4d11fe0d00ce0884ccf982675845b20c3ce9 Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 30 May 2024 16:00:32 +0200 Subject: software: Implement serial port detection --- software/communication/physical.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 software/communication/physical.go (limited to 'software/communication') diff --git a/software/communication/physical.go b/software/communication/physical.go new file mode 100644 index 0000000..25d5299 --- /dev/null +++ b/software/communication/physical.go @@ -0,0 +1,28 @@ +package communication + +import ( + "go.bug.st/serial/enumerator" +) + +const ( + ST_VID = `0483` +) + +func GetStSerials() ([]string, error) { + retval := make([]string, 0) + + ports, err := enumerator.GetDetailedPortsList() + if err != nil { + return retval, err + } + + for _, port := range ports { + if port.IsUSB { + if port.VID == ST_VID { + retval = append(retval, port.Name) + } + } + } + + return retval, nil +} -- cgit v1.2.3-70-g09d2