pysimconnect icon indicating copy to clipboard operation
pysimconnect copied to clipboard

Unable to Read Environment Variables from FS2020

Open hdinthkld opened this issue 5 months ago • 1 comments

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 avatar Jan 18 '24 21:01 hdinthkld