Streams H.264 to the Galahad II LCD via USB (gousb) with: - ffmpeg CLI transcoding (no fragile FFmpeg C-ABI bindings) - pure-Go Annex-B access-unit splitting - framerate pacing with graceful shutdown and USB reconnect - TOML config, cobra CLI, structured slog logging, unit tests
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
"text/tabwriter"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"galahad2lcd/internal/device"
|
|
)
|
|
|
|
func newListCmd() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "list",
|
|
Short: "List USB devices visible to the driver",
|
|
Args: cobra.NoArgs,
|
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
|
ctx, stop := newSignalContext()
|
|
defer stop()
|
|
|
|
infos, err := device.ListDevices(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if len(infos) == 0 {
|
|
fmt.Fprintln(cmd.OutOrStdout(), "no USB devices found (are permissions configured?)")
|
|
return nil
|
|
}
|
|
|
|
sort.Slice(infos, func(i, j int) bool {
|
|
return infos[i].Bus < infos[j].Bus ||
|
|
(infos[i].Bus == infos[j].Bus && infos[i].Address < infos[j].Address)
|
|
})
|
|
|
|
w := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 4, 2, ' ', 0)
|
|
fmt.Fprintln(w, "BUS\tADDR\tVID:PID\tPRODUCT\t")
|
|
for _, info := range infos {
|
|
product := info.Product
|
|
if product == "" {
|
|
product = "-"
|
|
}
|
|
marker := " "
|
|
if info.IsLCD {
|
|
marker = "*"
|
|
}
|
|
fmt.Fprintf(w, "%s%d\t%d\t%04x:%04x\t%s\t\n",
|
|
marker, info.Bus, info.Address, info.VendorID, info.ProductID, product)
|
|
}
|
|
fmt.Fprintln(w, "* Lian Li Galahad II LCD (0416:7395)")
|
|
return w.Flush()
|
|
},
|
|
}
|
|
}
|