desalegn
Newbie level 2
- Joined
- Mar 19, 2013
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,302
i write my code in c to read sms from gsm modem using proteus simulation.but i got the following on one of the virtual terminals and nothing on the other.
AT
AT+CMGF=1
AT+CMGR=1
but the response from the modem expected to be displayed on the 2nd virtual terminal.the code is as folows
void sms_read();
void sms_send();
char output[70];
void main() {
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(2000); // Wait for UART module to stabilize
sms_read();
}
void sms_read()
{
UART1_Write_Text("AT\n\r");
delay_ms(500);
UART1_Write_Text("AT+CMGF=1\n\r");
delay_ms(500);
UART1_Write_Text("AT+CMGR=1\n\r");
delay_ms(500);
while (1) {
if (UART1_Data_Ready() == 1) { // if data is received
UART1_Read_Text(output, "OK",90); // reads text until 'OK' is found
// sends back tex
sms_send();
}
}
}
void sms_send()
{
int i;
UART1_Write_Text("AT+CMGS=");
UART1_Write(0x22);
UART1_Write_Text("0912811798");
UART1_Write(0x22);
UART1_Write_Text("\n\r");
delay_ms(500);
UART1_Write_Text(output);
UART1_Write(26);// send ctrl + Z
}
plzzzz any help is appreciated
AT
AT+CMGF=1
AT+CMGR=1
but the response from the modem expected to be displayed on the 2nd virtual terminal.the code is as folows
void sms_read();
void sms_send();
char output[70];
void main() {
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(2000); // Wait for UART module to stabilize
sms_read();
}
void sms_read()
{
UART1_Write_Text("AT\n\r");
delay_ms(500);
UART1_Write_Text("AT+CMGF=1\n\r");
delay_ms(500);
UART1_Write_Text("AT+CMGR=1\n\r");
delay_ms(500);
while (1) {
if (UART1_Data_Ready() == 1) { // if data is received
UART1_Read_Text(output, "OK",90); // reads text until 'OK' is found
// sends back tex
sms_send();
}
}
}
void sms_send()
{
int i;
UART1_Write_Text("AT+CMGS=");
UART1_Write(0x22);
UART1_Write_Text("0912811798");
UART1_Write(0x22);
UART1_Write_Text("\n\r");
delay_ms(500);
UART1_Write_Text(output);
UART1_Write(26);// send ctrl + Z
}
plzzzz any help is appreciated