kutu / pyirsdk

Python 3 implementation of iRacing SDK
MIT License
317 stars 48 forks source link

pyirdk sometimes does not connect #14

Closed mlyszczek closed 3 years ago

mlyszczek commented 3 years ago

Hi,

Sometimes (about 20% of the time) pyirsdk cannot initialize connection to the mmap file. I basically use code from example 3 and modified only loop() function to send telemetry over TCP. Some basic debug showed that mmap() is succesfull, but _header.version is 0, and _header.var_buf is "[]". I also tried to dump mmap with pyirsdk.exe but it failed to produce any file as well.

Restarting the script does not work. Only workaround is to close the sim and start it again. Sometimes I have to do this multiple times.

So it looks like the problem is iracing itself? Did you have same problem in the past?

kutu commented 3 years ago

never

only issue we have is this one https://members.iracing.com/jforum/posts/list/3771391.page

mlyszczek commented 3 years ago

I think I've found solution (or at least workaround) for this problem. See pull request https://github.com/kutu/pyirsdk/pull/15

Without that patch problem on my side was reproducing 100% of the time with steps.

With that patch, I had 0 problems with telemetry so far (around 20 times when I restarted the sim)

kutu commented 3 years ago

you must reconnect pyirsdk check this tutorial https://github.com/kutu/pyirsdk/blob/master/tutorials/03%20Base%20application.md

mlyszczek commented 3 years ago

No, it doesn't work. I use that exact code on windows, the only change I've made is loop() where I simply send telemetry over TCP.

As soon as pyirsdk reads simstatus to be 1 (via http localhost), it opens telemetry file and does not close it. It just waits untils something shows up in the file - but it never does. No matter how many times I restarted pyirsdk, telemetry never shows again in that file.

It looks like, if pyirsdk does mmap() on that file, iracing for some reason cannot do the same and will not output any data. Obviously it's a bug in iracing on windows, but since we cannot change any of those, I proposed workaround in pyirsdk.