Add new command to do a basic JSON dump of a Reachview module configuration
Pyxis/orion/develop Something is wrong with the build of this commit
Details
Pyxis/orion/develop Something is wrong with the build of this commit
Details
This commit is contained in:
parent
98e33af1e5
commit
b8a07953dd
|
@ -0,0 +1,64 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"forge.cadoles.com/Pyxis/orion/emlid"
|
||||
"forge.cadoles.com/Pyxis/orion/emlid/reachview"
|
||||
)
|
||||
|
||||
var (
|
||||
host = "192.168.42.1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&host, "host", host, "ReachRS module host")
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
flag.Parse()
|
||||
|
||||
c := connect()
|
||||
defer c.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
config, err := c.Configuration(ctx)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
data, err := json.MarshalIndent(config, "", " ")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println(string(data))
|
||||
|
||||
log.Println("done")
|
||||
|
||||
}
|
||||
|
||||
func connect() *reachview.Client {
|
||||
|
||||
c := reachview.NewClient(
|
||||
emlid.WithEndpoint(host, 80),
|
||||
)
|
||||
|
||||
log.Printf("connecting to module '%s'", host)
|
||||
if err := c.Connect(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Println("connected")
|
||||
|
||||
return c
|
||||
|
||||
}
|
Reference in New Issue