Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

overlapped io, buffers and errors

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

overlapped io, buffers and errors

Post by Bartman »

I want to improve the reading of HID data.
Currently I have this code

Code: Select all

try:
	win32event.ResetEvent(self._overlappedRead.hEvent)
	rc, buf = win32file.ReadFile(handle, n, self._overlappedRead)
	if rc == 997: #error_io_pending
		#waiting for an event
		win32event.WaitForSingleObject(
			self._overlappedRead.hEvent,
			win32event.INFINITE)
except:
	self.abort = True

The control always flows in the rc == 997 condition. When data arrives, the events gets set and i can process the data in buf. When the device gets disconnected the event also gets set and my data processing algorithms runs on invalid data. I only get the error in the next loop, when I call ReadFile again.
Post Reply