fenugrec / freediag

OBD2 scantool
GNU General Public License v3.0
329 stars 73 forks source link

Added Windows trick with timeBeginPeriod() to increase Sleep() accuracy #52

Closed v-ladimir closed 5 years ago

v-ladimir commented 6 years ago

Mainly on Windows 10 based-laptops and Windows 7 machines working from battery there was a huge spread value during initial timing calibration using diag_os_calibrate() causing instability and even inability to connect to ECU. On RomRaider forums there was a workaround suggested to run in background media player software. After some research it comes out that in this case Windows timer period is changed, from default 15.6 ms value to the smallest possible (0.5 ms in my case). This allows to have timing errors close to zero, my tests shown avgerr variable values of 0..120 instead 1200..8000 without this tweak. Same timer period change was added to diag_os_win.c as a part of diagnostics initialization. Hope this will make it simpler for some of users :-)

fenugrec commented 6 years ago

Aah yes, the sledgehammer ! I wonder if it would be time to add OS-specific options for this kind of config... like "set timer_fast 1" or something. On your "problematic" machine, have you tried the read timeout accuracy tests without this fix ? (debug l0test ...) I'm curious to see if those tests at least detect the problem properly. I can't get any of my computers to show the problem, but I haven't tried Win versions more recent than XP.

fenugrec commented 6 years ago

btw, you should reaaally be working on a local branch on your tree, not adding commits to master !

fenugrec commented 5 years ago

Well, it almost took a year, but finally got around to merging this in c33eab1. Sorry for the long wait !