diff options
Diffstat (limited to 'src/rhctl/audio_switch.go')
-rw-r--r-- | src/rhctl/audio_switch.go | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/rhctl/audio_switch.go b/src/rhctl/audio_switch.go index 07e0270..f3821d8 100644 --- a/src/rhctl/audio_switch.go +++ b/src/rhctl/audio_switch.go @@ -80,7 +80,13 @@ type SwitchUpdate struct { } type SwitchState struct { - // TODO: fill this up with data + audio [SwitchOutputNumMax]struct { + inputs [SwitchInputNumMax]bool + silence bool + } + gpi [SwitchGPINumMax]bool + relay [SwitchRelayNumMax]bool + oc [SwitchOCNumMax]bool } type AudioSwitch struct { @@ -152,8 +158,7 @@ func (sw *AudioSwitch) Run() { case <-stop: return case <-sw.timer.C: - resp := SwitchResponse{SwitchError, "EEE timeout"} - sw.current.Response <- resp + sw.current.Response <- fmt.Errorf("command timed out") sw.current = nil sw.timer = nil case data := <-sw.port.rx: @@ -164,11 +169,15 @@ func (sw *AudioSwitch) Run() { case <-stop: return case cmd := <-sw.Commands: - c := cmd.Cmd.Generate(append(cmd.Args, sw.unit)...) - rhdl.Printf("sending '%s' to switch", c) - sw.current = cmd - sw.port.tx <- c - sw.timer = time.NewTimer(sw.timeout) + c, err := cmd.Cmd.Generate(append(cmd.Args, sw.unit)...) + if err != nil { + cmd.Response <- err + } else { + rhdl.Printf("sending '%s' to switch", c) + sw.current = cmd + sw.port.tx <- c + sw.timer = time.NewTimer(sw.timeout) + } case data := <-sw.port.rx: sw.handleData(data) } |