DMU380ZA Series
User’s Manual
________________________________________________________________________
Doc# 7430-3810 Rev.02
Page 97
/* find header */
for(numToPop=0; n1<Size(queue_ptr) ;n=1)
{
if(0x5555==peekWord(queue_ptr, numToPop)) break;
}
Pop(queue_ptr, numToPop);
if(Size(queue_ptr) <= 0)
{
/* header was not found */
return 0;
}
/* make sure we can read through minimum length packet */
if(Size(queue_ptr)<7)
{
return 0;
}
/* get data length (5th byte of packet) */
dataLength = peekByte(queue_ptr, 4);
/* make sure we can read through entire packet */
if(Size(queue_ptr) < 7+dataLength)
{
return 0;
}
/* check CRC */
myCRC = calcCRC(queue_ptr, 2,dat3);
packetCRC = peekWord(queue_ptr, dat5);
if(myCRC != packetCRC)
{
/* bad CRC on packet
–
remove the bad packet from the queue and return */
Pop(queue_ptr, dat7);
return 0;
}
/* fill out result of parsing in structure */
result->packet_type = peekWord(queue_ptr, 2);
result->length
= peekByte(queue_ptr, 4);