Jump to content

User Defined CIGI Packet


photo

Recommended Posts

My host machine has a custom CIGI or IG packet as per the CIGI 3.3 'user-defined packets' documentation.  My packet will be used to pass information from the HOST to drive an avionics display rendered with Unigine.  The packet sends floats for the following variables: 

  • true airspeed
  • indicated airspeed
  • vertical speed
  • xlocation
  • ylocation
  • zlocation
  • radar_altimeter height
  • barometric altimeter height
  • pitch rate
  • roll rate
  • yaw rate
  • pitch attitude
  • roll attitude
  • heading
  • body velocity x
  • body velocity y
  • body velocity z
  • body acceleration y

Is there a way to read user defined packets with either the CIGI or IG protocols?

Link to comment

Currently, CIGIConnector does not support user-defined packages.

This will be fixed in the next release in accordance with the CIGI specification.

Link to comment
  • 1 month later...

I see that this feature has been added to 2.8 but I haven't seen any info on it in the documentation.  Could you please point me in the right direction?  Thanks.

Link to comment

Hi Robert,

Just like with all other types of packets, to receive user-defined ones, we should add a callback for CIGI_OPCODE >= 201 (in accordance with CIGI ICD)
on receiving such packet the callback shall be executed with ICigiHostUserDefined * packet passed to it.
The ICigiHostUserDefined class has the getData() method, which returns a set of bytes to be read and interpreted by the user (depending on what was written to the packet on the host).

The same situation is with sending packets. First we ask the CIGIConnector to create a packet with a certain CIGI_OPCODE, if it is equal to 201 or greater an ICigiIGUserDefined instance shall be returned. You can set bytes to be sent by calling the ICigiIGUserDefined::setData() method.

It should be noted, that bytes are read and written starting from the second byte (not form the 4th). If you want to align bytes starting from the 4th one, you should add a couple of bytes in the beginning. The CIGI ICD recommends to start reading/writing bytes starting from the 4th one (see Data before the Data Block 1 shown in the images attached), although it is mentioned, that it is possible to start from the 2nd.

Below is an example of working with user-defined packets: (pseudocode, not for compilation):

int AppWorldLogic::init()
{
	// ....

	int index = Engine::get()->findPlugin("CIGIConnector");
	// check CIGIConnector plugin load
	if (index != -1)
	{

		// getting the CIGI interface
		cigi = (IG::CIGI::ConnectorInterface*)Engine::get()->getPluginData(index);
               // adding a calback for OPCODE = 202
		cigi->setReceivePacketCallback(202, MakeCallback(this, &AppWorldLogic::on_recv_user_packet));
	}
	return 1;
}

// ....

void AppWorldLogic::on_recv_user_packet(IG::CIGI::ICigiHostUserDefined * packet)
{
	Log::error("AppWorldLogic::on_recv_user_packet\n");
	unsigned char * request_data = packet->getData();  // read
	// ... 
        // creating a new IG user packet with opcode 203
	ICigiIGPacket * response_packet = cigi->createIGPacket(203);
	ICigiIGUserDefined * user_defined = dynamic_cast<ICigiIGUserDefined *>(response_packet);

	user_defined->setData(response_data, size_of_data); // write
	cigi->addIGPacket(response_packet);
}

Hope this helps.

We'll update documentation as soon as possible, sorry for the inconvenience caused!

Thank you!

userpacket1.png

userpacket2.png

  • Like 1
Link to comment
×
×
  • Create New...