95b95b95boverview, 96b96b96bsample code, Overview sample code – Moog Crossbow NAV440 Series User Manual

Page 109: Appendix d, Sample packet decoding, Table 104 code functions, Appendix c. sample packet— parser code, D on the final value, Overview, Appendix c. sample packet—parser code

Advertising
background image

 

 

 

 

 

NAV440 User Manual 

7430‐0131‐01 Rev. F 

Page 109

 
 

Appendix C.  Sample Packet—Parser Code 

Overview 

This section includes an example of code written in ANSI C for parsing packets from data sent by the  440 Series 
Inertial Systems. This example is for reading data directly from the  440 Series unit or from a log file.  

Sample Code 

The sample code contains the actual parser as well as several support functions for CRC calculation and circular 
queue access. 

Table 104  Code Functions 

Function 

Description 

process_xbow_packet 

Parse out packets from a qu
XBOW_PACKET (see below

eue. Returns these fields in structure 

). Checks for CRC errors 

calcCRC 

Calculate CRC on packets.  

Initialize 

Initialize the queue 

AddQueue 

Add item in front of queue 

DeleteQueue 

Return an item from the queue 

peekWord 

Retrieve 2‐bytes from the queue, without popping 

peekByte 

Retrieve a byte from the queue without popping 

Pop 

Discard item(s) from queue 

Size 

Return number of items in queue 

Empty 

Return 1 if queue is empty, 0 if not 

Full 

Return 1 if full, 0 if not full 

 
The parser will parse the queue looking for packets. Once a packet is found and the CRC checks out, the packet’s 

fields are placed in the XBOW_PACKET structure. The parser will then return to the caller. When no packets are 

 return value 0.  

found the parser will simply return to the caller with
The XBOW_PACKET structure is defined as follows: 

typedef struct xbow_packet

{

unsigned

short

packet_type;

char

length;

unsigned

short

crc;

char

data(256);

} XBOW_PACKET;

 
Typically, the parser would be called within a loop in a separate process, or in some time triggered environment, 
reading the queue looking for packets. A separate process might add data to this queue when it arrives. It is up to the 

Advertising