Skip to content

Commit 68eb4c5

Browse files
MiMaKesPitj3
andauthored
Support String values (#19)
* Fix for #8 - Added new client data zone for string data - SimConnect now properly loads the string data from the var - Data is properly stored in the new data zone * Improved functionality of string SimVars * Increased string data area size to maximum * write SimVar when string-value has changed * added some debug output * fixed some compiler warnings * Separated handling for "regular" float SimVars and "new" string SimVars * Added AddString command to readme * Review changes: * Refactoring RegisterSimVar function into two separate functions. One for floats, one for strings * Removing first WriteSimVar function call when registering a simvar * Removing unused variables --------- Co-authored-by: Roderick Griffioen <[email protected]>
1 parent 9e5bb66 commit 68eb4c5

File tree

2 files changed

+221
-82
lines changed

2 files changed

+221
-82
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,27 @@ The default channels for the MobiFlight client are auto created on startup. Each
2121

2222
#### Communication protocol
2323

24-
| Command (string)| Responses (string) | LVars offset (float) |
24+
| Command (string)| Responses (string) | LVars value (float/string) |
2525
| ----------- | ----------- | ---------|
2626
| ```MF.Ping```| ```MF.Pong```|
2727
| ```MF.LVars.List``` | ```MF.LVars.List.Start``` <br> ```A32NX_AUTOPILOT_1_ACTIVE``` <br> ```A32NX_AUTOPILOT_HEADING_SELECTED``` <br> ```...``` <br> ```MF.LVars.List.End```|
28-
| ```MF.SimVars.Add.(A:GROUND ALTITUDE,Meters)``` || ```1455.23``` |
29-
|```MF.SimVars.Clear``` |||
30-
|```MF.SimVars.Set.5 (>L:MyVar)```|||
31-
|```MF.Clients.Add.ClientName```|```MF.Clients.Add.ClientName.Finished```||
32-
|```MF.Config.MAX_VARS_PER_FRAME.Set.30```|||
33-
|```MF.Version.Get```|```MF.Version.0.6.0```||
28+
| ```MF.SimVars.Add.(A:GROUND ALTITUDE,Meters)``` || ```e.g. 1455.23 (float)``` |
29+
| ```MF.SimVars.AddString.(A:GPS WP NEXT ID,String)``` || ```e.g. EDDS (string)``` |
30+
| ```MF.SimVars.Clear``` |||
31+
| ```MF.SimVars.Set.5 (>L:MyVar)```|||
32+
| ```MF.Clients.Add.ClientName```|```MF.Clients.Add.ClientName.Finished```||
33+
| ```MF.Config.MAX_VARS_PER_FRAME.Set.30```|||
34+
| ```MF.Version.Get```|```MF.Version.0.6.0```||
3435

3536

3637
**MF.SimVars.Add.**
37-
The "SimVars.Add." command needs to be extended with a gauge calculator scipt for reading a variable, like shown in the table. Each added variable needs 4 reserved bytes to return its float value in the LVars channel. The bytes are allocated in the order of the LVars being added. The first variable starts at offset 0, the second at offset 4, the third at offset 8 and so on. To access each value, the external SimConnect clients needs a unique DataDefinitionId for each memory segment. It is recommended to start with ID 1000.
38+
The "SimVars.Add." command needs to be extended with a gauge calculator script for reading a variable, like shown in the table. Each added variable needs 4 reserved bytes to return its float value in the LVars channel. The bytes are allocated in the order of the LVars being added. The first variable starts at offset 0, the second at offset 4, the third at offset 8 and so on. To access each value, the external SimConnect clients needs a unique DataDefinitionId for each memory segment. It is recommended to start with ID 1000.
3839

3940
![Lvars channels](doc/lvarsChannel.png)
4041

42+
**MF.SimVars.AddString.**
43+
The "SimVars.AddString." command works similar to the "SimVars.Add." command but the string result of the gauge calculator script is used. The size of a single string can be up to 128 bytes, which allows handling a total of 64 string variables. The first variable starts at offset 0, the second at offset 128, the third at offset 256 and so on. To access each value, the external SimConnect clients needs a unique DataDefinitionId for each memory segment. It is recommended to start with ID 10000.
44+
4145
**MF.Clients.Add.**
4246
The default channels are reserved for communication with the MobiFlight client. But they can be used to request additional channels for other SimConnect clients as well. If another client wants to use the WASM module for variable access, it can register itself with the command ```MF.Clients.Add.MyClientName``` using the default command channel. The WASM module then creates the new shared memory channels "MyClientName.LVars", "MyClientName.Command", "MyClientName.Response" and informs the client with ```MF.Clients.Add.ClientName.Finished```.
4347

0 commit comments

Comments
 (0)