rene-aguirre / pywinusb

USB / HID windows helper library
BSD 3-Clause "New" or "Revised" License
207 stars 63 forks source link

Controls delay on the screen #46

Closed skaftanis closed 6 years ago

skaftanis commented 6 years ago

Hi, thanks for the good work!

I use this code to read data from a racing wheel. The problem is that the data aren't exactly real time, because there is some kind of internal delay. When for example I stop steering the wheel I can see in the screen all the values between my current position and the previous for many seconds. I want to do it exactly real time like this: http://html5gamepad.com/

Thanks!

rene-aguirre commented 6 years ago

@skaftanis for realtime performance your processing has to be shorter than the signal sampling.

How many samples per second do you receive? What is your processing time? Do you drop samples on jitter? Do you process one sample at a time or a block of samples? etc.

I recommend you getting started with passing the data received on your callbacks (start with raw data) with a timestamp attached into another thread that only has a receiving queue that writes to a file.

Straight file operations are usually much faster than visual IO (e.g. print to screen in an IDE or even CLI).

That'd give you a context in what are your realtime expectations like data throughput and jitter.

PyWinUSB does asynchronous reading in a dedicated python thread which only posts messages to a consumer thread.

That's the reason you don't loose data, your data would get accumulated if your rate of consumption is slower than the rate of production.

Based on your analysis you might need to (not necessarily mutually exclusive options):

Anyway... start with data :-)