tags:

views:

368

answers:

1

Hi Guys,

I am writing a Python script to read a SMS from the SIM memory, buffer it and send the same SMS to another number. I am executing this script on Telit GM862-GPS. The script I have written is :

import MDM
MDM.send('AT+CMGF=1\r', 10)                      # Changing to Text mode
MDM.send('AT+CMGR=1\r',0)                        # Reading SMS at index 1
a = MDM.receive(10)                              # Receiving as string

MDM.send('AT+CMGS="Phone no.", 129', 0)          #selecting a particular no.
MDM.send(a, 0)                                   # sending retrieved SMS
MDM.sendbyte(0x1A, 0)                            # sending Ctrl Z

But I am facing this problem: After executing "AT+CMGR=1 \r" command, the script doesn't execute commands after that. I have checked this by putting a simple AT command to change some value after "Read SMS" command & that value doesnt get changed. I dont know for what weird reason its doing this.

It would be really helpful if someone can help me out with this.

Regards

Update

@ Paid nerd: Yes..thats a timeout value @ Jaime: A SMS exists in the SIM memory and it does show the SMS at index 1. The only problem I am getting is that it doesn't execute the commands which come after the "AT+CMGR" or "AT+CMGL" command. @ Foresto: I tried adding "\n" at the end but it doesn't execute the python statements after the Read SMS statement.

+1  A: 

It looks like your program is waiting for a response that never arrives. That sort of thing is typical when a device doesn't think you have sent a complete command yet.

I don't know the protocol you're using to communicate with that device, but it looks like a Hayes AT command set. Is it possible the device is expecting a newline character instead of or in addition to the carriage returns you're sending? For example:

'AT+CMGF=1\r\n'

Also, I don't know what your MDM object is, but could it be buffering your commands (not actually sending them) until you call a flush() method or something similar?

Forest