From 27f0e349ba9f0b09906b770f069f43c50eb9a3d1 Mon Sep 17 00:00:00 2001 From: saji <9110284+kschamplin@users.noreply.github.com> Date: Wed, 10 May 2023 01:13:04 -0500 Subject: [PATCH] fix xbee cli info --- cmd/gotelem/cli/xbee.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/gotelem/cli/xbee.go b/cmd/gotelem/cli/xbee.go index 408fba1..b15ee34 100644 --- a/cmd/gotelem/cli/xbee.go +++ b/cmd/gotelem/cli/xbee.go @@ -5,6 +5,7 @@ package cli import ( "context" + "encoding/binary" "fmt" "io" "os" @@ -78,6 +79,11 @@ writtend to stdout. `, Action: netcat, HideHelpCommand: true, + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "hex", + }, + }, }, }, } @@ -85,7 +91,7 @@ writtend to stdout. func xbeeInfo(ctx *cli.Context) error { logger := slog.New(slog.NewTextHandler(os.Stderr)) - transport := ctx.Context.Value(keyIODevice).(xbee.Transport) + transport := ctx.Context.Value(keyIODevice).(*xbee.Transport) xb, err := xbee.NewSession(transport, logger.With("device", transport.Type())) if err != nil { return cli.Exit(err, 1) @@ -95,7 +101,7 @@ func xbeeInfo(ctx *cli.Context) error { if err != nil { return cli.Exit(err, 1) } - fmt.Println(b) + fmt.Printf("Network ID: %X\n", binary.BigEndian.Uint16(b)) return nil } @@ -109,7 +115,7 @@ func netcat(ctx *cli.Context) error { } logger := slog.New(slog.NewTextHandler(os.Stderr)) - transport := ctx.Context.Value(keyIODevice).(xbee.Transport) + transport := ctx.Context.Value(keyIODevice).(*xbee.Transport) xb, _ := xbee.NewSession(transport, logger.With("devtype", transport.Type())) sent := make(chan int64)