Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 5 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...
/media/uploads/Pradeepkumark/dia.bmp
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
9 years, 5 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.
Could you please post any example program for this issue.....? It will help me to understand...
posted by 10 Jun 2015Is 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 10 Jun 2015Sorry ,(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 11 Jun 2015