summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rhctl/audio_switch.go43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/rhctl/audio_switch.go b/src/rhctl/audio_switch.go
index 31ecbc4..0f89ee7 100644
--- a/src/rhctl/audio_switch.go
+++ b/src/rhctl/audio_switch.go
@@ -104,7 +104,7 @@ type AudioSwitch struct {
func (sw *AudioSwitch) updateStateAudio(data string) {
if len(data) < int(4+2*SwitchInputNumMax) {
- rhl.Printf("Audioswitch: invalid audio status update (too short)", data)
+ rhl.Printf("Audioswitch: invalid audio status update (too short)")
return
}
var out SwitchOutputNum
@@ -124,23 +124,40 @@ func (sw *AudioSwitch) updateStateAudio(data string) {
case "1":
sw.state.Audio[out-1].Inputs[i] = true
default:
- rhl.Printf("Audioswitch: invalid audio status update (state must be either \"1\" or \"0\" but is %q)", ins[i])
+ rhl.Printf("Audioswitch: invalid audio status update (state must be either '1' or '0' but is '%s')", ins[i])
}
}
sw.StateChanges <- sw.state
}
func (sw *AudioSwitch) updateStateGPI(data string) {
- if len(data) < 5 {
- rhl.Printf("Audioswitch: invalid gpi status update (too short)", data)
+ if len(data) < 8 {
+ rhl.Printf("Audioswitch: invalid gpi status update (too short)")
return
}
if data[4] != 'A' {
- return // TODO: parse single GPI status...
+ // 'SuP,ii,x'
+ var in SwitchGPINum
+ if err := in.FromString(data[4:6]); err != nil {
+ rhl.Printf("Audioswitch: invalid gpi status update: %v", err)
+ return
+ }
+
+ switch data[7] {
+ case '0':
+ sw.state.GPI[in] = false
+ case '1':
+ sw.state.GPI[in] = true
+ default:
+ rhl.Printf("Audioswitch: invalid gpi status update (state must be either '1' or '0' but is '%s')", data[7:8])
+ }
+ sw.StateChanges <- sw.state
+ return
}
+ // 'SuP,A,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x'
if len(data) < int(5+2*SwitchGPINumMax) {
- rhl.Printf("Audioswitch: invalid gpi status update (too short)", data)
+ rhl.Printf("Audioswitch: invalid gpi status update (too short)")
return
}
@@ -156,7 +173,7 @@ func (sw *AudioSwitch) updateStateGPI(data string) {
case "1":
sw.state.GPI[i] = true
default:
- rhl.Printf("Audioswitch: invalid gpi status update (state must be either \"1\" or \"0\" but is %q)", ins[i])
+ rhl.Printf("Audioswitch: invalid gpi status update (state must be either '1' or '0' but is '%s')", ins[i])
}
}
sw.StateChanges <- sw.state
@@ -164,7 +181,7 @@ func (sw *AudioSwitch) updateStateGPI(data string) {
func (sw *AudioSwitch) updateStateRelay(data string) {
if len(data) < int(3+2*SwitchRelayNumMax) {
- rhl.Printf("Audioswitch: invalid relay status update (too short)", data)
+ rhl.Printf("Audioswitch: invalid relay status update (too short)")
return
}
@@ -180,7 +197,7 @@ func (sw *AudioSwitch) updateStateRelay(data string) {
case "1":
sw.state.Relay[i] = true
default:
- rhl.Printf("Audioswitch: invalid relay status update (state must be either \"1\" or \"0\" but is %q)", outs[i])
+ rhl.Printf("Audioswitch: invalid relay status update (state must be either '1' or '0' but is '%s')", outs[i])
}
}
sw.StateChanges <- sw.state
@@ -188,7 +205,7 @@ func (sw *AudioSwitch) updateStateRelay(data string) {
func (sw *AudioSwitch) updateStateOC(data string) {
if len(data) < int(3+2*SwitchOCNumMax) {
- rhl.Printf("Audioswitch: invalid oc status update (too short)", data)
+ rhl.Printf("Audioswitch: invalid oc status update (too short)")
return
}
@@ -204,7 +221,7 @@ func (sw *AudioSwitch) updateStateOC(data string) {
case "1":
sw.state.OC[i] = true
default:
- rhl.Printf("Audioswitch: invalid oc status update (state must be either \"1\" or \"0\" but is %q)", outs[i])
+ rhl.Printf("Audioswitch: invalid oc status update (state must be either '1' or '0' but is '%s')", outs[i])
}
}
sw.StateChanges <- sw.state
@@ -212,7 +229,7 @@ func (sw *AudioSwitch) updateStateOC(data string) {
func (sw *AudioSwitch) updateStateSilence(data string) {
if len(data) < int(3+2*SwitchOutputNumMax) {
- rhl.Printf("Audioswitch: invalid silence status update (too short)", data)
+ rhl.Printf("Audioswitch: invalid silence status update (too short)")
return
}
@@ -228,7 +245,7 @@ func (sw *AudioSwitch) updateStateSilence(data string) {
case "1":
sw.state.Audio[i].Silence = true
default:
- rhl.Printf("Audioswitch: invalid silence status update (state must be either \"1\" or \"0\" but is %q)", outs[i])
+ rhl.Printf("Audioswitch: invalid silence status update (state must be either '1' or '0' but is '%s')", outs[i])
}
}
sw.StateChanges <- sw.state