mirror of https://bitbucket.org/ausocean/av.git
cmd/revid-cli: move creation code to near call site
This commit is contained in:
parent
f5a3899e1d
commit
e2c2093e28
|
@ -332,6 +332,20 @@ func startRevid() {
|
|||
revidInst.Start()
|
||||
}
|
||||
|
||||
func createRevidInstance() {
|
||||
// Try to create the revid instance with the given config
|
||||
var err error
|
||||
for revidInst, err = revid.NewRevid(config); err != nil; {
|
||||
// If the config does have a logger, use it to output error, otherwise
|
||||
// just output to std output
|
||||
if config.Logger != nil {
|
||||
config.Logger.Log(progName, "FATAL ERROR", err.Error())
|
||||
} else {
|
||||
fmt.Printf("FATAL ERROR: %v", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func stopRevid() {
|
||||
revidInst.Stop()
|
||||
|
||||
|
@ -467,17 +481,3 @@ func revidReportActions(pin int) (int, error) {
|
|||
return -1, errors.New("External pin" + strconv.Itoa(pin) + " not defined")
|
||||
}
|
||||
}
|
||||
|
||||
func createRevidInstance() {
|
||||
// Try to create the revid instance with the given config
|
||||
var err error
|
||||
for revidInst, err = revid.NewRevid(config); err != nil; {
|
||||
// If the config does have a logger, use it to output error, otherwise
|
||||
// just output to std output
|
||||
if config.Logger != nil {
|
||||
config.Logger.Log(progName, "FATAL ERROR", err.Error())
|
||||
} else {
|
||||
fmt.Printf("FATAL ERROR: %v", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue