You are ignoring an important situational fact...the serial port is not an
infinite stream to you, but a sequence of serial ports divided by
connection closings. In this situation, the thing to be scanned is
experiencing EOF at close events but this is not being communicated. That
is the problem. N
When reading from a serial port, there is no EOF between data sets. I may
have to use something else besides a scanner to do this. I have a handler
function called by a goroutine that just monitors incoming data in a for
loop and sends that data coming in back through a channel. If the
conne
Scan() returns false when it reaches EOF or an error, so with what you
provided i assume you're missing to check that.
for ns.Scan() {
...
}
or
for {
if !ns.Scan() {
break
}
-wgr
On Sun, Dec 30, 2018 at 10:36 PM Trig wrote:
>
> I'm currently utilizing the bufio.NewScanner to read ASCII dat
I'm currently utilizing the bufio.NewScanner to read ASCII data from a
serial port. I have the following simple code:
ns := bufio.NewScanner(sPort)
for {
ns.Scan()
if ns.Text() != "" { // ignore blank lines
// handle content here
}
}
The problem is ns.Scan() blocks the loop from