diff options
-rw-r--r-- | src/rhctl/audio_switch.go | 2 | ||||
-rw-r--r-- | src/rhctl/playout_server.go | 4 | ||||
-rw-r--r-- | src/rhctl/serial_port.go | 8 |
3 files changed, 7 insertions, 7 deletions
diff --git a/src/rhctl/audio_switch.go b/src/rhctl/audio_switch.go index 8202e60..3da62ca 100644 --- a/src/rhctl/audio_switch.go +++ b/src/rhctl/audio_switch.go @@ -37,7 +37,7 @@ func (sw *AudioSwitch) Run() { func SwitchInit(dev string, rate Baudrate) (sw *AudioSwitch, err error) { sw = &AudioSwitch{} - if sw.port, err = SerialOpenAndHandle(dev, rate); err != nil { + if sw.port, err = SerialOpenAndHandle(dev, rate, ""); err != nil { err = fmt.Errorf("Error opening switch port: %s", err) return } diff --git a/src/rhctl/playout_server.go b/src/rhctl/playout_server.go index c3cfcf1..118d69f 100644 --- a/src/rhctl/playout_server.go +++ b/src/rhctl/playout_server.go @@ -52,11 +52,11 @@ func ServerInit(name string, ctrldev, hbdev string, rate Baudrate) (srv *Playout srv.health = Dead srv.channel = "music" - if srv.control, err = SerialOpenAndHandle(ctrldev, rate); err != nil { + if srv.control, err = SerialOpenAndHandle(ctrldev, rate, "\r\n"); err != nil { err = fmt.Errorf("Error opening control port(%s): %s", srv.name, err) return } - if srv.heartbeat, err = SerialOpenAndHandle(hbdev, rate); err != nil { + if srv.heartbeat, err = SerialOpenAndHandle(hbdev, rate, "\r\n"); err != nil { err = fmt.Errorf("Error opening control port(%s): %s", srv.name, err) return } diff --git a/src/rhctl/serial_port.go b/src/rhctl/serial_port.go index e8bfd92..e4b2c46 100644 --- a/src/rhctl/serial_port.go +++ b/src/rhctl/serial_port.go @@ -62,14 +62,14 @@ func SerialRead(c chan<- string, port *sio.Port) { } } -func SerialWrite(c <-chan string, port *sio.Port) { +func SerialWrite(c <-chan string, port *sio.Port, newline string) { for data := range c { - port.Write([]byte(data)) + port.Write([]byte(data + newline)) } port.Close() } -func SerialOpenAndHandle(device string, speed Baudrate) (port *SerialPort, err error) { +func SerialOpenAndHandle(device string, speed Baudrate, newline string) (port *SerialPort, err error) { port = &SerialPort{} if port.port, err = sio.Open(device, uint32(speed)); err != nil { return @@ -77,7 +77,7 @@ func SerialOpenAndHandle(device string, speed Baudrate) (port *SerialPort, err e tx := make(chan string, 1) rx := make(chan string, 20) go SerialRead(rx, port.port) - go SerialWrite(tx, port.port) + go SerialWrite(tx, port.port, newline) port.rx = rx port.tx = tx |