// +build pi0 package main import ( "os/exec" "time" "bitbucket.org/ausocean/utils/logger" ) const audioCmd = "play" func initCommand(log *logger.Logger) { const soundcardPath = "/usr/share/doc/audioInjector/asound.state.RCA.thru.test" const sleepDur = 1 * time.Second // alsactl is a command that ensures the sound will be played through the correct soundcard. path, err := exec.LookPath("alsactl") if err != nil { log.Log(logger.Fatal, "didn't find 'alsactl' executable") } log.Log(logger.Debug, "'alsactl' executable path", "path", path) cmdInit := exec.Command("alsactl", "-f", soundcardPath, "restore") for cmdInit.Run() != nil { log.Log(logger.Warning, "cmd.Run() for 'alsactl' failed", "error", err.Error()) time.Sleep(sleepDur) } // Making sure that play command is on the pi. path, err = exec.LookPath(audioCmd) if err != nil { log.Log(logger.Fatal, "didn't find 'play' executable") } log.Log(logger.Debug, "'play' executable path", "path", path) }