By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,908 Members | 1,892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,908 IT Pros & Developers. It's quick & easy.

[Prob]Sending AT commands through COM PORT

P: 2
I am trying to send SMS using sending AT commands to a GPRS mobile device in windows enviornment.I can send sms when i am sending commands using Hyper Terminal.but the problem is when i am Sending those commands using the following scripts its becoming unsuccessful.
Here is my code:

Expand|Select|Wrap|Line Numbers
  1. import time
  2. import serial
  3. # configure the serial connections
  4. ser = serial.Serial(
  5.     port='COM8',
  6.     baudrate=115200,
  7.     parity=serial.PARITY_NONE,
  8.     stopbits=serial.STOPBITS_ONE,
  9.     bytesize=serial.SEVENBITS
  10. )
  11. at_r = 'AT\r'
  12. sms_r = 'AT+CMGF=1'
  13. dest_r = 'AT+CMGS="+9190074xxx43"'
  14. call_r = 'ATDT +919339xxxx05\r'   #I can dial successfully 
  15. msg_r = 'This is text Message!!!!'
  16. msga_r = 'This is text Message!!!!\n'
  17. ser.isOpen()
  18.  
  19. #ser.write('AT+CGMM\r')             #working fine i can read the device name.
  20. ser.write(at_r)                    
  21. #ser.write(call_r)                  #Dial No. working fine
  22. ser.write(sms_r)                    #Set the mode to SMS mode
  23. ser.write(dest_r)                   #Set Destination
  24. ser.write(msga_r)                   #Set Text
  25. ser.write(chr(26))                  #write ctrl+z inthe port
  26.  
  27. #give device time to answer
  28. time.sleep(1)
  29. line = ''
  30. line = ser.read(19)
  31. print line
  32. ser.close()
Mar 13 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.