Skip to content

Commit 7aad5e8

Browse files
authored
Merge pull request #69 from odwdinc/master
updated asyncio
2 parents a6d0042 + 9d855a4 commit 7aad5e8

File tree

4 files changed

+31
-20
lines changed

4 files changed

+31
-20
lines changed

README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ Full documentation for this example can be found at [https://msfs2020.cc](https:
1111

1212
## Python interface example
1313

14-
````
14+
```py
1515
from SimConnect import *
1616

1717
# Create SimConnect link
1818
sm = SimConnect()
19-
# Note the default _time is 2000 as to refreshed at 2s
19+
# Note the default _time is 2000 to be refreshed every 2 seconds
2020
aq = AircraftRequests(sm, _time=2000)
21-
# Use _time=ms where ms is the millsec to refresh data to cash.
22-
# setting ms to 0 will disable data cashing and allwas pull new data form sim.
23-
# There is still a timeout of 4 trys with a 10ms delay between checks.
24-
# If no data is received in 40ms the value will be set to -999999
25-
# Each Requests can be fine tuned by seting the time pram.
26-
# To find and set time out of cashed data to 200ms
21+
# Use _time=ms where ms is the time in milliseconds to cache the data.
22+
# Setting ms to 0 will disable data caching and always pull new data from the sim.
23+
# There is still a timeout of 4 tries with a 10ms delay between checks.
24+
# If no data is received in 40ms the value will be set to None
25+
# Each request can be fine tuned by setting the time param.
2726

27+
# To find and set timeout of cached data to 200ms:
2828
altitude = aq.find("PLANE_ALTITUDE")
2929
altitude.time = 200
3030

@@ -46,7 +46,7 @@ event_to_trigger = ae.find("AP_ALT_VAR_SET_ENGLISH") # Sets AP autopilot hold l
4646
event_to_trigger(target_altitude)
4747
sm.quit()
4848
exit()
49-
````
49+
```
5050

5151
## HTTP interface example
5252

@@ -108,20 +108,20 @@ Arguments to pass:
108108

109109
Description: Triggers an event in the simulator
110110

111-
## Runing SimConnect on other system.
111+
## Running SimConnect on a separate system.
112112

113113
#### Note: At this time SimConnect can only run on Windows hosts.
114114

115-
Creat a file called SimConnect.cfg in the same folder as your script.
115+
Create a file called SimConnect.cfg in the same folder as your script.
116116
#### Sample SimConnect.cfg:
117-
```
117+
```ini
118118
; Example SimConnect client configurations
119119
[SimConnect]
120120
Protocol=IPv4
121121
Address=<ip of server>
122122
Port=500
123123
```
124-
To enable the host running the sim to share over network,
124+
To enable the host running the sim to share over network,
125125

126126
add \<Address\>0.0.0.0\</Address\>
127127

@@ -131,7 +131,7 @@ SimConnect.xml can be located at
131131
#### `%AppData%\Microsoft Flight Simulator\SimConnect.xml`
132132

133133
#### Sample SimConnect.xml:
134-
```
134+
```xml
135135
<?xml version="1.0" encoding="Windows-1252"?>
136136

137137
<SimBase.Document Type="SimConnect" version="1,0">
@@ -158,12 +158,10 @@ Python 64-bit is needed. You may see this Error if running 32-bit python:
158158

159159
## Events and Variables
160160

161-
Below are links to the Microsoft documentation
161+
Below are links to the Microsoft documentation
162162

163163
[Function](https://docs.microsoft.com/en-us/previous-versions/microsoft-esp/cc526983(v=msdn.10))
164164

165165
[Event IDs](https://docs.microsoft.com/en-us/previous-versions/microsoft-esp/cc526980(v=msdn.10))
166166

167167
[Simulation Variables](https://docs.microsoft.com/en-us/previous-versions/microsoft-esp/cc526981(v=msdn.10))
168-
169-

SimConnect/EventList.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,4 +1222,4 @@ class __G1000_MFD(EventHelper):
12221222
(b'G1000_MFD_PAGE_KNOB_INC', "Step up through the individual pages.", "Shared Cockpit"),
12231223
(b'G1000_MFD_PAGE_KNOB_DEC', "Step down through the individual pages.", "Shared Cockpit"),
12241224
]
1225-
# G1000_MFD_SOFTKEY1, G1000_MFD_SOFTKEY12 Initiate the action for the icon displayed in the softkey position. Shared Cockpit
1225+
# G1000_MFD_SOFTKEY1, G1000_MFD_SOFTKEY12 Initiate the action for the icon displayed in the softkey position. Shared Cockpit

SimConnect/SimConnect.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import threading
1010
import asyncio
1111

12-
_library_path = os.path.abspath(__file__).replace(".py", ".dll")
12+
_library_path = os.path.splitext(os.path.abspath(__file__))[0] + '.dll'
1313

1414
LOGGER = logging.getLogger(__name__)
1515

@@ -436,3 +436,16 @@ def flight_to_dic(self, fpath):
436436
temp = line.split("=")
437437
dic[index][temp[0]] = temp[1].strip()
438438
return dic
439+
440+
def sendText(self, text, timeSeconds=5, TEXT_TYPE=SIMCONNECT_TEXT_TYPE.SIMCONNECT_TEXT_TYPE_PRINT_WHITE):
441+
pyarr = bytearray(text.encode())
442+
dataarray = (ctypes.c_char * len(pyarr))(*pyarr)
443+
pObjData = cast(dataarray, c_void_p)
444+
self.dll.Text(
445+
self.hSimConnect,
446+
TEXT_TYPE,
447+
timeSeconds,
448+
0,
449+
sizeof(ctypes.c_double) * len(pyarr),
450+
pObjData
451+
)

SimConnect/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def int_or_str(value):
1111
return value
1212

1313

14-
__version__ = "0.4.18"
14+
__version__ = "0.4.21"
1515
VERSION = tuple(map(int_or_str, __version__.split(".")))
1616

1717
__all__ = ["SimConnect", "Request", "Event", "millis", "DWORD", "AircraftRequests", "AircraftEvents", "FacilitiesRequests"]

0 commit comments

Comments
 (0)