From 801064012cf619af3c067cc715ec5cb3304c3732 Mon Sep 17 00:00:00 2001 From: sina Date: Thu, 2 Mar 2023 12:23:45 +0330 Subject: TCOFLUSH and TCIFLUSH --- ports.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ports.go b/ports.go index ddf2e85..e5241d1 100644 --- a/ports.go +++ b/ports.go @@ -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)) -- cgit v1.2.3