From 73e1007edd14aca2110f09557c68f0efac642b85 Mon Sep 17 00:00:00 2001 From: Trek H Date: Sat, 8 Aug 2020 14:19:25 +0930 Subject: [PATCH 1/5] soundcheck: add basic structure of sound check procedure --- cmd/soundcheck/main.go | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 cmd/soundcheck/main.go diff --git a/cmd/soundcheck/main.go b/cmd/soundcheck/main.go new file mode 100644 index 00000000..880f86e7 --- /dev/null +++ b/cmd/soundcheck/main.go @@ -0,0 +1,62 @@ +/* +AUTHORS + Trek Hopton + +LICENSE + Copyright (C) 2020 the Australian Ocean Lab (AusOcean) + + It is free software: you can redistribute it and/or modify them + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + It is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + in gpl.txt. If not, see http://www.gnu.org/licenses. +*/ + +// Package soundcheck is a program for switching a transducer from playing to recording audio. +package main + +import ( + "flag" + "fmt" + "log" + "os" + "os/exec" +) + +func main() { + pTime := flag.Duration("ptime", 60, "duration to play audio") + rTime := flag.Duration("rtime", 20, "duration to record audio") + path := flag.String("path", "", "path to sound file we wish to play") + flag.Parse() + + if _, err := os.Stat(path); os.IsNotExist(err) { + log.Fatal(err) + } + + loopCmd := exec.Command("./looper", path) + rvCmd := exec.Command("./rv") + for { + if err := loopCmd.Start(); err != nil { + log.Fatal(err) + } + time.sleep(pTime) + if err := loopCmd.Process.Kill(); err != nil { + fmt.Println("failed to kill process: ", err) + } + + if err := rvCmd.Start(); err != nil { + log.Fatal(err) + } + time.sleep(rTime) + if err := rvCmd.Process.Kill(); err != nil { + fmt.Println("failed to kill process: ", err) + } + } +} From 3265f7c19561a68f4acae531fa3b00bcc8339454 Mon Sep 17 00:00:00 2001 From: Trek H Date: Tue, 11 Aug 2020 21:17:21 +0930 Subject: [PATCH 2/5] soundcheck: builds --- cmd/soundcheck/main.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/cmd/soundcheck/main.go b/cmd/soundcheck/main.go index 880f86e7..086b27bd 100644 --- a/cmd/soundcheck/main.go +++ b/cmd/soundcheck/main.go @@ -26,27 +26,26 @@ import ( "flag" "fmt" "log" - "os" "os/exec" + "time" ) func main() { - pTime := flag.Duration("ptime", 60, "duration to play audio") - rTime := flag.Duration("rtime", 20, "duration to record audio") - path := flag.String("path", "", "path to sound file we wish to play") + var pTime time.Duration + var rTime time.Duration + var path string + flag.DurationVar(&pTime, "ptime", 60, "duration to play audio") + flag.DurationVar(&rTime, "rtime", 20, "duration to record audio") + flag.StringVar(&path, "path", "", "path to sound file we wish to play") flag.Parse() - if _, err := os.Stat(path); os.IsNotExist(err) { - log.Fatal(err) - } - - loopCmd := exec.Command("./looper", path) - rvCmd := exec.Command("./rv") + loopCmd := exec.Command("../looper/looper", path) + rvCmd := exec.Command("../rv/rv") for { if err := loopCmd.Start(); err != nil { log.Fatal(err) } - time.sleep(pTime) + time.Sleep(pTime) if err := loopCmd.Process.Kill(); err != nil { fmt.Println("failed to kill process: ", err) } @@ -54,7 +53,7 @@ func main() { if err := rvCmd.Start(); err != nil { log.Fatal(err) } - time.sleep(rTime) + time.Sleep(rTime) if err := rvCmd.Process.Kill(); err != nil { fmt.Println("failed to kill process: ", err) } From 94825f3db9beb1730fe8b018ed9964a9e349234a Mon Sep 17 00:00:00 2001 From: Saxon Date: Fri, 14 Aug 2020 15:40:22 +0930 Subject: [PATCH 3/5] cmd/treatment: wrote driver to handle audio playback and recording for sound check --- cmd/soundcheck/main.go | 61 -------- cmd/treatment/circleci.go | 34 +++++ cmd/treatment/main.go | 312 ++++++++++++++++++++++++++++++++++++++ cmd/treatment/pi3.go | 38 +++++ go.mod | 3 +- go.sum | 33 ++++ 6 files changed, 419 insertions(+), 62 deletions(-) delete mode 100644 cmd/soundcheck/main.go create mode 100644 cmd/treatment/circleci.go create mode 100644 cmd/treatment/main.go create mode 100644 cmd/treatment/pi3.go diff --git a/cmd/soundcheck/main.go b/cmd/soundcheck/main.go deleted file mode 100644 index 086b27bd..00000000 --- a/cmd/soundcheck/main.go +++ /dev/null @@ -1,61 +0,0 @@ -/* -AUTHORS - Trek Hopton - -LICENSE - Copyright (C) 2020 the Australian Ocean Lab (AusOcean) - - It is free software: you can redistribute it and/or modify them - under the terms of the GNU General Public License as published by the - Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - It is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - in gpl.txt. If not, see http://www.gnu.org/licenses. -*/ - -// Package soundcheck is a program for switching a transducer from playing to recording audio. -package main - -import ( - "flag" - "fmt" - "log" - "os/exec" - "time" -) - -func main() { - var pTime time.Duration - var rTime time.Duration - var path string - flag.DurationVar(&pTime, "ptime", 60, "duration to play audio") - flag.DurationVar(&rTime, "rtime", 20, "duration to record audio") - flag.StringVar(&path, "path", "", "path to sound file we wish to play") - flag.Parse() - - loopCmd := exec.Command("../looper/looper", path) - rvCmd := exec.Command("../rv/rv") - for { - if err := loopCmd.Start(); err != nil { - log.Fatal(err) - } - time.Sleep(pTime) - if err := loopCmd.Process.Kill(); err != nil { - fmt.Println("failed to kill process: ", err) - } - - if err := rvCmd.Start(); err != nil { - log.Fatal(err) - } - time.Sleep(rTime) - if err := rvCmd.Process.Kill(); err != nil { - fmt.Println("failed to kill process: ", err) - } - } -} diff --git a/cmd/treatment/circleci.go b/cmd/treatment/circleci.go new file mode 100644 index 00000000..a3e7c1e9 --- /dev/null +++ b/cmd/treatment/circleci.go @@ -0,0 +1,34 @@ +// +build circleci + +/* +DESCRIPTION + circleci.go defines a dummy initialisation command for running on circleci. + +AUTHORS + Ella Pietraroia + Scott Barnard + +LICENSE + Copyright (C) 2020 the Australian Ocean Lab (AusOcean) + + It is free software: you can redistribute it and/or modify them + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + It is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + in gpl.txt. If not, see http://www.gnu.org/licenses. +*/ + +package main + +import "bitbucket.org/ausocean/utils/logger" + +const audioCmd = "" + +func initCommand(log *logger.Logger) {} diff --git a/cmd/treatment/main.go b/cmd/treatment/main.go new file mode 100644 index 00000000..dfdabb78 --- /dev/null +++ b/cmd/treatment/main.go @@ -0,0 +1,312 @@ +/* +DESCRIPTION + treatment is a netsender client intended to provide audio playback control, + and speaker health checking by reversing signal and recording using revid. + +AUTHORS + Saxon Nelson-Milton + Trek Hopton + +LICENSE + Copyright (C) 2020 the Australian Ocean Lab (AusOcean) + + It is free software: you can redistribute it and/or modify them + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + It is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + in gpl.txt. If not, see http://www.gnu.org/licenses. +*/ + +// Package treatment is a program for playing and recording audio through a common +// speaker unit. +package main + +import ( + "bytes" + "flag" + "fmt" + "io" + "os/exec" + "strconv" + "sync" + "time" + + "bitbucket.org/ausocean/av/container/mts" + "bitbucket.org/ausocean/av/container/mts/meta" + "bitbucket.org/ausocean/av/revid" + "bitbucket.org/ausocean/av/revid/config" + "bitbucket.org/ausocean/iot/pi/gpio" + "bitbucket.org/ausocean/iot/pi/netlogger" + "bitbucket.org/ausocean/iot/pi/netsender" + "bitbucket.org/ausocean/utils/logger" + lumberjack "gopkg.in/natefinch/lumberjack.v2" +) + +// Copyright information prefixed to all metadata. +const ( + metaPreambleKey = "copyright" + metaPreambleData = "ausocean.org/license/content2020" +) + +// Logging configuration. +const ( + logPath = "/var/log/netsender/netsender.log" + logMaxSize = 500 // MB + logMaxBackup = 10 + logMaxAge = 28 // days + logVerbosity = logger.Info + logSuppress = true +) + +// Misc constants. +const ( + netSendRetryTime = 5 * time.Second + defaultSleepTime = 60 // Seconds + profilePath = "rv.prof" + pkg = "rv: " + runPreDelay = 20 * time.Second +) + +// Treatment modes. +const ( + modePaused = "Paused" + modeTreatment = "Play" + modeCheck = "Check" +) + +// Variable map to send to netreceiver/vidgrind. +var varMap = map[string]string{ + "mode": "enum:Paused,Play,Check", +} + +func main() { + mts.Meta = meta.NewWith([][2]string{{metaPreambleKey, metaPreambleData}}) + + // Set up the player command with audio file path. + filePtr := flag.String("path", "", "Path to sound file we wish to play.") + flag.Parse() + cmd := exec.Command(audioCmd, *filePtr) + + // Create lumberjack logger to handle logging to file. + fileLog := &lumberjack.Logger{ + Filename: logPath, + MaxSize: logMaxSize, + MaxBackups: logMaxBackup, + MaxAge: logMaxAge, + } + + // Create netlogger to handle logging to cloud. + netLog := netlogger.New() + + // Create logger that we call methods on to log, which in turn writes to the + // lumberjack and netloggers. + log := logger.New(logVerbosity, io.MultiWriter(fileLog, netLog), logSuppress) + + // The netsender client will handle communication with netreceiver and GPIO stuff. + log.Log(logger.Debug, "initialising netsender client") + ns, err := netsender.New(log, gpio.InitPin, gpio.ReadPin, gpio.WritePin, varMap) + if err != nil { + log.Log(logger.Fatal, "could not initialise netsender client", "error", err.Error()) + } + + // Revid will handle the recording and sending of audio for sound checking. + log.Log(logger.Debug, "initialising revid") + rv, err := revid.New(config.Config{Logger: log}, ns) + if err != nil { + log.Log(logger.Fatal, "could not initialise revid", "error", err.Error()) + } + + // Start the control loop. + log.Log(logger.Debug, "starting control loop") + run(rv, ns, cmd, log, netLog) +} + +// run starts a control loop that runs netsender, sends logs, checks for var changes, and +// if var changes, changes current mode (paused,audio playback or soundcheck) +func run(rv *revid.Revid, ns *netsender.Sender, cmd *exec.Cmd, l *logger.Logger, nl *netlogger.Logger) { + var ( + wg sync.WaitGroup + audioQuit chan struct{} + treating bool + vs int + ) + + for { + l.Log(logger.Debug, "running netsender") + err := ns.Run() + if err != nil { + l.Log(logger.Warning, "run failed. Retrying...", "error", err.Error()) + time.Sleep(netSendRetryTime) + continue + } + + l.Log(logger.Debug, "sending logs") + err = nl.Send(ns) + if err != nil { + l.Log(logger.Warning, pkg+"Logs could not be sent", "error", err.Error()) + } + + l.Log(logger.Debug, "checking varsum") + newVs := ns.VarSum() + if vs == newVs { + sleep(ns, l) + continue + } + vs = newVs + l.Log(logger.Info, "varsum changed", "vs", vs) + + l.Log(logger.Debug, "getting new vars") + vars, err := ns.Vars() + if err != nil { + l.Log(logger.Error, pkg+"netSender failed to get vars", "error", err.Error()) + time.Sleep(netSendRetryTime) + continue + } + l.Log(logger.Info, "got new vars", "vars", vars) + + // Configure revid based on the vars. + l.Log(logger.Debug, "updating revid configuration") + err = rv.Update(vars) + if err != nil { + l.Log(logger.Warning, pkg+"couldn't update revid", "error", err.Error()) + sleep(ns, l) + continue + } + l.Log(logger.Info, "revid successfully reconfigured") + + l.Log(logger.Debug, "checking mode") + switch ns.Mode() { + case modePaused: + stopAudio(&wg, &treating, audioQuit) + l.Log(logger.Info, "mode is Paused, stopping revid") + rv.Stop() + case modeTreatment: + if !treating { + l.Log(logger.Info, "starting audio treatment") + rv.Stop() + audioQuit = make(chan struct{}) + treating = true + wg.Add(1) + go playAudio(cmd, audioQuit, &wg, l) + } + case modeCheck: + stopAudio(&wg, &treating, audioQuit) + l.Log(logger.Info, "sound checking") + err = rv.Start() + if err != nil { + l.Log(logger.Error, "could not start revid", "error", err.Error()) + ns.SetMode(modePaused, &vs) + sleep(ns, l) + continue + } + } + l.Log(logger.Info, "revid updated with new mode") + sleep(ns, l) + } +} + +// playAudio is intended to be run as a routine. It will repeatedly play an audio file until +// a signal is received to return. The entire audio file is played before the termination +// signal chan is checked. +func playAudio(cmd *exec.Cmd, quit chan struct{}, wg *sync.WaitGroup, l *logger.Logger) { + var numPlays int + for { + // We'd like to see what the playback software is outputting, so pipe + // stdout and stderr. + outPipe, err := cmd.StdoutPipe() + if err != nil { + l.Log(logger.Error, "failed to pipe stdout", "error", err) + } + errPipe, err := cmd.StderrPipe() + if err != nil { + l.Log(logger.Error, "failed to pipe stderr", "error", err) + } + + // Start playback of the audio file. + err = cmd.Start() + if err != nil { + l.Log(logger.Error, "start failed", "error", err.Error()) + continue + } + numPlays++ + l.Log(logger.Debug, "playing audio", "numPlays", numPlays) + + // Copy any std out to a buffer for logging. + var outBuff bytes.Buffer + go func() { + _, err = io.Copy(&outBuff, outPipe) + if err != nil { + l.Log(logger.Error, "failed to copy out pipe", "error", err) + } + }() + + // Copy any std error to a buffer for logging. + var errBuff bytes.Buffer + go func() { + _, err = io.Copy(&errBuff, errPipe) + if err != nil { + l.Log(logger.Error, "failed to copy error pipe", "error", err) + } + }() + + // Wait for playback to complete. + err = cmd.Wait() + if err != nil { + l.Log(logger.Error, "failed to wait for execution finish", "error", err.Error()) + } + l.Log(logger.Debug, "stdout received", "stdout", string(outBuff.Bytes())) + + // If there was any errors on stderr, log them. + if errBuff.Len() != 0 { + l.Log(logger.Error, "errors from stderr", "stderr", string(errBuff.Bytes())) + } + + // Check for audio signal halt. + // TODO: work out better way to do this. Doing it this way means we have to wait for + // the audio file to finish playing. + select { + case <-quit: + wg.Done() + return + default: + } + } +} + +// stopAudio signals to the playAudio routine to terminate and then waits for it to +// do so. +func stopAudio(wg *sync.WaitGroup, treating *bool, signal chan struct{}) { + close(signal) + wg.Wait() + *treating = false +} + +// sleep uses a delay to halt the program based on the monitoring period +// netsender parameter (mp) defined in the netsender.conf config. +func sleep(ns *netsender.Sender, l *logger.Logger) { + l.Log(logger.Debug, "sleeping") + t, err := strconv.Atoi(ns.Param("mp")) + if err != nil { + l.Log(logger.Error, pkg+"could not get sleep time, using default", "error", err) + t = defaultSleepTime + } + time.Sleep(time.Duration(t) * time.Second) + l.Log(logger.Debug, "finished sleeping") +} + +// checkPath wraps the use of lookPath to check the existence of executables +// that will be used by the audio looper. +func checkPath(cmd string, l *logger.Logger) { + path, err := exec.LookPath(cmd) + if err != nil { + l.Log(logger.Fatal, fmt.Sprintf("couldn't find %s", cmd), "error", err) + } + l.Log(logger.Debug, fmt.Sprintf("found %s", cmd), "path", path) +} diff --git a/cmd/treatment/pi3.go b/cmd/treatment/pi3.go new file mode 100644 index 00000000..f93e6c39 --- /dev/null +++ b/cmd/treatment/pi3.go @@ -0,0 +1,38 @@ +// +build !circleci + +/* +DESCRIPTION + pi3.go defines an initialisation function for use when running on the + Raspberry Pi 3. + +AUTHORS + Ella Pietraroia + Scott Barnard + Saxon Nelson-Milton + +LICENSE + Copyright (C) 2020 the Australian Ocean Lab (AusOcean) + + It is free software: you can redistribute it and/or modify them + under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + It is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + in gpl.txt. If not, see http://www.gnu.org/licenses. +*/ + +package main + +import ( + "bitbucket.org/ausocean/utils/logger" +) + +const audioCmd = "omxplayer" + +func initCommand(l *logger.Logger) { checkPath(audioCmd, l) } diff --git a/go.mod b/go.mod index 727e60bb..1d22f89b 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,12 @@ module bitbucket.org/ausocean/av go 1.13 require ( - bitbucket.org/ausocean/iot v1.2.14 + bitbucket.org/ausocean/iot v1.2.15 bitbucket.org/ausocean/utils v1.2.14 github.com/Comcast/gots v0.0.0-20190305015453-8d56e473f0f7 github.com/go-audio/audio v0.0.0-20181013203223-7b2a6ca21480 github.com/go-audio/wav v0.0.0-20181013172942-de841e69b884 + github.com/go-delve/delve v1.5.0 github.com/google/go-cmp v0.4.1 github.com/mewkiz/flac v1.0.5 github.com/pkg/errors v0.8.1 diff --git a/go.sum b/go.sum index 0537db2b..582e04d4 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ bitbucket.org/ausocean/iot v1.2.13 h1:E9LcW3HYqRgJqxNhPJUCfVRvoV2IAU4B7JSDNxB/x2 bitbucket.org/ausocean/iot v1.2.13/go.mod h1:Q5FwaOKnCty3dVeVtki6DLwYa5vhNpOaeu1lwLyPCg8= bitbucket.org/ausocean/iot v1.2.14 h1:+2up1G1g28RnXFw+1tpobdpZxzZDYEXgsXwmpNZDCWA= bitbucket.org/ausocean/iot v1.2.14/go.mod h1:Q5FwaOKnCty3dVeVtki6DLwYa5vhNpOaeu1lwLyPCg8= +bitbucket.org/ausocean/iot v1.2.15 h1:fJ3hP/jZ/5irLn74bMIlztKrKAqpdhbNR/QiNz5ZgPE= +bitbucket.org/ausocean/iot v1.2.15/go.mod h1:rRcWt6SoM/jgIZpP1zrpnKb5BhxIMulAJ+q1xTvLh94= bitbucket.org/ausocean/utils v1.2.11 h1:zA0FOaPjN960ryp8PKCkV5y50uWBYrIxCVnXjwbvPqg= bitbucket.org/ausocean/utils v1.2.11/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8= bitbucket.org/ausocean/utils v1.2.13 h1:tUaIywtoMc1+zl1GCVQokX4mL5X7LNHX5O51AgAPrWA= @@ -17,6 +19,9 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMx github.com/adrianmo/go-nmea v1.1.1-0.20190109062325-c448653979f7/go.mod h1:HHPxPAm2kmev+61qmkZh7xgZF/7qHtSpsWppip2Ipv8= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/cosiner/argv v0.1.0/go.mod h1:EusR6TucWKX+zFgtdUsKT2Cvg45K5rtpCcWz4hK06d8= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -26,11 +31,19 @@ github.com/go-audio/audio v0.0.0-20181013203223-7b2a6ca21480 h1:4sGU+UABMMsRJyD+ github.com/go-audio/audio v0.0.0-20181013203223-7b2a6ca21480/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs= github.com/go-audio/wav v0.0.0-20181013172942-de841e69b884 h1:2TaXIaVA4ff/MHHezOj83tCypALTFAcXOImcFWNa3jw= github.com/go-audio/wav v0.0.0-20181013172942-de841e69b884/go.mod h1:UiqzUyfX0zs3pJ/DPyvS5v8sN6s5bXPUDDIVA5v8dks= +github.com/go-delve/delve v1.5.0 h1:gQsRvFdR0BGk19NROQZsAv6iG4w5QIZoJlxJeEUBb0c= +github.com/go-delve/delve v1.5.0/go.mod h1:c6b3a1Gry6x8a4LGCe/CWzrocrfaHvkUxCj3k4bvSUQ= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/google/go-cmp v0.4.1 h1:/exdXoGamhu5ONeUJH0deniYLWYvQwW66yvlfiiKTu0= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-dap v0.2.0/go.mod h1:5q8aYQFnHOAZEMP+6vmq25HKYAEwE+LF5yh7JKrrhSQ= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4/go.mod h1:2RvX5ZjVtsznNZPEt4xwJXNJrM3VTZoQf7V6gk0ysvs= +github.com/kidoman/embd v0.0.0-20170508013040-d3d8c0c5c68d h1:dPUSr0RGzXAdsUTMtiyQ/2RBLIIwkv6jGnhxrufitvQ= github.com/kidoman/embd v0.0.0-20170508013040-d3d8c0c5c68d/go.mod h1:ACKj9jnzOzj1lw2ETilpFGK7L9dtJhAzT7T1OhAGtRQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -38,21 +51,30 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/mattetti/audio v0.0.0-20180912171649-01576cde1f21 h1:Hc1iKlyxNHp3CV59G2E/qabUkHvEwOIJxDK0CJ7CRjA= github.com/mattetti/audio v0.0.0-20180912171649-01576cde1f21/go.mod h1:LlQmBGkOuV/SKzEDXBPKauvN2UqCgzXO2XjecTGj40s= +github.com/mattn/go-colorable v0.0.0-20170327083344-ded68f7a9561/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mewkiz/flac v1.0.5 h1:dHGW/2kf+/KZ2GGqSVayNEhL9pluKn/rr/h/QqD9Ogc= github.com/mewkiz/flac v1.0.5/go.mod h1:EHZNU32dMF6alpurYyKHDLYpW1lYpBZ5WrXi/VuNIGs= +github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/spf13/cobra v0.0.0-20170417170307-b6cb39589372/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/pflag v0.0.0-20170417173400-9e4c21054fa1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/yobert/alsa v0.0.0-20180630182551-d38d89fa843e h1:3NIzz7weXhh3NToPgbtlQtKiVgerEaG4/nY2skGoGG0= github.com/yobert/alsa v0.0.0-20180630182551-d38d89fa843e/go.mod h1:CaowXBWOiSGWEpBBV8LoVnQTVPV4ycyviC9IBLj8dRw= github.com/yryz/ds18b20 v0.0.0-20180211073435-3cf383a40624/go.mod h1:MqFju5qeLDFh+S9PqxYT7TEla8xeW7bgGr/69q3oki0= +go.starlark.net v0.0.0-20190702223751-32f345186213/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg= go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= @@ -62,10 +84,19 @@ go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= gocv.io/x/gocv v0.21.0 h1:dVjagrupZrfCRY0qPEaYWgoNMRpBel6GYDH4mvQOK8Y= gocv.io/x/gocv v0.21.0/go.mod h1:Rar2PS6DV+T4FL+PM535EImD/h13hGVaHhnCu1xarBs= +golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/image v0.0.0-20200119044424-58c23975cae1 h1:5h3ngYt7+vXCDZCup/HkCQgW5XwmSvR/nA2JmJ0RErg= golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190913121621-c3b328c6e5a7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -73,5 +104,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= From 9329c30928af5273a4514160bdb2de1aa002dd43 Mon Sep 17 00:00:00 2001 From: Saxon Date: Fri, 14 Aug 2020 17:26:47 +0930 Subject: [PATCH 4/5] cmd/treatment/main.go: fixed file header indentation --- cmd/treatment/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/treatment/main.go b/cmd/treatment/main.go index dfdabb78..472ec806 100644 --- a/cmd/treatment/main.go +++ b/cmd/treatment/main.go @@ -1,11 +1,11 @@ /* DESCRIPTION treatment is a netsender client intended to provide audio playback control, - and speaker health checking by reversing signal and recording using revid. + and speaker health checking by reversing signal and recording using revid. AUTHORS Saxon Nelson-Milton - Trek Hopton + Trek Hopton LICENSE Copyright (C) 2020 the Australian Ocean Lab (AusOcean) From e5e9c31ffbd0ecef949175a910aaa4036439ec6c Mon Sep 17 00:00:00 2001 From: Trek H Date: Wed, 19 Aug 2020 12:43:56 +0930 Subject: [PATCH 5/5] treatment: modify tags, check err on flag --- cmd/treatment/circleci.go | 2 +- cmd/treatment/main.go | 8 +++++--- cmd/treatment/pi3.go | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/treatment/circleci.go b/cmd/treatment/circleci.go index a3e7c1e9..83fe00c2 100644 --- a/cmd/treatment/circleci.go +++ b/cmd/treatment/circleci.go @@ -1,4 +1,4 @@ -// +build circleci +// +build !pi3 /* DESCRIPTION diff --git a/cmd/treatment/main.go b/cmd/treatment/main.go index 472ec806..dc7fde99 100644 --- a/cmd/treatment/main.go +++ b/cmd/treatment/main.go @@ -69,9 +69,7 @@ const ( const ( netSendRetryTime = 5 * time.Second defaultSleepTime = 60 // Seconds - profilePath = "rv.prof" pkg = "rv: " - runPreDelay = 20 * time.Second ) // Treatment modes. @@ -92,7 +90,6 @@ func main() { // Set up the player command with audio file path. filePtr := flag.String("path", "", "Path to sound file we wish to play.") flag.Parse() - cmd := exec.Command(audioCmd, *filePtr) // Create lumberjack logger to handle logging to file. fileLog := &lumberjack.Logger{ @@ -109,6 +106,11 @@ func main() { // lumberjack and netloggers. log := logger.New(logVerbosity, io.MultiWriter(fileLog, netLog), logSuppress) + if *filePtr == "" { + log.Log(logger.Fatal, "no file path provided, check usage") + } + cmd := exec.Command(audioCmd, *filePtr) + // The netsender client will handle communication with netreceiver and GPIO stuff. log.Log(logger.Debug, "initialising netsender client") ns, err := netsender.New(log, gpio.InitPin, gpio.ReadPin, gpio.WritePin, varMap) diff --git a/cmd/treatment/pi3.go b/cmd/treatment/pi3.go index f93e6c39..fefd475f 100644 --- a/cmd/treatment/pi3.go +++ b/cmd/treatment/pi3.go @@ -1,4 +1,4 @@ -// +build !circleci +// +build pi3 /* DESCRIPTION