-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python-SimConnect Help with P3D? #75
Comments
Hello Vamshi, Thanks for your interest! happy to help.
my suggestions is to test with changing
to self.Open = self.SimConnect.SimConnect
and
to self.Close = self.SimConnect.Dispose
let me know if this helps. and good luck! |
Hey! Thanks for the reply! So, the server and client are both running on the same system. Thus, I did not make any change to the xmls/cfgs involved. AttributeError: function 'SimConnect' not found |
ok, is there another dll or are you using the LockheedMartin.Prepar3D.SimConnect.dll from SDK\lib\SimConnect\managed? |
Hey, Yeah. So I've been using LockheedMartin.Prepar3D.SimConnect.dll from SDK\lib\SimConnect\managed. I cannot find the un-managed SimConnect.dll anywhere on the SDK other than instances of: C:\Program Files\Lockheed Martin\Prepar3D v5\redist\Interface, which i guess are legacy versions? Should I try to find something on google? lol |
you could try the Microsoft.FlightSimulator.SimConnect.dll if it works grate, if not then its probley managed as well. I did find this gem, looks to be
https://www.prepar3d.com/forum/viewtopic.php?t=7502 http://prepar3d.net/forum/viewtopic.php?t=125348
So Try google, check out FSX/ESP might be helpful. if push comes to shove try compiling your own simconnect.dll ?? https://docs.microsoft.com/en-us/cpp/build/walkthrough-creating-and-using-a-dynamic-link-library-cpp?view=msvc-160 good luck! |
Hey, Thank you. I tried the Microsoft.FlightSimulator.SimConnect.dll. and I get the following error when I run the python script. OSError: [WinError 193] %1 is not a valid Win32 application, Do you know what this could mean? https://stackoverflow.com/questions/25651990/oserror-winerror-193-1-is-not-a-valid-win32-application according to this, it seems like I have to point to the python.exe file. I will check it out and update you. I will explore this route as well as potentially compiling our own simconnect.dll. |
miss matched python version 64bit vs 32bit. Edit, The bit of python needs to match the bit of the DLL. aka a 64bit DLL needs 64bit python and 32bit DLL needs 32bit python. It looks like the older versions is 32bit so use 32bit python for testing. |
wow that's wonderful!! Python-SimConnect/local_example.py Lines 26 to 36 in 9d855a4
Just test altitude for None before adding back to altitude. Python-SimConnect/SimConnect/RequestList.py Lines 18 to 23 in 9d855a4
if the data is not found in the timeout then returns NoneType maybe change _attemps is default to 10. _time is for cashing results _time=0 disables cashing. See for more samples. Also you are welcome to test the new Asyncio branch, no NoneType there :) |
Hey! Thank you so much!!!!! IT works like a charm, I didn't check for the none type stuff yet. But I will do that later. Thank you so much for your help! I will write up a report along with instructions that I realized to get this working with P3D. and contribute to this project :) Once again! Thanks!!!!! |
Glad to help, Happy Holladay's and all, and good luck with your PhD! |
Thank you! And good luck to you too on your endeavors! Kind Regards |
Thank you. Where are you seeing 2000ms? Updates to SimConnect are called every 2ms via: Python-SimConnect/SimConnect/SimConnect.py Lines 171 to 174 in 9d855a4
Data is pushed to SimConnect without delays via: Python-SimConnect/SimConnect/RequestList.py Lines 27 to 31 in 9d855a4
Then: Python-SimConnect/SimConnect/SimConnect.py Lines 215 to 240 in 9d855a4
|
Oh! Nevermind, I thought it was 2secs sorry about that. |
Are you calling Python-SimConnect/SimConnect/SimConnect.py Lines 176 to 179 in 9d855a4
looks like the error is started with call on Proper exit is: Python-SimConnect/local_example.py Lines 23 to 24 in 9d855a4
If you able to post some test code when you see the problem, I can take a look. |
Are you running form command line or form some IDE? I have had reports that some IDE's (Visual Studio) may cause errors. from SimConnect import *
import logging
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger(__name__)
LOGGER.info("START")
sm = SimConnect()
aq = AircraftRequests(sm, _time=0, _attemps=20)
pa = aq.find("PLANE_ALTITUDE")
print(pa.get())
sm.exit()
quit() |
So my best guess is that there is some python threading running in the background?? Maybe form the time you where calling sm.quit() vs sm.exit(). also are you using python in a Virtual Environment? |
Hey, Checked with a reboot as well as closing any instances of python on task manager... |
Best guess is how windows handles 32bit apps in 64bit. As this is a windows only program I think we can get by with self.DispatchProc = WINFUNCTYPE(c_void_p, POINTER(SIMCONNECT_RECV), DWORD, c_void_p) vs
I tested on the 64bit and see no errors replacing this line, hopefully this will help. |
Hey, No, making the change still throws the same exceptions for some reason. I am clearly lost at what the issue could be. However, it is throwing an OSError(OSError: exception: access violation writing 0x04220048), which in the link you posted and the following shows the potential issue:
Thank you for all your kind help. |
Hey!!
--> self.SimConnect = windll.LoadLibrary(library_path) and then
to
in the attributes file. Thank you so much for all the help!! Kind Regards |
wonderful! |
fix Python-SimConnect Help with P3D? #75
Thank you so much!! |
Sorry to bother you but I wonder could you please upload the copy you have changed to match P3D? Thank you! |
Hello,
First of all, I really want to thank you for providing such an amazing piece of software.
My name is Vamshi, a PhD student from Ryerson University, Toronto, we are working on a project in which we need to control a Prepar3D(P3D) simulation with external data sources (data coming in from a python program...we are using a gps data log file to send data into the simulation.)
I have landed on Python-SimConnect and have been thanking the gods for it serves the exact purpose. I am trying to run the setup and keep running into the following error:
"SIMCONNECT_EXCEPTION_VERSION_MISMATCH"
This is obviously because the SimConnect version being used and the s/w was designed for is FS2020. The P3D sim i am using is P3D V5 which has a simconnect version of 5.1.0. Thus, the server (P3D) does not match the Client SimConnect version.
Since both FS2020 and P3D all develop with SimConnect to send/receive data, this should work.
I've also tried another thing, I've moved the simconnect.dll files from the P3D path into the python project file so that it can reference a dll generated with the libraries compiled on the P3D side. However, I get the following error:
" File "C:\Users\MIMS-PC\AppData\Local\Programs\Python\Python38\lib\ctypes_init_.py", line 391, in getitem
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'SimConnect_Open' not found"
It says simconnect_open not found, in the attributes.py file, we notice that the:
self.SimConnect = cdll.LoadLibrary(library_path)
SIMCONNECTAPI SimConnect_Open(
HANDLE * phSimConnect,
LPCSTR szName,
HWND hWnd,
DWORD UserEventWin32,
HANDLE hEventHandle,
DWORD ConfigIndex)
SIMCONNECTAPI SimConnect_Open is commented out.
These are two possible methods that I am trying right now. Looking forward to your reply and your guidance.
Can you please please please guide me through this? It will help me so much with my studies in creating an amazing data-driven simulation.
The text was updated successfully, but these errors were encountered: