I have a partially working CSharp wrapper that seems to be communicating with MSFS2020 via SimConnect failry well. I am however, running into some issues with a few of the SimVars and was hoping someone could help me out. Specifically, I am unable to get the following values from SimConnect that I would like to:
[The current % setting of the throttle handle]
I cannot figure out what is the proper value for the SimVar name. I am currently using "GENERAL ENG THROTTLE LEVER POSITION:index", but that doesn't appear to be working. Is the ":index" meant to represent something like "
index of the engine)"? So, in a twin engine plane I would do "GENERAL ENG THROTTLE LEVER POSITION:1" for the second engine? I'm able to parse the "FLAPS HANDLE PERCENT" SimVar, so if I can just get the throttle data to come across, I should be able to handle it.
[ATC information, such as ATC ID, ATC TYPE etc]
I have had no luck capturing ANY string information. I've tried every variation of STRING8, STRING32, STRING54, STRING128, STRING256, STRINGV to get the proper data on string types. I am also not sure what should be passed as the unit when getting strings. I've seen "null" passed elsewhere for unit type on string values, but still have had no success. For strings, I need help ensuring that I'm using the proper SimVar names, as well as DataTypes, and also that my data struct has been properly defined.
I have built a polling request system like you see present in the SDK samples. I am going to include some code snippets so you may be able to help me diagnose the issue. Long story short, I need to make sure that I'm registering my calls via SimConnect.AddToDataDefinition() correctly and that my struct has the fields defined properly, because that is likely where the issue is.
Here is my return data STRUCT that should contain the requested data from SimConnect:
Here are the calls to register my request:
I am getting exceptions number 7 & 3 from the SimConnect library when trying to get these string values.
Can anyone provide some direction?
P.S. I'll be happy to post my working WinForms & WPF implementation if anyone would like to see it.
[The current % setting of the throttle handle]
I cannot figure out what is the proper value for the SimVar name. I am currently using "GENERAL ENG THROTTLE LEVER POSITION:index", but that doesn't appear to be working. Is the ":index" meant to represent something like "
[ATC information, such as ATC ID, ATC TYPE etc]
I have had no luck capturing ANY string information. I've tried every variation of STRING8, STRING32, STRING54, STRING128, STRING256, STRINGV to get the proper data on string types. I am also not sure what should be passed as the unit when getting strings. I've seen "null" passed elsewhere for unit type on string values, but still have had no success. For strings, I need help ensuring that I'm using the proper SimVar names, as well as DataTypes, and also that my data struct has been properly defined.
I have built a polling request system like you see present in the SDK samples. I am going to include some code snippets so you may be able to help me diagnose the issue. Long story short, I need to make sure that I'm registering my calls via SimConnect.AddToDataDefinition() correctly and that my struct has the fields defined properly, because that is likely where the issue is.
Here is my return data STRUCT that should contain the requested data from SimConnect:
C#:
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ATCInfo
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public string Type_Name;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
public string Tail_Number;
}
Here are the calls to register my request:
C#:
*this is correct *?? *?? *??
simConnector.AddToDataDefinition(DEFINITIONS.ATCInfo, "ATC TYPE", null, SIMCONNECT_DATATYPE.STRING64, 0, SimConnect.SIMCONNECT_UNUSED);
simConnector.AddToDataDefinition(DEFINITIONS.ATCInfo, "ATC FLIGHT NUMBER", null, SIMCONNECT_DATATYPE.STRING8, 0, SimConnect.SIMCONNECT_UNUSED);
simConnector.RegisterDataDefineStruct<ATCInfo>(DEFINITIONS.ATCInfo);
I am getting exceptions number 7 & 3 from the SimConnect library when trying to get these string values.
Can anyone provide some direction?
P.S. I'll be happy to post my working WinForms & WPF implementation if anyone would like to see it.
Last edited: