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.
10 years, 1 month ago.
strange situetion with serial
hi to all i have this situetion, i use this shield http://www.cooking-hacks.com/documentation/tutorials/arduino-gprs-gsm-quadband-sim900, and i write this software
t
#include "mbed.h" Serial pc(SERIAL_TX, SERIAL_RX); // pc comunication Serial SIM900(PA_9, PA_10); // serial comunication DigitalOut sim_power(D9); // sim power // power to shield sim900 void power() { sim_power.write(1); wait(3); sim_power.write(0); wait(19); } // i read the serial answer void callback_rx() { pc.printf("%c", SIM900.getc()); } int main() { power(); wait_ms(100); pc.printf("\r\n GSM 900 TEST\n"); SIM900.attach(&callback_rx); SIM900.baud(9600); // oppure 115200 while(1) { SIM900.printf("AT\r"); wait_ms(1000); } }
All work well, when i send the AT comand the shield send me the ok now i want save this answare in a variable and i write this
#include <string> string result; .... void callback_rx() { // pc.printf("%c", SIM900.getc()); char x; x = SIM900.getc(); result += x; pc.putc(x); }
i don't see nothing, i want save the answer of shield for check it if all is ok, can you help me? best regards antonio
Assigned to
10 years, 1 month ago.This means that the question has been accepted and is being worked on.
Are you still getting interrupts? If you don't read all of the waiting data in your interrupt you may not get any more generated. Given the baud rate and simplicity of the code this shouldn't be a problem but just to be safe you should do:
thanks now all work well,
posted by Antoniolinux B. 03 Oct 2014