RCM2200, serial reading problem

Hello,

I am trying to read characters (via RS-485 using a MAX1487 or a LMS1487 transceiver) through the serial port D (pin 3) of a RabbitCore RCM2200, using Dynamic C 7.21 TSE. Data sent are strings of 64 characters ending with . My problem is that I get the wrong characters: I should get “$GPGLL” (0x24 0x47 0x50 0x47 0x4C 0x4C) and I get: 0x6e 0x71 0x5F 0x71 0x67.

I have really tried a lot a different ways to do it (other RCM2200 card, different dynamic C functions, …) and I always get the right amount of characters but with wrong ASCII codes. Hardware has also been checked and PD3 gets a correct signal.

Below are some key parts of my code. Has anybody any idea of what could be wrong ?

in main():

...
while(1) 
{
    ...
    costate { wfd serial_com(); }
    ...
}

serial function:

cofunc serial_com()
{
     int n;
     char *pBuffer = NULL;

#GLOBAL_INIT
{
     BitWrPortI(PDFR, &PDFRShadow, 0, 3);    // Set PD3 to be a normal I/O pin
     BitWrPortI(PDDCR, &PDDCRShadow, 0, 3);  // Set PD3 to drive high or low
     BitWrPortI(PDDDR, &PDDDRShadow, 1, 3); // Set PD3 to be an Output

     // Set port D bit 3 low - Disable 485 transmissions, put in receive mode
     BitWrPortI(PDDR, &PDDRShadow, 0, 3);
}

     serDopen(4800);     // Open serial port
     serDdatabits(PARAM_8BIT);
     serDparity(PARAM_NOPARITY);

     while(1) // forever
     {
           wfd{ n = cof_serGets(pBuffer, 85, 3000UL); }

           if(n && pBuffer[0] != '\0') // If bytes received
           {

                 send_debug(pBuffer); // sends the string through TCP/IP
           }
           else
                yield; // No data so give way for other processes
      }

      serDclose();     // Close serial port
}

Try declaring as:

unsigned char pBuffer