Skip to main content

py-simcon

This is a Python wrapper for SimConnect library which is used to talk to Microsoft Flight Simulator. This wrapper provides natural pythonic interface. It can be used in both synchronous and asynchronous (asyncio) applications. In both cases it is thread safe.

Features

  • Listen to system events (aircraft loaded, game paused, etc)
  • Receive data updates
  • Async and sync interfaces, which can work together simultaneously

Examples

Conventional (synchronous)

import pprint

from simcon import Sim, DataField, PERIOD
from simcon.data import types


with Sim("MyApp") as sim:
    data = sim.sync_request_data_once([
        DataField("ATC ID", None, types.STRING32),
        DataField("Title", None, types.STRING256),
    ])
    pprint.pprint(data)
    data_request = sim.request_data_on_sim_object(
        [
            DataField("HSI station ident", None, types.STRING8),
            DataField("Plane latitude", "degrees"),
            DataField("Plane longitude", "degrees"),
            DataField("Plane altitude", "feet"),
            DataField("GPS ground true track", "degrees"),
            DataField("GPS ground speed", "knots"),
            DataField("Zulu time", "seconds"),
        ],
        PERIOD.SECOND,
    )
    count = 0
    for data in data_request:
        pprint.pprint(data)
        count += 1
        if count >= 3:
            break

Result:

{'GPS ground speed': 97.83114326014487,
 'GPS ground true track': 307.4598039853386,
 'Plane altitude': 8501.684970335986,
 'Plane latitude': 39.3924225392898,
 'Plane longitude': -125.57142850592173,
 'Zulu time': 3287.369384765625}
{'GPS ground speed': 97.83704928992589,
 'GPS ground true track': 307.45556123353225,
 'Plane altitude': 8501.840396854732,
 'Plane latitude': 39.39269706474836,
 'Plane longitude': -125.57189141562071,
 'Zulu time': 3288.369384765625}
...

Asynchronous (asyncio):

import asyncio
import pprint

from simcon import Sim, DataField, PERIOD
from simcon.data import types


async def show_data():
    async with Sim("MyApp") as sim:
        data = await sim.request_data_once([
            DataField("ATC ID", None, types.STRING32),
            DataField("Title", None, types.STRING256),
        ])
        pprint.pprint(data)
        data_request = sim.request_data_on_sim_object(
            [
                DataField("HSI station ident", None, types.STRING8),
                DataField("Plane latitude", "degrees"),
                DataField("Plane longitude", "degrees"),
                DataField("Plane altitude", "feet"),
                DataField("GPS ground true track", "degrees"),
                DataField("GPS ground speed", "knots"),
                DataField("Zulu time", "seconds"),
            ],
            PERIOD.SECOND,
        )
        count = 0
        async for data in data_request:
            pprint.pprint(data)
            count += 1
            if count >= 3:
                break

asyncio.run(show_data())

Results will be the same as in the example above

Release History

Yet to release

  • Nothing so far

0.6.1

  • Always release GIL before calling SimConnect (fixes freezes)

0.6.0

  • Fixed event/data cleanup exceptions when stopping
  • Fixed iterating over changing dicts when stopping
  • Fixed non-asyncio-friendly threading.Lock causing deadlocks (API changed!)

0.5.0

  • Added more parameters to data requests:
    • when - either always, or only when the data changes (default: always)
    • origin - periods to wait before first data transmission (default: 0)
    • interval - periods between data transmissions (default: 1, i.e. every period)
    • limit - limit the number of data transmissions (default: 0, i.e. never stop)
  • Fixed 32-bit fields alignment

0.4.0

  • Wrapped SimConnect failures into OSError instead of a generic RuntimeError
  • Sim now stops when the simulator quits.
  • Added wait_stop() to wait until Sim stops
  • Stop Sim if it failed to start as a context manager

0.3.0

  • Added support for strings, integer, and float32 data types
  • Added a helper to request data once

0.2.0

  • Added start() and stop() methods. All event and data listeners will throw Closed() exception if they are still being awaited when Sim stops, or if it is already stopped when wait() is called.

0.1.0

  • Initial release

Metadata

Release files for simcon 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simcon 0.6.1
File Size Uploaded Provenance Actions
simcon-0.6.1.tar.gz 17.2 kB Without provenance Details for simcon-0.6.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for simcon 0.6.1
File Interpreter ABI Platform Actions
simcon-0.6.1-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for simcon-0.6.1-cp39-cp39-win_amd64.whl
simcon-0.6.1-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details for simcon-0.6.1-cp38-cp38-win_amd64.whl
simcon-0.6.1-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details for simcon-0.6.1-cp37-cp37m-win_amd64.whl

Total release size: 1.6 MB

Release files / simcon-0.6.1.tar.gz

Download URL simcon-0.6.1.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9730376ef352c214cd4cceec0974f610981082390da5941a79a91c17fa859740
BLAKE2b-256 checksum
How to use checksums
ecc51f3607482d1505abf0cf20c6cf9caeafebd15d759cb11d978e5cb3dfff3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / simcon-0.6.1-cp39-cp39-win_amd64.whl

Download URL simcon-0.6.1-cp39-cp39-win_amd64.whl
Size 524.6 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
1220426bab5e17721d7038585b6752f1ba9bc5cb569fe40297ae9e352ffb5087
BLAKE2b-256 checksum
How to use checksums
993c86544379fe9105ea4f72815a66b55e2399d6a89f512e3641aa9c19ef1f90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / simcon-0.6.1-cp38-cp38-win_amd64.whl

Download URL simcon-0.6.1-cp38-cp38-win_amd64.whl
Size 524.9 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
1d577f51ea1c38010231cbe890ad57befa9a31a8d0e8c4b7d9b2ceed075e9c58
BLAKE2b-256 checksum
How to use checksums
5fa90203f15a4b9dd0b78599842d5adffd29edc9c92b0d490ec53121c280e892
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Release files / simcon-0.6.1-cp37-cp37m-win_amd64.whl

Download URL simcon-0.6.1-cp37-cp37m-win_amd64.whl
Size 511.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
c66f5f6a9eae0465d74b9898894f3d72b62d0a6ce772e7ce64d6f31d9a29231e
BLAKE2b-256 checksum
How to use checksums
3ee80158b0115dda2f37c6ea1e0c972582ecfb4ab6756ea730e4f620f595747d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.9

Security for simcon 0.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page