aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsina <sina@snix.ir>2023-03-02 12:23:45 +0330
committersina <sina@snix.ir>2023-03-02 12:23:45 +0330
commit801064012cf619af3c067cc715ec5cb3304c3732 (patch)
treea322ad49a482810714be3124078a1440a414d6f7
parent093b30d819ccefdfc4cee3f902828ef48b91b2ce (diff)
TCOFLUSH and TCIFLUSHHEADmaster
-rw-r--r--ports.go13
1 files changed, 13 insertions, 0 deletions
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))

Snix LLC Git Repository Holder Copyright(C) 2022 All Rights Reserved Email To Snix.IR