Receving String correctly on RS232

Hi,

i’m making a software with an RCM3700 module to communicate with a GPRS modem using AT commands.

I’ve experiencing some problems during receiving.
Sending a request for inserting PIN i’m sending:

“AT+CPIN=7159\x0d\x0a” the modem is doing what expected but i cannot parse the response.

The supposed response is: “0\r” the first time a send the command and “4\r” next times (because the pin is already given)

Unfortunately the response I receive is different every time I send the command. Sometimes “null” other times “šÃšÃ” rarely the correct answer

serDopen(115200);
serDflowcontrolOff();
serDwrite(“AT+CPIN=XXXX\x0d\x0a”,15);
serDread(buffer,80,2000)

the last two lines are in a costate it shouldn’t be a problem I think…

anyone has any advice

Have you tried sending just the command characters? You are specifying 15 characters instead of 14, and the null at the end might be confusing the modem.