ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.8 months ago (distributed domain, exempt) |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://github.com/odwdinc/Python-SimConnect |
| Last Crawled | 2026-03-25 10:22:38 (23 days ago) |
| First Indexed | 2020-09-02 21:30:19 (5 years ago) |
| HTTP Status Code | 200 |
| Meta Title | GitHub - odwdinc/Python-SimConnect: Python interface for MSFS2020 SimConnect.dll · GitHub |
| Meta Description | Python interface for MSFS2020 SimConnect.dll. Contribute to odwdinc/Python-SimConnect development by creating an account on GitHub. |
| Meta Canonical | null |
| Boilerpipe Text | Python interface for Microsoft Flight Simulator 2020 (MSFS2020) using SimConnect
This library allows Python scripts to read and set variables within MSFS2020 and trigger events within the simulation.
It also includes, as an example, "Cockpit Companion", a flask mini http server which runs locally. It provides a web UI with a moving map and simulation variables. It also provides simulation data in JSON format in response to REST API requests.
Full documentation for this example can be found at
https://msfs2020.cc
and it is included in a standalone repo here on Github as
MSFS2020-cockpit-companion
.
Mobiflight Simconnect events:
Yes this supports the new
SimConnect commands that DocMoebiuz
of
MobiFlight
developed.
A full list of
commands and install instructions
At this time MobiFlight SimConnect commands are not include in the AircraftEvents class and as so the AircraftEvents.find() and AircraftEvents.get() will not work. You will need to pass the Event ID to a new Event class as the Example below shows.
from
SimConnect
import
*
# Create SimConnect link
sm
=
SimConnect
()
# Creat a function to call the MobiFlight AS1000_MFD_SOFTKEYS_3 event.
Sk3
=
Event
(
b'MobiFlight.AS1000_MFD_SOFTKEYS_3'
,
sm
)
# Call the Event.
Sk3
()
sm
.
exit
()
quit
()
Python interface example
from
SimConnect
import
*
# Create SimConnect link
sm
=
SimConnect
()
# Note the default _time is 2000 to be refreshed every 2 seconds
aq
=
AircraftRequests
(
sm
,
_time
=
2000
)
# Use _time=ms where ms is the time in milliseconds to cache the data.
# Setting ms to 0 will disable data caching and always pull new data from the sim.
# There is still a timeout of 4 tries with a 10ms delay between checks.
# If no data is received in 40ms the value will be set to None
# Each request can be fine tuned by setting the time param.
# To find and set timeout of cached data to 200ms:
altitude
=
aq
.
find
(
"PLANE_ALTITUDE"
)
altitude
.
time
=
200
# Get the aircraft's current altitude
altitude
=
aq
.
get
(
"PLANE_ALTITUDE"
)
altitude
=
altitude
+
1000
# Set the aircraft's current altitude
aq
.
set
(
"PLANE_ALTITUDE"
,
altitude
)
ae
=
AircraftEvents
(
sm
)
# Trigger a simple event
event_to_trigger
=
ae
.
find
(
"AP_MASTER"
)
# Toggles autopilot on or off
event_to_trigger
()
# Trigger an event while passing a variable
target_altitude
=
15000
event_to_trigger
=
ae
.
find
(
"AP_ALT_VAR_SET_ENGLISH"
)
# Sets AP autopilot hold level
event_to_trigger
(
target_altitude
)
sm
.
exit
()
quit
()
HTTP interface example
Run
glass_server.py
using Python 3.
http://localhost:5000
Method: GET
Variables: None
Output: Web interface with moving map and aircraft information
http://localhost:5000/dataset/<dataset_name>
Method: GET
Arguments to pass:
Argument
Location
Description
dataset_name
in path
can be navigation, airspeed compass, vertical_speed, fuel, flaps, throttle, gear, trim, autopilot, cabin
Description: Returns set of variables from simulator in JSON format
http://localhost:5000/datapoint/<datapoint_name>/get
Method: GET
Arguments to pass:
Argument
Location
Description
datapoint_name
in path
any variable name from MS SimConnect documentation
Description: Returns individual variable from simulator in JSON format
http://localhost:5000/datapoint/<datapoint_name>/set
Method: POST
Arguments to pass:
Argument
Location
Description
datapoint_name
in path
any variable name from MS SimConnect documentation
index (optional)
form or json
the relevant index if required (eg engine number) - if not passed defaults to None
value_to_use (optional)
value to set variable to - if not passed defaults to 0
Description: Sets datapoint in the simulator
http://localhost:5000/event/<event_name>/trigger
Method: POST
Arguments to pass:
Argument
Location
Description
event_name
in path
any event name from MS SimConnect documentation
value_to_use (optional)
value to pass to the event
Description: Triggers an event in the simulator
Running SimConnect on a separate system.
Note: At this time SimConnect can only run on Windows hosts.
Create a file called SimConnect.cfg in the same folder as your script.
Sample SimConnect.cfg:
;
Example SimConnect client configurations
[SimConnect]
Protocol
=IPv4
Address
=<ip of server>
Port
=500
To enable the host running the sim to share over network,
add <Address>0.0.0.0</Address>
under the <Port>500</Port> in SimConnect.xml
SimConnect.xml can be located at
%AppData%\Microsoft Flight Simulator\SimConnect.xml
Sample SimConnect.xml:
<?
xml
version
=
"
1.0
"
encoding
=
"
Windows-1252
"
?>
<
SimBase
.Document
Type
=
"
SimConnect
"
version
=
"
1,0
"
>
<
Descr
>SimConnect Server Configuration</
Descr
>
<
Filename
>SimConnect.xml</
Filename
>
<
SimConnect
.Comm>
<
Descr
>Static IP4 port</
Descr
>
<
Protocol
>IPv4</
Protocol
>
<
Scope
>local</
Scope
>
<
Port
>500</
Port
>
<
Address
>0.0.0.0</
Address
>
<
MaxClients
>64</
MaxClients
>
<
MaxRecvSize
>41088</
MaxRecvSize
>
</
SimConnect
.Comm>
...
Notes:
Python 64-bit is needed. You may see this Error if running 32-bit python:
OSError: [WinError 193] %1 is not a valid Win32 application
Per mracko on COM_RADIO_SET:
MSFS uses the European COM frequency spacing of 8.33kHz for all default aircraft.
This means that in practice, you increment the frequency by 0.005 MHz and
skip x.x20, x.x45, x.x70, and x.x95 MHz frequencies.
Have a look here http://g3asr.co.uk/calculators/833kHz.htm
Events and Variables
Below are links to the Microsoft documentation
Function
Event IDs
Simulation Variables |
| Markdown | [Skip to content](https://github.com/odwdinc/Python-SimConnect#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fodwdinc%2FPython-SimConnect)
Appearance settings
- Platform
- AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
- DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
- APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
- EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com/)
- [Blog](https://github.blog/)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
- Solutions
- BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
- BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
- BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
- Resources
- EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
- EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com/)
- SUPPORT & SERVICES
- [Documentation](https://docs.github.com/)
- [Customer support](https://support.github.com/)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
[View all resources](https://github.com/resources)
- Open Source
- COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
- PROGRAMS
- [Security Lab](https://securitylab.github.com/)
- [Maintainer Community](https://maintainers.github.com/)
- [Accelerator](https://github.com/accelerator)
- [GitHub Stars](https://stars.github.com/)
- [Archive Program](https://archiveprogram.github.com/)
- REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
- Enterprise
- ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
- AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
- [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Cancel
Create saved search
[Sign in](https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fodwdinc%2FPython-SimConnect)
[Sign up](https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=odwdinc%2FPython-SimConnect)
Appearance settings
Resetting focus
You signed in with another tab or window. [Reload](https://github.com/odwdinc/Python-SimConnect) to refresh your session. You signed out in another tab or window. [Reload](https://github.com/odwdinc/Python-SimConnect) to refresh your session. You switched accounts on another tab or window. [Reload](https://github.com/odwdinc/Python-SimConnect) to refresh your session.
Dismiss alert
{{ message }}
[odwdinc](https://github.com/odwdinc) / **[Python-SimConnect](https://github.com/odwdinc/Python-SimConnect)** Public
- [Notifications](https://github.com/login?return_to=%2Fodwdinc%2FPython-SimConnect)
You must be signed in to change notification settings
- [Fork 125](https://github.com/login?return_to=%2Fodwdinc%2FPython-SimConnect)
- [Star 306](https://github.com/login?return_to=%2Fodwdinc%2FPython-SimConnect)
- [Code](https://github.com/odwdinc/Python-SimConnect)
- [Issues 35](https://github.com/odwdinc/Python-SimConnect/issues)
- [Pull requests 4](https://github.com/odwdinc/Python-SimConnect/pulls)
- [Actions](https://github.com/odwdinc/Python-SimConnect/actions)
- [Projects](https://github.com/odwdinc/Python-SimConnect/projects)
- [Security 0](https://github.com/odwdinc/Python-SimConnect/security)
- [Insights](https://github.com/odwdinc/Python-SimConnect/pulse)
Additional navigation options
- [Code](https://github.com/odwdinc/Python-SimConnect)
- [Issues](https://github.com/odwdinc/Python-SimConnect/issues)
- [Pull requests](https://github.com/odwdinc/Python-SimConnect/pulls)
- [Actions](https://github.com/odwdinc/Python-SimConnect/actions)
- [Projects](https://github.com/odwdinc/Python-SimConnect/projects)
- [Security](https://github.com/odwdinc/Python-SimConnect/security)
- [Insights](https://github.com/odwdinc/Python-SimConnect/pulse)
# odwdinc/Python-SimConnect
master
[**4** Branches](https://github.com/odwdinc/Python-SimConnect/branches)
[**0** Tags](https://github.com/odwdinc/Python-SimConnect/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | Name | Last commit message | Last commit date |
|---|---|---|---|
| Latest commit [](https://github.com/odwdinc)[odwdinc](https://github.com/odwdinc/Python-SimConnect/commits?author=odwdinc) [Update \_\_init\_\_.py](https://github.com/odwdinc/Python-SimConnect/commit/af3eb9deedcf88fde422da2ac12fa41b96984942) Open commit details Jun 15, 2022 [af3eb9d](https://github.com/odwdinc/Python-SimConnect/commit/af3eb9deedcf88fde422da2ac12fa41b96984942) · Jun 15, 2022 History [323 Commits](https://github.com/odwdinc/Python-SimConnect/commits/master/) Open commit details 323 Commits | | | |
## Repository files navigation
- [README](https://github.com/odwdinc/Python-SimConnect)
- [AGPL-3.0 license](https://github.com/odwdinc/Python-SimConnect)
[](https://badge.fury.io/py/SimConnect)
# Python-SimConnect
Python interface for Microsoft Flight Simulator 2020 (MSFS2020) using SimConnect
This library allows Python scripts to read and set variables within MSFS2020 and trigger events within the simulation.
It also includes, as an example, "Cockpit Companion", a flask mini http server which runs locally. It provides a web UI with a moving map and simulation variables. It also provides simulation data in JSON format in response to REST API requests.
Full documentation for this example can be found at <https://msfs2020.cc> and it is included in a standalone repo here on Github as [MSFS2020-cockpit-companion](https://github.com/hankhank10/MSFS2020-cockpit-companion).
## Mobiflight Simconnect events:
Yes this supports the new [SimConnect commands that DocMoebiuz](https://forums.flightsimulator.com/t/full-g1000-control-now-with-mobiflight/348509) of [MobiFlight](https://www.mobiflight.com/en/index.html) developed. A full list of [commands and install instructions](https://pastebin.com/fMdB7at2)
At this time MobiFlight SimConnect commands are not include in the AircraftEvents class and as so the AircraftEvents.find() and AircraftEvents.get() will not work. You will need to pass the Event ID to a new Event class as the Example below shows.
```
from SimConnect import *
# Create SimConnect link
sm = SimConnect()
# Creat a function to call the MobiFlight AS1000_MFD_SOFTKEYS_3 event.
Sk3 = Event(b'MobiFlight.AS1000_MFD_SOFTKEYS_3', sm)
# Call the Event.
Sk3()
sm.exit()
quit()
```
## Python interface example
```
from SimConnect import *
# Create SimConnect link
sm = SimConnect()
# Note the default _time is 2000 to be refreshed every 2 seconds
aq = AircraftRequests(sm, _time=2000)
# Use _time=ms where ms is the time in milliseconds to cache the data.
# Setting ms to 0 will disable data caching and always pull new data from the sim.
# There is still a timeout of 4 tries with a 10ms delay between checks.
# If no data is received in 40ms the value will be set to None
# Each request can be fine tuned by setting the time param.
# To find and set timeout of cached data to 200ms:
altitude = aq.find("PLANE_ALTITUDE")
altitude.time = 200
# Get the aircraft's current altitude
altitude = aq.get("PLANE_ALTITUDE")
altitude = altitude + 1000
# Set the aircraft's current altitude
aq.set("PLANE_ALTITUDE", altitude)
ae = AircraftEvents(sm)
# Trigger a simple event
event_to_trigger = ae.find("AP_MASTER") # Toggles autopilot on or off
event_to_trigger()
# Trigger an event while passing a variable
target_altitude = 15000
event_to_trigger = ae.find("AP_ALT_VAR_SET_ENGLISH") # Sets AP autopilot hold level
event_to_trigger(target_altitude)
sm.exit()
quit()
```
## HTTP interface example
Run `glass_server.py` using Python 3.
#### `http://localhost:5000`
Method: GET
Variables: None
Output: Web interface with moving map and aircraft information
#### `http://localhost:5000/dataset/<dataset_name>`
Method: GET
Arguments to pass:
| Argument | Location | Description |
|---|---|---|
| dataset\_name | in path | can be navigation, airspeed compass, vertical\_speed, fuel, flaps, throttle, gear, trim, autopilot, cabin |
Description: Returns set of variables from simulator in JSON format
#### `http://localhost:5000/datapoint/<datapoint_name>/get`
Method: GET
Arguments to pass:
| Argument | Location | Description |
|---|---|---|
| datapoint\_name | in path | any variable name from MS SimConnect documentation |
Description: Returns individual variable from simulator in JSON format
#### `http://localhost:5000/datapoint/<datapoint_name>/set`
Method: POST
Arguments to pass:
| Argument | Location | Description |
|---|---|---|
| datapoint\_name | in path | any variable name from MS SimConnect documentation |
| index (optional) | form or json | the relevant index if required (eg engine number) - if not passed defaults to None |
| value\_to\_use (optional) | value to set variable to - if not passed defaults to 0 | |
Description: Sets datapoint in the simulator
#### `http://localhost:5000/event/<event_name>/trigger`
Method: POST
Arguments to pass:
| Argument | Location | Description |
|---|---|---|
| event\_name | in path | any event name from MS SimConnect documentation |
| value\_to\_use (optional) | value to pass to the event | |
Description: Triggers an event in the simulator
## Running SimConnect on a separate system.
#### Note: At this time SimConnect can only run on Windows hosts.
Create a file called SimConnect.cfg in the same folder as your script.
#### Sample SimConnect.cfg:
```
; Example SimConnect client configurations
[SimConnect]
Protocol=IPv4
Address=<ip of server>
Port=500
```
To enable the host running the sim to share over network,
add \<Address\>0.0.0.0\</Address\>
under the \<Port\>500\</Port\> in SimConnect.xml
SimConnect.xml can be located at
#### `%AppData%\Microsoft Flight Simulator\SimConnect.xml`
#### Sample SimConnect.xml:
```
<?xml version="1.0" encoding="Windows-1252"?>
<SimBase.Document Type="SimConnect" version="1,0">
<Descr>SimConnect Server Configuration</Descr>
<Filename>SimConnect.xml</Filename>
<SimConnect.Comm>
<Descr>Static IP4 port</Descr>
<Protocol>IPv4</Protocol>
<Scope>local</Scope>
<Port>500</Port>
<Address>0.0.0.0</Address>
<MaxClients>64</MaxClients>
<MaxRecvSize>41088</MaxRecvSize>
</SimConnect.Comm>
...
```
## Notes:
Python 64-bit is needed. You may see this Error if running 32-bit python:
`OSError: [WinError 193] %1 is not a valid Win32 application`
Per mracko on COM\_RADIO\_SET:
```
MSFS uses the European COM frequency spacing of 8.33kHz for all default aircraft.
This means that in practice, you increment the frequency by 0.005 MHz and
skip x.x20, x.x45, x.x70, and x.x95 MHz frequencies.
Have a look here http://g3asr.co.uk/calculators/833kHz.htm
```
## Events and Variables
Below are links to the Microsoft documentation
[Function](https://docs.microsoft.com/en-us/previous-versions/microsoft-esp/cc526983\(v=msdn.10\))
[Event IDs](https://docs.microsoft.com/en-us/previous-versions/microsoft-esp/cc526980\(v=msdn.10\))
[Simulation Variables](https://docs.flightsimulator.com/html/Programming_Tools/SimVars/Simulation_Variables.htm)
## About
Python interface for MSFS2020 SimConnect.dll
### Resources
[Readme](https://github.com/odwdinc/Python-SimConnect#readme-ov-file)
### License
[AGPL-3.0 license](https://github.com/odwdinc/Python-SimConnect#AGPL-3.0-1-ov-file)
### Uh oh\!
There was an error while loading. [Please reload this page](https://github.com/odwdinc/Python-SimConnect).
[Activity](https://github.com/odwdinc/Python-SimConnect/activity)
### Stars
[**306** stars](https://github.com/odwdinc/Python-SimConnect/stargazers)
### Watchers
[**29** watching](https://github.com/odwdinc/Python-SimConnect/watchers)
### Forks
[**125** forks](https://github.com/odwdinc/Python-SimConnect/forks)
[Report repository](https://github.com/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fodwdinc%2FPython-SimConnect&report=odwdinc+%28user%29)
## [Releases](https://github.com/odwdinc/Python-SimConnect/releases)
No releases published
## [Packages 0](https://github.com/users/odwdinc/packages?repo_name=Python-SimConnect)
No packages published
## [Contributors](https://github.com/odwdinc/Python-SimConnect/graphs/contributors)
### Uh oh\!
There was an error while loading. [Please reload this page](https://github.com/odwdinc/Python-SimConnect).
## Languages
- [Python 86.6%](https://github.com/odwdinc/Python-SimConnect/search?l=python)
- [HTML 8.8%](https://github.com/odwdinc/Python-SimConnect/search?l=html)
- [JavaScript 3.0%](https://github.com/odwdinc/Python-SimConnect/search?l=javascript)
- [CSS 1.5%](https://github.com/odwdinc/Python-SimConnect/search?l=css)
- [Makefile 0.1%](https://github.com/odwdinc/Python-SimConnect/search?l=makefile)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
- [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
- [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
- [Security](https://github.com/security)
- [Status](https://www.githubstatus.com/)
- [Community](https://github.community/)
- [Docs](https://docs.github.com/)
- [Contact](https://support.github.com/?tags=dotcom-footer)
- Manage cookies
- Do not share my personal information
You can’t perform that action at this time. |
| Readable Markdown | [](https://badge.fury.io/py/SimConnect)
Python interface for Microsoft Flight Simulator 2020 (MSFS2020) using SimConnect
This library allows Python scripts to read and set variables within MSFS2020 and trigger events within the simulation.
It also includes, as an example, "Cockpit Companion", a flask mini http server which runs locally. It provides a web UI with a moving map and simulation variables. It also provides simulation data in JSON format in response to REST API requests.
Full documentation for this example can be found at [https://msfs2020.cc](https://msfs2020.cc/) and it is included in a standalone repo here on Github as [MSFS2020-cockpit-companion](https://github.com/hankhank10/MSFS2020-cockpit-companion).
Mobiflight Simconnect events:
Yes this supports the new [SimConnect commands that DocMoebiuz](https://forums.flightsimulator.com/t/full-g1000-control-now-with-mobiflight/348509) of [MobiFlight](https://www.mobiflight.com/en/index.html) developed. A full list of [commands and install instructions](https://pastebin.com/fMdB7at2)
At this time MobiFlight SimConnect commands are not include in the AircraftEvents class and as so the AircraftEvents.find() and AircraftEvents.get() will not work. You will need to pass the Event ID to a new Event class as the Example below shows.
```
from SimConnect import *
# Create SimConnect link
sm = SimConnect()
# Creat a function to call the MobiFlight AS1000_MFD_SOFTKEYS_3 event.
Sk3 = Event(b'MobiFlight.AS1000_MFD_SOFTKEYS_3', sm)
# Call the Event.
Sk3()
sm.exit()
quit()
```
Python interface example
```
from SimConnect import *
# Create SimConnect link
sm = SimConnect()
# Note the default _time is 2000 to be refreshed every 2 seconds
aq = AircraftRequests(sm, _time=2000)
# Use _time=ms where ms is the time in milliseconds to cache the data.
# Setting ms to 0 will disable data caching and always pull new data from the sim.
# There is still a timeout of 4 tries with a 10ms delay between checks.
# If no data is received in 40ms the value will be set to None
# Each request can be fine tuned by setting the time param.
# To find and set timeout of cached data to 200ms:
altitude = aq.find("PLANE_ALTITUDE")
altitude.time = 200
# Get the aircraft's current altitude
altitude = aq.get("PLANE_ALTITUDE")
altitude = altitude + 1000
# Set the aircraft's current altitude
aq.set("PLANE_ALTITUDE", altitude)
ae = AircraftEvents(sm)
# Trigger a simple event
event_to_trigger = ae.find("AP_MASTER") # Toggles autopilot on or off
event_to_trigger()
# Trigger an event while passing a variable
target_altitude = 15000
event_to_trigger = ae.find("AP_ALT_VAR_SET_ENGLISH") # Sets AP autopilot hold level
event_to_trigger(target_altitude)
sm.exit()
quit()
```
HTTP interface example
Run `glass_server.py` using Python 3.
`http://localhost:5000`
Method: GET
Variables: None
Output: Web interface with moving map and aircraft information
`http://localhost:5000/dataset/<dataset_name>`
Method: GET
Arguments to pass:
| Argument | Location | Description |
|---|---|---|
| dataset\_name | in path | can be navigation, airspeed compass, vertical\_speed, fuel, flaps, throttle, gear, trim, autopilot, cabin |
Description: Returns set of variables from simulator in JSON format
`http://localhost:5000/datapoint/<datapoint_name>/get`
Method: GET
Arguments to pass:
| Argument | Location | Description |
|---|---|---|
| datapoint\_name | in path | any variable name from MS SimConnect documentation |
Description: Returns individual variable from simulator in JSON format
`http://localhost:5000/datapoint/<datapoint_name>/set`
Method: POST
Arguments to pass:
| Argument | Location | Description |
|---|---|---|
| datapoint\_name | in path | any variable name from MS SimConnect documentation |
| index (optional) | form or json | the relevant index if required (eg engine number) - if not passed defaults to None |
| value\_to\_use (optional) | value to set variable to - if not passed defaults to 0 | |
Description: Sets datapoint in the simulator
`http://localhost:5000/event/<event_name>/trigger`
Method: POST
Arguments to pass:
| Argument | Location | Description |
|---|---|---|
| event\_name | in path | any event name from MS SimConnect documentation |
| value\_to\_use (optional) | value to pass to the event | |
Description: Triggers an event in the simulator
Running SimConnect on a separate system.
Note: At this time SimConnect can only run on Windows hosts.
Create a file called SimConnect.cfg in the same folder as your script.
Sample SimConnect.cfg:
```
; Example SimConnect client configurations
[SimConnect]
Protocol=IPv4
Address=<ip of server>
Port=500
```
To enable the host running the sim to share over network,
add \<Address\>0.0.0.0\</Address\>
under the \<Port\>500\</Port\> in SimConnect.xml
SimConnect.xml can be located at
`%AppData%\Microsoft Flight Simulator\SimConnect.xml`
Sample SimConnect.xml:
```
<?xml version="1.0" encoding="Windows-1252"?>
<SimBase.Document Type="SimConnect" version="1,0">
<Descr>SimConnect Server Configuration</Descr>
<Filename>SimConnect.xml</Filename>
<SimConnect.Comm>
<Descr>Static IP4 port</Descr>
<Protocol>IPv4</Protocol>
<Scope>local</Scope>
<Port>500</Port>
<Address>0.0.0.0</Address>
<MaxClients>64</MaxClients>
<MaxRecvSize>41088</MaxRecvSize>
</SimConnect.Comm>
...
```
Notes:
Python 64-bit is needed. You may see this Error if running 32-bit python:
`OSError: [WinError 193] %1 is not a valid Win32 application`
Per mracko on COM\_RADIO\_SET:
```
MSFS uses the European COM frequency spacing of 8.33kHz for all default aircraft.
This means that in practice, you increment the frequency by 0.005 MHz and
skip x.x20, x.x45, x.x70, and x.x95 MHz frequencies.
Have a look here http://g3asr.co.uk/calculators/833kHz.htm
```
Events and Variables
Below are links to the Microsoft documentation
[Function](https://docs.microsoft.com/en-us/previous-versions/microsoft-esp/cc526983\(v=msdn.10\))
[Event IDs](https://docs.microsoft.com/en-us/previous-versions/microsoft-esp/cc526980\(v=msdn.10\))
[Simulation Variables](https://docs.flightsimulator.com/html/Programming_Tools/SimVars/Simulation_Variables.htm) |
| Shard | 174 (laksa) |
| Root Hash | 6325672905007345774 |
| Unparsed URL | com,github!/odwdinc/Python-SimConnect s443 |