<Packet name="KlvUserData" ID="ORION_PKT_KLV_USER_DATA" parameterInterface="true" comment="This packet is used to set and query the values of user-configurable KLV tags">
<Data name="Key" inMemoryType="unsigned8" comment="UAS Local Set key" />
<Data name="SubKey" inMemoryType="unsigned8" comment="UAS Local Set sub-key, if applicable (e.g., security metadata)"/>
<Data name="Value" inMemoryType="signed8" array="128" encodedType="string" default="0" comment="Variable-length value string"/>
</Packet>
ProtoGen creates a decode function that looks like this:
int decodeKlvUserDataPacket(const void* pkt, uint8_t* Key, uint8_t* SubKey, char Value[128])
{
int byteindex = 0;
const uint8_t* data = getOrionPublicPacketDataConst(pkt);
int numBytes = getOrionPublicPacketSize(pkt);
if(getOrionPublicPacketID(pkt) != getKlvUserDataPacketID())
return 0;
if(numBytes < getKlvUserDataMinDataLength())
return 0;
// this packet has default fields, make sure they are set
for(i = 0; i < 128; i++)
Value[i] = 0;
// UAS Local Set key
*Key = (uint8_t)uint8FromBytes(data, &byteindex);
// UAS Local Set sub-key, if applicable (e.g., security metadata)
*SubKey = (uint8_t)uint8FromBytes(data, &byteindex);
// Variable-length value string
stringFromBytes(Value, data, &byteindex, 128, 0);
return 1;
}
Given the following input:
ProtoGen creates a decode function that looks like this:
Which fails to compile because
i
is not defined.