diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-03-25 00:28:27 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-03-25 00:28:27 (GMT) |
commit | 5554f1b3f82340fe0157b4094e23bbb669829b5d (patch) | |
tree | 57d4362a51d3352b8f8753c5addf06052906a97b /src/rhctl/serial_port.go | |
parent | aa513c85c215f22eba8abfac561c4a619782adf5 (diff) |
add an optional newline for all serial line
Diffstat (limited to 'src/rhctl/serial_port.go')
-rw-r--r-- | src/rhctl/serial_port.go | 8 |
1 files changed, 4 insertions, 4 deletions
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 |