From 6e5bf5459805cb7c8b8e5baca33e7d1bcc1be13b Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Thu, 19 Oct 2017 13:26:10 +0200 Subject: [PATCH] protocol: support \r\n from serial output --- protocol/tbm.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/protocol/tbm.go b/protocol/tbm.go index dc10627..2b58b0f 100644 --- a/protocol/tbm.go +++ b/protocol/tbm.go @@ -75,7 +75,9 @@ func deserialise(in io.Reader, init []byte) (*Result, []byte, error) { for i := 0; i < n2; i++ { // '\r' is really '\n' if data[i] == '\r' { - data[i] = '\n' + data = append(data[:i], data[i+1:]...) + n2-- + continue } if data[i] == 0x4 { @@ -83,15 +85,13 @@ func deserialise(in io.Reader, init []byte) (*Result, []byte, error) { want_output = false output = data[:i] data = data[i+1:] - /* // The TBM gives us our own commands back for j := 0; j < len(output); j++ { - if output[j] == '\r' { + if output[j] == '\n' { output = output[j+1:] break } } - */ break } else { errorcode = data[:i]