Exemple #1
0
func (p *Port) reset() (err error) {
	err = syscall.FlushFileBuffers(p.handle)
	if err != nil {
		return
	}
	err = _PurgeComm(p.handle, _PURGE_TXABORT|_PURGE_RXABORT|_PURGE_TXCLEAR|_PURGE_RXCLEAR)
	if err != nil {
		return
	}
	err = _ClearCommError(p.handle)
	if err != nil {
		return
	}
	return
}
func flush(addr, len uintptr) error {
	errno := syscall.FlushViewOfFile(addr, len)
	if errno != nil {
		return os.NewSyscallError("FlushViewOfFile", errno)
	}

	handleLock.Lock()
	defer handleLock.Unlock()
	handle, ok := handleMap[addr]
	if !ok {
		// should be impossible; we would've errored above
		return errors.New("unknown base address")
	}

	errno = syscall.FlushFileBuffers(handle)
	return os.NewSyscallError("FlushFileBuffers", errno)
}
Exemple #3
0
func (p *Port) flush() (err error) {
	return syscall.FlushFileBuffers(p.handle)
}