Issues with ATC strings in managed code

Discuss on the SimConnect SDK can be used by programmers to write add-on components for Prepar3D
Locked
obinder
Posts: 145
Joined: Sun Jun 08, 2014 9:43 am

Issues with ATC strings in managed code

Post by obinder »

Hi @ll,

one of my apps is handling AI traffic. I am encountering a strange problem in V4 - it looks like the ATC strings are no longer properly terminated.

Edit: This only happens when I set those data fields myself with "SetDataOnSimObject"!

For example, an "ATC ID" set to <AITRAC> looks like <AITRACig> when I query it with "RequestDataOnSimObject" or "RequestDataOnSimObjectType". "ATC AIRLINE" is even worse, the strings blend over into each other.

Needless to say, this has been working as it should for over a year in all other simulator versions.
What am I doing wrong?
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct nameStruct
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public String atcId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public String atcAirline;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public String flightNumber;

};

simconnect.AddToDataDefinition(DEFINITIONS.ACNAME, "ATC ID", null, SIMCONNECT_DATATYPE.STRING256, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.ACNAME, "ATC AIRLINE", null, SIMCONNECT_DATATYPE.STRING256, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.ACNAME, "ATC FLIGHT NUMBER", null, SIMCONNECT_DATATYPE.STRING256, 0.0f, SimConnect.SIMCONNECT_UNUSED);

simconnect.RegisterDataDefineStruct<nameStruct>(DEFINITIONS.ACNAME);

MainDialog.nameStruct nameStr = new MainDialog.nameStruct();
nameStr.atcId = createdAi.nameId;
nameStr.atcAirline = createdAi.airline;
nameStr.flightNumber = createdAi.flightnumber;
simconnect.SetDataOnSimObject(MainDialog.DEFINITIONS.ACNAME, objectId, 0, nameStr);
Best regards
Oliver Binder
User avatar
Rob McCarthy
Lockheed Martin
Posts: 3703
Joined: Wed Aug 24, 2011 1:37 pm

Re: Issues with ATC strings in managed code

Post by Rob McCarthy »

Oliver,

Thanks for reporting this. We'll look into a fix for the next update.

Regards,
Rob McCarthy
Rob McCarthy
Prepar3D® Core Lead
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: Issues with ATC strings in managed code

Post by Clifton Crane »

Hi Oliver,

Thanks for the report. We were able to isolate the issue and it will be available in the next release.
Clifton Crane
Prepar3D® Software Engineer Sr.
Locked