By LEPINE Jean-philippe 956874
#519568 Hello,

I wrote a Java application which already set P3D frequencies and XPNDR code from an external simulator data. I would like to set transponder mode and ident but it seems I need to send those commands directly to vPilot (they are not implemented in P3D). My add-on already has communication with SimConnect.

I saw on vPilot documentation plugins sytem, but they only seem to be accessible for C/C#/C++ applications. My question is : is there a way for my application to send those events to vPilot using SimConnect or something else ?

Thank you in advance
Best regards
Jean-phuilippe
By Ross Carlson 887155
#519580 Transponder mode and ident can be set via either FSUIPC using the Squawkbox offsets, or via SimConnect using the Squawkbox client data area. vPilot reads the Squawkbox client data area via SimConnect in order to set transponder mode and trigger ident. If you use FSUIPC to set the Squawkbox offsets, FSUIPC will automatically copy the values to the Squawkbox client data area, so you can use either method and it will work with vPilot.

Let me know if you need details on the byte layout of the FSUIPC offsets or the Squawkbox client data area.
By LEPINE Jean-philippe 956874
#519583 Hi Ross,

Thank you very much. My application has access to SimConnect, not to FSUIPC. Unfortunately, I don't know anything about Squawkbox client data area, and how to interract with it though SimConnect commands. If you could detail it for me, and give me a small example, it would be very kind.

Thank you very much
Best regards
Jean-philippe
By Ross Carlson 887155
#519585 Here's the code that vPilot uses to create the Squawkbox client data area, map data definitions to specific offsets within the data area, and request that SimConnect send events when those values change:

Code: Select all      private void ConfigureSquawkBoxClientDataAccess()
      {
         mSimConnect.MapClientDataNameToID("SquawkBox Data", ClientData.SquawkBox);
         mSimConnect.CreateClientData(ClientData.SquawkBox, 128, SIMCONNECT_CREATE_CLIENT_DATA_FLAG.DEFAULT);
         mSimConnect.AddToClientDataDefinition(DataDefinitions.SquawkBoxRunning, 0, 1, 0.0f, 0);
         mSimConnect.AddToClientDataDefinition(DataDefinitions.SquawkBoxConnected, 1, 1, 0.0f, 0);
         mSimConnect.AddToClientDataDefinition(DataDefinitions.SquawkBoxTransponderMode, 17, 1, 0.0f, 0);
         mSimConnect.AddToClientDataDefinition(DataDefinitions.SquawkBoxTransponderIdent, 19, 1, 0.0f, 0);
         mSimConnect.RequestClientData(ClientData.SquawkBox, DataRequests.SquawkBoxTransponderMode, DataDefinitions.SquawkBoxTransponderMode, SIMCONNECT_CLIENT_DATA_PERIOD.ON_SET, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG.CHANGED, 0, 0, 0);
         mSimConnect.RequestClientData(ClientData.SquawkBox, DataRequests.SquawkBoxTransponderIdent, DataDefinitions.SquawkBoxTransponderIdent, SIMCONNECT_CLIENT_DATA_PERIOD.ON_SET, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG.CHANGED, 0, 0, 0);
         mSimConnect.SetClientData(ClientData.SquawkBox, DataDefinitions.SquawkBoxRunning, SIMCONNECT_CLIENT_DATA_SET_FLAG.DEFAULT, 0, (byte)1);
      }

The last line there shows how vPilot sets the SquawkBoxRunning byte (offset 0) to 1 to indicate that Squawkbox is now running. (Even though it's vPilot, not squawkbox.) I later set the SquawkBoxConnected value (offset 1) to 1 or 0 when the user connects or disconnects to/from the network.

Note that your code would not create the client data area ... only the pilot client (vPilot, in this case) should do that. You would do all the above *except* CreateClientData().

To indicate that the user is squawking mode C:

Code: Select allmSimConnect.SetClientData(ClientData.SquawkBox, DataDefinitions.SquawkBoxTransponderMode, SIMCONNECT_CLIENT_DATA_SET_FLAG.DEFAULT, 0, (byte)0);

(Yes, a value of zero means mode C is on, and a value of 1 means the transponder is in standby.)

To indicate that the user is squawking ident:

Code: Select allmSimConnect.SetClientData(ClientData.SquawkBox, DataDefinitions.SquawkBoxTransponderIdent, SIMCONNECT_CLIENT_DATA_SET_FLAG.DEFAULT, 0, (byte)1);

vPilot will automatically set the ident value back to 0 when it sees it change to a 1.
By LEPINE Jean-philippe 956874
#519598 Hi Ross,

I implemented today. I have the mode C / STDBY toggle working perfectly. However, the IDENT doesn't work (I don't get button turning to green in vPilot GUI). My Java SimConnect client uses custom commands, but if it works for MODE, why it shouldn't work for IDENT ? Below is a sample of my code, only to show you I don't do anything different for MODE and IDENT. Do you have an idea ?

Code: Select allargSc.mapClientDataNameToID("SquawkBox Data", CLIENT_DATA_SQUAWKBOX);
argSc.addToClientDataDefinition(SQUAWKBOX_TRANSPONDER_MODE, 17, 1, 0.0f, 0);
argSc.addToClientDataDefinition(SQUAWKBOX_TRANSPONDER_IDENT, 19, 1, 0.0f, 0);

/**
* Set vPilot transponder mode.
* @param argMode 0 = mode C,  1 = STDBY (int32).
 * @throws IOException
*/
public static void setXpndrMode(int argMode) throws IOException
{
   byte[] data = {0};
   data[0] = (byte)argMode;
      
   sc.setClientData(CLIENT_DATA_SQUAWKBOX, SQUAWKBOX_TRANSPONDER_MODE, data);
}
   
   
/**
 * Toggle vPilot transponder IDENT.
 * @throws IOException
 */
public static void toggleXpndrIdent() throws IOException
{
   byte[] data = {0};      
   data[0] = (byte)1;
      
   sc.setClientData(CLIENT_DATA_SQUAWKBOX, SQUAWKBOX_TRANSPONDER_IDENT, data);
}   


Best regards,
Jean-philippe
By Ross Carlson 887155
#519600 Were you connected to the network at the time you tested? vPilot will only squawk ident if you're connected. You must also be squawking mode C for ident to work.

In any case, vPilot should be toggling the byte back to zero as soon as it sees it change to a one.
By LEPINE Jean-philippe 956874
#519602 Hello Ross,

I ran a new test, connected and on mode C... it is working perfectly. Thank you so much for your kind help. Sorry I am not an active vPilot user, that's why I didn't know I needed to be connected and on C mode to IDENT. I implement this function mostly for other users of my application, I need to take all use cases into account.

Thanks again for the great and quick support.
Cheers !
Jean-philippe
By LEPINE Jean-philippe 956874
#519612 It is a bridge between Aerowinx PSX and P3D. It is not released yet (Beta test phase now). It uses P3D as a scenery generator to display aircraft environment which is missing in PSX (only a very basic scenery is implemented). The position data is updated at 72Hz and sent to P3D. I also send PSX frequencies and transponder data to P3D and vPilot (mode C and IDENT).

Best regards,
Jean-philippe
By Ross Carlson 887155
#519613 Ahh, very nice. I've considered using PSX for my sim a few times in the past, but I ended up going with ProSim 737 mainly due to the wide variety of hardware options for the 737.