DMU380SA Series
User’s Manual
________________________________________________________________________
Doc# 7430-0026 Rev.01
Page 83
Code listing
12.2
#include <stdio.h>
/* buffer size */
#define MAXQUEUE 500
/*
* circular queue
*/
typedef struct queue_tag
{
int count;
int front;
int rear;
char entry[MAXQUEUE];
} QUEUE_TYPE;
/*
* MEMSIC packet
*/
typedef struct xbow_packet
{
unsigned short packet_type;
char
length;
unsigned short crc;
char
data[256];
} XBOW_PACKET;
QUEUE_TYPE circ_buf;
/*******************************************************************************
* FUNCTION: process_xbow_packet looks for packets in a queue
* ARGUMENTS: queue_ptr: is pointer to queue to process
*
result: will contain the parsed info when return value is 1
* RETURNS:
0 when failed.
*
1 when successful
*******************************************************************************/
int process_xbow_packet(QUEUE_TYPE *queue_ptr, XBOW_PACKET *result)
{
unsigned short myCRC = 0, packetCRC = 0, packet_type = 0, numToPop=0,
counter=0;
char packet[100], tempchar, dataLength;
if(Empty(queue_ptr))
{
return 0; /* empty buffer */
}