jacobsa / go-serial

A Go library for dealing with serial ports.
Apache License 2.0
631 stars 121 forks source link

Flush buffer #39

Open bvwj opened 6 years ago

bvwj commented 6 years ago

It seems when I open a port and execute a read there can be old data in the buffer. I have to disconnect/reconnect the USB-UART to clear the old data.

I do not see any flush function. Is flushing the buffer possible?

CYL96 commented 6 years ago

read all

ssnover commented 5 years ago

If you import "io/ioutil" you can call ioutil.ReadAll on your serial port object. However, it does not appear to time out and I can't find a way to make this function return. I have both an InterCharacterTimeout of 2 set and a MinimumReadSize of 1.

timchenxiaoyu commented 3 years ago

some promblem. c# has port clean api