diff options
author | sina <sina@snix.ir> | 2023-03-02 12:23:45 +0330 |
---|---|---|
committer | sina <sina@snix.ir> | 2023-03-02 12:23:45 +0330 |
commit | 801064012cf619af3c067cc715ec5cb3304c3732 (patch) | |
tree | a322ad49a482810714be3124078a1440a414d6f7 | |
parent | 093b30d819ccefdfc4cee3f902828ef48b91b2ce (diff) |
-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)) |