Added buffer flush methods

+ serial.Port.ResetInputBuffer()
+ serial.Port.ResetOutputBuffer()
This commit is contained in:
Veniamin Albaev
2017-03-09 11:11:06 +03:00
parent 4d886c1028
commit 8b7629bfe1
8 changed files with 48 additions and 0 deletions

View File

@@ -115,6 +115,21 @@ func (port *windowsPort) Write(p []byte) (int, error) {
return int(writed), err
}
const (
purgeRxAbort uint32 = 0x0002
purgeRxClear = 0x0008
purgeTxAbort = 0x0001
purgeTxClear = 0x0004
)
func (port *windowsPort) ResetInputBuffer() error {
return purgeComm(port.handle, purgeRxClear|purgeRxAbort)
}
func (port *windowsPort) ResetOutputBuffer() error {
return purgeComm(port.handle, purgeTxClear|purgeTxAbort)
}
const (
dcbBinary uint32 = 0x00000001
dcbParity = 0x00000002