summaryrefslogtreecommitdiff
path: root/software/communication
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-05-30 16:00:32 +0200
committerxengineering <me@xengineering.eu>2024-05-30 16:00:32 +0200
commitb8ef4d11fe0d00ce0884ccf982675845b20c3ce9 (patch)
tree3beb57ff849ed74569ce325225bc819791c25a6a /software/communication
parenteab833271eeaa8d54991c11eccec9445f662a191 (diff)
downloadiot-core-b8ef4d11fe0d00ce0884ccf982675845b20c3ce9.tar
iot-core-b8ef4d11fe0d00ce0884ccf982675845b20c3ce9.tar.zst
iot-core-b8ef4d11fe0d00ce0884ccf982675845b20c3ce9.zip
software: Implement serial port detection
Diffstat (limited to 'software/communication')
-rw-r--r--software/communication/physical.go28
1 files changed, 28 insertions, 0 deletions
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
+}