Open thedemoncat opened 1 year ago
bufio.NewReader(stream).ReadLine()
bufio.Scanner is another option I find quite useful. You can also set your custom Spiltter function there if your input data is not newline-separated.
Is there a way to set a custom timeout on bufio.NewReader()? I've set a timeout on the port itself as well
Is there a way to set a custom timeout on bufio.NewReader()? I've set a timeout on the port itself as well
the underlying io.Reader does not implement a timeout - the idea here being that the reader finishes when the resource is closed or exhausted (EOF). So the correct way I think is to set the timeout on the port, which is your resource in this case. Note however that on Windows, this does not work with the original tarm/serial. There are a couple of forks that implement this feature (example from my fork).
HI!!!
arduino App (platformio - esp8266)
golang app
in the console I get this result:
Why is the first character read separately in the stream?
How to read a line correctly?
Thank you in advance!