MACRAW IP stack with ARP/ICMP, stable device ordering, LED blink on test
This commit is contained in:
@@ -3,6 +3,7 @@ package client
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -15,12 +16,23 @@ func ListSerial() ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("enumerating ports: %w", err)
|
||||
}
|
||||
var result []string
|
||||
type entry struct {
|
||||
name string
|
||||
serial string
|
||||
}
|
||||
var entries []entry
|
||||
for _, p := range ports {
|
||||
if p.IsUSB && p.VID == "2E8A" && strings.HasPrefix(p.Name, "/dev/cu.") {
|
||||
result = append(result, p.Name)
|
||||
entries = append(entries, entry{p.Name, p.SerialNumber})
|
||||
}
|
||||
}
|
||||
slices.SortFunc(entries, func(a, b entry) int {
|
||||
return strings.Compare(a.serial, b.serial)
|
||||
})
|
||||
var result []string
|
||||
for _, e := range entries {
|
||||
result = append(result, e.name)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user