Go Down

Topic: Arduino + GM862 GPS + SoftwareSerial (Read 1 time) previous topic - next topic

kenterfie

I try to control a GM862-GSM/GPS Modul with AT commands over a SoftwareSerial connection. The transmit of commands works great and every action is running successfully, but the rx data is strange, and i dont know why.

On every call i get some wasted bytes on the front of the data stream and also the size of data is variant. What i don't understand is, that the paket includes the right anwser in the end of the message, but also the wasted data in front of them. I havn't found something about this behavior. Is this problem known by someone or is it perhaps a familiar issue of the SoftwareSerial implementation?

It would be great, it has someone a tip for me to fix the problem or makes it possible to understand the problem himself.

Thanks
Stefan Reusch

Small log of hardware serial port debug output
Code: [Select]
Port open
GM862 monitor
AT
10 ->buf: AT
OK

already on
checking network ...
AT+CREG?
30 ->buf: AT+CREG?
+CREG: 0,1

OK

done
checking network ...
AT+CREG?
30 ->buf: ?T+CREG?
+CREG: 0,1

OK

done
checking network ...
AT+CREG?
30 ->buf: ?T+CREG?
+CREG: 0,1

OK

done
checking network ...
AT+CREG?
30 ->buf: E?4J???j?
+CREG: 0,1

OK

done
checking network ...
AT+CREG?
30 ->buf: ??I??
+CREG: 0,1

OK

done
checking network ...
AT+CREG?
30 ->buf: AT+CREG?
+CREG: 0,1

OK

done
checking network ...
AT+CREG?
29 ->buf: Q?*u??
+CREG: 0,1

OK

done
checking network ...
AT+CREG?
30 ->buf: AT+CREG?
+CREG: 0,1

OK

done
checking network ...
AT+CREG?
29 ->buf: ?jiJU??
+CREG: 0,1

OK

done
checking network ...
AT+CREG?
30 ->buf: ?T+CREG?
+CREG: 0,1

OK

done
checking network ...


el_supremo

The log is fascinating but essentially useless without your code.

Pete

liudr

and, we don't know what should be happening, just what is happening so provide code and expected result with actual result. I want to know your baud rate but I can wait, just hand over the code hehe. ]:)

kenterfie

#3
Jan 12, 2012, 10:45 pm Last Edit: Jan 12, 2012, 10:48 pm by kenterfie Reason: 1
i use a baud rate of 9600 between gsm modul and arduino.

i have reused some of the code from http://tinkerlog.com/2009/05/15/interfacing-arduino-with-a-telit-gm862/ and updated some parts of it to work with arduino 1.0.
the receive loop looks like this at the moment. its was not modified by me, but i think it is not the reason for the currupt data, which is returned.

the function looks like at the moment
Code: [Select]

byte GM862::getsTimeout(char *buf, uint16_t timeout) {
byte count = 0;
long timeIsOut = 0;
char c;
bool found = false;
memset(buf, 0, BUF_LENGTH);
timeIsOut = millis() + timeout;
while (timeIsOut > millis() && count < (BUF_LENGTH - 1)) {  
if (modem->available() && !modem->overflow()) {
c = modem->read();
count++;
*buf++ = c;
timeIsOut = millis() + timeout;
}
}
if (count != 0) {
*buf = 0;
count++;
}
return count;
}


then the normal parts to initialize the soft serial port and set baud rate of 9200.

Code: [Select]

pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
modem = modemPort;
modem->begin(9600);


after this some AT commands are transmitted, but it is irrelevant, because the transmit data is ever called by the modul, which is visible on the returned data. one thing, would be possible is, that this are binary debug information, but i cant find something about this in the docs.

el_supremo

Quote
the receive loop looks like this at the moment. its was not modified by me, but i think it is not the reason for the bad data

You post a piece of code that you say you haven't modified and which you think is working. Absolutely brilliant.

Pete



kenterfie

I mean, that this function would work correct, when the softserial class of arduino would return the right data. I have no device to monitor the output/delays at the moment to verify the received data. I think the problem is related to the softserial class or to the gsm modul. What i try at the moment is to vary the delay timings, but this has nothing changed until now. Sorry, when i do something wrong, but it is my first arduino project and if something missing or not meaningful enough, then i try to post more info about the problem.

kenterfie

Ok, i have found now, that 38400 are suggested, after a short try the returned data looks good, but i cant believe this was the reason for it.

liudr

Where did you find the recommended speed being 38400? I was never able to use that fast speed.

el_supremo

The link at tinkerlog.com that OP posted uses 19k2 so I'd be interested to know where/who recommends 38k4.
I also can't believe that using 38k4 fixed the problem.

Pete

Go Up