odwdinc / Python-SimConnect

Python interface for MSFS2020 SimConnect.dll

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New Sim Variable in latest doc posting = COM SPACING MODE

FS2020-USER-TESTER opened this issue · comments

In the document posted with the recent SDK update,
https://docs.flightsimulator.com/html/Programming_Tools/SimVars/Aircraft_Simulation_Variables.htm

I noticed a new variable
COM SPACING MODE | Com [index] Radio Frequency step: | Enum:0 = 25kHz1 = 8.33kHz
Default was 1.0 which matched the behavior of the COM knob.
I tried adding into the variable list using several different data types.
Consistently get SIMCONNECT_EXCEPTION_DATA_ERROR on set.
Somehow I got variable set to 0.0 for several flights, but today I cannot reproduce that success using same code.
Stuck Back to 1.0

Can you try to add?

The problem seem to be with the Enum data type, python has a bit of a hard time with this type.

I seem to be able to read with

sm = SimConnect()
pl = Request((b"COM SPACING MODE:0", b"Enum"), sm)
print("com", pl.value)

one should be able to use

sm = SimConnect()
pl = Request((b"COM SPACING MODE:0", b"Enum"), sm, _settable=True)
print("com", pl.value)
pl.value = 1 // or 0

SIMCONNECT_EXCEPTION_DATA_ERROR seems to suggest that the data passed to the event is not of the right format.
this is where I'm lost as well.

Attempting to pass as pointer to array of ctypes.c_double as normal and as pointer to ctypes.c_double showed no improvements.
changing the data type form SIMCONNECT_DATATYPE.SIMCONNECT_DATATYPE_FLOAT64 to all others in

# Data data types
class SIMCONNECT_DATATYPE(CtypesEnum):
SIMCONNECT_DATATYPE_INVALID = 0 # invalid data type
SIMCONNECT_DATATYPE_INT32 = 1 # 32-bit integer number
SIMCONNECT_DATATYPE_INT64 = 2 # 64-bit integer number
SIMCONNECT_DATATYPE_FLOAT32 = 3 # 32-bit floating-point number (float)
SIMCONNECT_DATATYPE_FLOAT64 = 4 # 64-bit floating-point number (double)
SIMCONNECT_DATATYPE_STRING8 = 5 # 8-byte string
SIMCONNECT_DATATYPE_STRING32 = 6 # 32-byte string
SIMCONNECT_DATATYPE_STRING64 = 7 # 64-byte string
SIMCONNECT_DATATYPE_STRING128 = 8 # 128-byte string
SIMCONNECT_DATATYPE_STRING256 = 9 # 256-byte string
SIMCONNECT_DATATYPE_STRING260 = 10 # 260-byte string
SIMCONNECT_DATATYPE_STRINGV = 11 # variable-length string
SIMCONNECT_DATATYPE_INITPOSITION = 12 # see SIMCONNECT_DATA_INITPOSITION
SIMCONNECT_DATATYPE_MARKERSTATE = 13 # see SIMCONNECT_DATA_MARKERSTATE
SIMCONNECT_DATATYPE_WAYPOINT = 14 # see SIMCONNECT_DATA_WAYPOINT
SIMCONNECT_DATATYPE_LATLONALT = 15 # see SIMCONNECT_DATA_LATLONALT
SIMCONNECT_DATATYPE_XYZ = 16 # see SIMCONNECT_DATA_XYZ
SIMCONNECT_DATATYPE_MAX = 17 # enum limit

Did not change the message.
mismatching data types did change the message.

Attempting to change b"Enum" did not result in any changes.

I tried a C# program but did not find reliable set data operation for this spacing variable. So appears not Python problem.
What I see testing here - the C152 and the C172 mostly start up with COM SPACING MODE = 1 and the knob works consistent with that. Occasionally they start up with COM SPACING MODE = 0 and the knob works consistent with that. I do not see a pattern as to what it picks to start. The call to SetDataOnSimObject always generates an exception.

Initially the random startup convinced me I was somehow setting the variable via SimConnect but I no longer believe that.
Now I think it is just FS2020 bug.

This mod https://github.com/JPLogistics/MSFS_C152 fixes the C152 COM spacing to 25mHz.
(And has odd side effect to setting the C172 spacing to 25 mHz if plane selected in same session.)
This mod https://github.com/Working-Title-MSFS-Mods/fspackages/releases/tag/g1000-v0.3.4 fixes the G1000 to have a AUX menu available to select the frequency spacing.

So simulation user has a path to select correct spacing but not through SimConnect.