Skip to content
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

Unable to Read Environment Variables from FS2020 #15

Open
hdinthkld opened this issue Jan 18, 2024 · 1 comment
Open

Unable to Read Environment Variables from FS2020 #15

hdinthkld opened this issue Jan 18, 2024 · 1 comment

Comments

@hdinthkld
Copy link

hdinthkld commented Jan 18, 2024

Is it possible to read the simulators environment variables (e.g. ZULU TIME)?

Using same code from the demo sample with the below edit:

altitude = sc.get_simdatum("Indicated Altitude")
print("Got indicated altitude", altitude)

absolute_time= sc.get_simdatum("ABSOLUTE TIME")
print(absolute_time)

Results in the following:

INFO:root:Open: App b'KittyHawk' v11.0 build 282174.999 SimConnect: v11.0 build 62651.3
Got indicated altitude 8639.2451171875
Traceback (most recent call last):
  File "C:\Users\devuser\Documents\Projects\msfs-simconnect\pysimconnect_test.py", line 24, in <module>
    absolute_time = sc.get_simdatum("ABSOLUTE TIME")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\devuser\Documents\Projects\msfs-simconnect\venv\Lib\site-packages\simconnect\sc.py", line 113, in get_simdatum
    simdata = self.get_simdata([spec], timeout_seconds)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\devuser\Documents\Projects\msfs-simconnect\venv\Lib\site-packages\simconnect\sc.py", line 126, in get_simdata
    dd = self.subscribe_simdata(simvars, period=PERIOD_ONCE, repeat_count=1, flags=0)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\devuser\Documents\Projects\msfs-simconnect\venv\Lib\site-packages\simconnect\sc.py", line 151, in subscribe_simdata
    dd = DataDefinition.create(self, simvars)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\devuser\Documents\Projects\msfs-simconnect\venv\Lib\site-packages\simconnect\datadef.py", line 62, in create
    sv = validate_simvar(name, settable)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\devuser\Documents\Projects\msfs-simconnect\venv\Lib\site-packages\simconnect\scvars.py", line 15, in validate_simvar
    logging.warning(f"SimConnect: unrecognized simvar '{base}', {_closemsg(base, SIMVARS)}")
                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\devuser\Documents\Projects\msfs-simconnect\venv\Lib\site-packages\simconnect\scvars.py", line 87, in _closemsg
    options = (ss[:3] + ['...']) if len(ss) > 3 else ss
               ~~^^^^
KeyError: slice(None, 3, None)

According to this document it does say that they available by prefixing with "E:":
PROGRAMMING APIs

The bulk of the simvars I've tried calling appear to only be "A:" variables (e.g. SIM ON GROUND) which work as expected. Reviewing the scvars.json this also seems to be true.

I did find the below bug which could indicate it has been broken since SU14, I don't understand what the OP is saying he did to resolve it:
Simvars of E section not anymore available in SDK

@hdinthkld
Copy link
Author

Perhaps this is also of additional assistnace:
Reading Environment variables via SDK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant