[Prob]Sending AT commands through COM PORT

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Debasish Mandal
    New Member
    • Mar 2011
    • 2

    [Prob]Sending AT commands through COM PORT

    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:

    Code:
    import time
    import serial
    # configure the serial connections
    ser = serial.Serial(
    	port='COM8',
    	baudrate=115200,
    	parity=serial.PARITY_NONE,
    	stopbits=serial.STOPBITS_ONE,
    	bytesize=serial.SEVENBITS
    )
    at_r = 'AT\r'
    sms_r = 'AT+CMGF=1'
    dest_r = 'AT+CMGS="+9190074xxx43"'
    call_r = 'ATDT +919339xxxx05\r'   #I can dial successfully 
    msg_r = 'This is text Message!!!!'
    msga_r = 'This is text Message!!!!\n'
    ser.isOpen()
    
    #ser.write('AT+CGMM\r')             #working fine i can read the device name.
    ser.write(at_r)                    
    #ser.write(call_r)                  #Dial No. working fine
    ser.write(sms_r)                    #Set the mode to SMS mode
    ser.write(dest_r)                   #Set Destination
    ser.write(msga_r)                   #Set Text
    ser.write(chr(26))                  #write ctrl+z inthe port
    
    #give device time to answer
    time.sleep(1)
    line = ''
    line = ser.read(19)
    print line
    ser.close()
Working...