| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package main
- import (
- "encoding/hex"
- "flag"
- "fmt"
- "os"
- "prod2u6400-uartkit/internal/protocol"
- )
- func main() {
- mode := flag.String("mode", "set-all", "set-all, get-snapshot, or i2c-set-all")
- preset := flag.String("preset", "channel4", "channel4 or safe")
- flag.Parse()
- s := protocol.SetAll{}
- for i := range s.Front {
- s.Front[i] = 20
- }
- for i := range s.Rear {
- s.Rear[i] = 20
- }
- if *preset == "channel4" {
- for i := 18; i < 24; i++ {
- s.PTC[i] = 100
- }
- s.Front[3], s.Rear[3] = 30, 10
- } else if *preset != "safe" {
- fmt.Fprintln(os.Stderr, "unknown preset")
- os.Exit(2)
- }
- if *mode == "set-all" {
- b, _ := protocol.EncodeSetAll(s)
- fmt.Println(hex.EncodeToString(b))
- return
- }
- if *mode == "get-snapshot" {
- fmt.Println(hex.EncodeToString(protocol.EncodeGetSnapshot()))
- return
- }
- if *mode == "i2c-set-all" {
- p, _ := s.Payload()
- fmt.Printf("addr=0x%02X staging=0100%s command=001001\n", 0x2A, hex.EncodeToString(p))
- return
- }
- fmt.Fprintln(os.Stderr, "unknown mode")
- os.Exit(2)
- }
|