diff options
-rw-r--r-- | ports.go | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -65,10 +65,23 @@ func (p *Port) Write(b []byte) (int, error) { return p.f.Write(b) } func (p *Port) Close() error { return p.f.Close() } // Flush implement flush() method for serial port +// flushes both data received but not read, and data written but not transmitted func (p *Port) Flush() error { return unix.IoctlSetInt(int(p.f.Fd()), unix.TCFLSH, unix.TCIOFLUSH) } +// Flush implement flush() method for serial port +// flushes data received but not read +func (p *Port) FlushRead() error { + return unix.IoctlSetInt(int(p.f.Fd()), unix.TCFLSH, unix.TCIFLUSH) +} + +// Flush implement flush() method for serial port +// flushes data written but not transmitted +func (p *Port) FlushWrite() error { + return unix.IoctlSetInt(int(p.f.Fd()), unix.TCFLSH, unix.TCOFLUSH) +} + // SendBreak Sends Break Signal func (p *Port) SendBreak(d time.Duration) error { return unix.IoctlSetInt(int(p.f.Fd()), unix.TCSBRKP, int(d)) |