diff options
Diffstat (limited to 'src/rhctl/audio_switch.go')
-rw-r--r-- | src/rhctl/audio_switch.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/rhctl/audio_switch.go b/src/rhctl/audio_switch.go index 1368da8..5fc9fac 100644 --- a/src/rhctl/audio_switch.go +++ b/src/rhctl/audio_switch.go @@ -23,7 +23,6 @@ package main import ( "fmt" - "time" ) type AudioSwitch struct { @@ -32,15 +31,22 @@ type AudioSwitch struct { func (sw *AudioSwitch) Run() { rhdl.Printf("running audio switch") - sw.port.tx <- "hello switch" - time.Sleep(10 * time.Second) + stop := make(chan bool) + sw.port.Run(stop) + + select { + case <-stop: + return + case data := <-sw.port.rx: + rhl.Printf("got data from audio switch: %q", data) + } } func SwitchInit(conf *Config) (sw *AudioSwitch, err error) { sw = &AudioSwitch{} - if sw.port, err = SerialOpenAndHandle(conf.Audioswitch.Device, conf.Audioswitch.Baudrate, ""); err != nil { + if sw.port, err = SerialOpen(conf.Audioswitch.Device, conf.Audioswitch.Baudrate, ""); err != nil { err = fmt.Errorf("Error opening switch port: %s", err) return } |