mirror of https://bitbucket.org/ausocean/av.git
cmd/revid-cli: replaced use of send() with netsender.Run() and implemented readPin func.
This commit is contained in:
parent
934653991d
commit
f67fb1ec8a
|
@ -40,6 +40,7 @@ import (
|
|||
"bitbucket.org/ausocean/av/stream/mts"
|
||||
"bitbucket.org/ausocean/av/stream/mts/meta"
|
||||
"bitbucket.org/ausocean/iot/pi/netsender"
|
||||
"bitbucket.org/ausocean/iot/pi/sds"
|
||||
"bitbucket.org/ausocean/iot/pi/smartlogger"
|
||||
"bitbucket.org/ausocean/utils/logger"
|
||||
)
|
||||
|
@ -267,8 +268,7 @@ func run(cfg revid.Config) error {
|
|||
var vars map[string]string
|
||||
|
||||
// initialize NetSender and use NetSender's logger
|
||||
var ns netsender.Sender
|
||||
err := ns.Init(log, nil, nil, nil)
|
||||
ns, err := netsender.New(log, nil, readPin, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ func run(cfg revid.Config) error {
|
|||
vars, _ = ns.Vars()
|
||||
vs := ns.VarSum()
|
||||
|
||||
rv, err := revid.New(cfg, &ns)
|
||||
rv, err := revid.New(cfg, ns)
|
||||
if err != nil {
|
||||
log.Log(logger.Fatal, pkg+"could not initialise revid", "error", err.Error())
|
||||
}
|
||||
|
@ -300,8 +300,7 @@ func run(cfg revid.Config) error {
|
|||
}
|
||||
|
||||
for {
|
||||
// TODO(saxon): replace this call with call to ns.Run().
|
||||
err = send(&ns, rv)
|
||||
err = ns.Run()
|
||||
if err != nil {
|
||||
log.Log(logger.Error, pkg+"Run Failed. Retrying...", "error", err.Error())
|
||||
time.Sleep(netSendRetryTime)
|
||||
|
@ -356,27 +355,16 @@ func run(cfg revid.Config) error {
|
|||
}
|
||||
}
|
||||
|
||||
// send implements our main NetSender client and handles NetReceiver configuration
|
||||
// (as distinct from httpSender which just sends video data).
|
||||
func send(ns *netsender.Sender, rv *revid.Revid) error {
|
||||
// populate input values, if any
|
||||
inputs := netsender.MakePins(ns.Param("ip"), "X")
|
||||
if rv != nil {
|
||||
for i, pin := range inputs {
|
||||
if pin.Name == "X23" {
|
||||
inputs[i].Value = rv.Bitrate()
|
||||
func readPin(pin *netsender.Pin) error {
|
||||
switch {
|
||||
case pin.Name == "X23":
|
||||
//pin.Value = rv.Bitrate()
|
||||
case pin.Name[0] == 'X':
|
||||
return sds.ReadSystem(pin)
|
||||
default:
|
||||
pin.Value = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_, reconfig, err := ns.Send(netsender.RequestPoll, inputs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if reconfig {
|
||||
return ns.Config()
|
||||
}
|
||||
return nil
|
||||
return nil // Return error only if we want NetSender to generate an error
|
||||
}
|
||||
|
||||
// flagStrings implements an appending string set flag.
|
||||
|
|
Loading…
Reference in New Issue