summaryrefslogtreecommitdiff
path: root/src/rhctl
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-04-18 19:45:45 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-04-18 19:45:45 (GMT)
commit5db809ecc7794fe45401aa50e5064eb90031fcee (patch)
tree3229f8b1d1dc8ff3b913d27575037fffea194ace /src/rhctl
parent2350f07eaf88b1cb04b177cebfb9b6174ed94b2d (diff)
parsing single GPI update, fixes from go vet
Diffstat (limited to 'src/rhctl')
-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