Queue losing data

I am having a problem with a Queue losing the first item stored in it. I am using version 5.4.2 with the dsPIC port. Here is a basic description of my setup. I have a sensor that is transmitting 4304 bytes of data every 5 seconds over a RS-232 port at 57.6k. I have a task that calls SerGetc() to pull a byte from the queue. The byte is then placed in an array. When the array is full I would normally do some analysis.
The first 4304 bytes that are sent are stored correctly and the data looks good. Every data transfer after that is always missing the first byte of data. I have verified that the data is coming over the serial port and is being picked up by the RX ISR. For some reason it is being lost in the queue. Any thoughts? I am out of ideas.
Here is the relevant code:    
// This is how I am creating the task and the Queue. They are pulled from my MAIN
xTaskCreate(vSerial_StoreData,( signed portCHAR * )”store data”, 1000, NULL, 1, NULL); // Create the task
xSerialDataIn_1_Queue = xQueueCreate(1000, sizeof(int8)); // Create a receiver Queue for serial 1 // Serial pot 1 receive ISR
void __attribute__((__interrupt__, auto_psv)) _U1RXInterrupt(void)
{
static uint8 newCh = 0;
static uint8 init = 0;
static uint8 output = 0;
static uint16 index = 0;
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
static portBASE_TYPE result_send;
static portBASE_TYPE result_peek; IFS0bits.U1RXIF = 0; // Clear the interupt flag while( U1STAbits.URXDA == 1 )
{
newCh = U1RXREG;
result_send = xQueueSendToBackFromISR( xSerialDataIn_1_Queue, &newCh, &xHigherPriorityTaskWoken );
} if( xHigherPriorityTaskWoken != pdFALSE )
{
taskYIELD();
}
} // Gets a single char from Serial port 1. The function will wait, and yield, until a char is available
void Ser1RxGetc(int8 *pc)
{
int8 data = 0; while (xQueueReceive(xSerialDataIn_1_Queue, &data, 0) == errQUEUE_EMPTY)
taskYIELD(); *pc = data;
} void vSerial_StoreData (void *pvParameters)
{
uint8 data = 0; // Current data byte
uint16 index = 0; // Byte number received
uint16 count = 0;
uint16 result = 0; while (1)
{ Ser1RxGetc((int8*)&data); // Grab the data
dataRead = data; // Store the data if (index < 4304)
{
index++; // Increment the counter
} else
{
index = 0; // I place break points at thses locations to look at the data
if (count == 0)
result ++;
if (count == 1)
result ++;
if (count == 2)
result ++; count++;
memset(&dataRead, 0x00, sizeof(dataRead)); // Clear the read buffer
}
}
}

Queue losing data

A couple of comments. I don’t understand what the memset is doing. Is it supposed to be clearing the whole array each time a char is received? Your code is polling xSerialDataIn_1_Queue and yielding when it has no data. Why not just block on the queue? If you know how many chars are coming then it would be more efficient to simply place the chars in the array in the interrupt, then use a semaphore to unblock a task to process the array.

Queue losing data

Thanks for your comments.
The code I provided is just some test code to try to find this problem. The memset clears the data array after the 4304 characters have been received to get it ready for the next batch of data. Originally I was blocking on the queue. I tried it this way just to see if it would fix the problem…it didn’t. Both methods had the same problem. It would be more efficient to just store the data in an array but this is just a small portion of the entire system. Other portions of the system dictate I do it this way. Keith