5 years, 11 months ago.

Serial interrupt skips some data while reading from GPRS modem?

Hi everyone, i want to read some data from server through gprs modem. I dont know why the modem not reading the data .... I have used serial interrupt function to read the data.. My actual data is hex value (30 12 00 08 70 72 6f 74 6f 63 6f 6c 6668 66 68) but it reads only first three values alone ie till (30 12 00) after that it is not reading . Please give me a solution for this...


code: void callback_rx() { if (SIM900.readable()) { receive_buffer[ptr++] = SIM900.getc(); myled=1; } else { myled=0; } }

declared variables as volatile datatype as well as global.

1 Answer

5 years, 11 months ago.

Try changing if (SIM900.readable()) to while (SIM900.readable())

Assuming your code isn't doing anything else at the same time this shouldn't be an issue but if you're in an interrupt when the data arrives it's possible that there are two bytes waiting. If you only read the first byte then you won't get an interrupt for the second one.

Also rather than posting a screen shot of the code use <<code>> and <</code>> (each on it's own line) to format code neatly.

ya i have checked , but the same problem exists....what to do now..?

posted by Pradeepkumar K 10 Jun 2015

Could you please post any example program for this issue.....? It will help me to understand...

posted by Pradeepkumar K 10 Jun 2015

Is your buffer larger than 3 characters? How are you reading the characters? Have you tested replacing the SIM900 read inputs with a static buffer input to make sure the rest of your code operates as expected?

posted by Elijah P 10 Jun 2015

Sorry ,(30 0d 00 08 70 72 6f 74 6f 63 6f 6c 79 79 79 ) this is my data which is sent from server to gprs modem . The problem is serial interrupt function reads only (30 od ) omitting rest of the characters. i send some other data i reads correctly i dont know where the problem is .... Help me !.....

posted by Pradeepkumar K 11 Jun 2015

can anyone help me... about this issue...

posted by Pradeepkumar K 12 Jun 2015

The serial port interrupts work so it's probably a bug in your code somewhere. It's not possible to debug software that you can't see.

We can't help you if you don't post your code.

posted by Andy A 12 Jun 2015