9

How do i send AT GSM commands using python?

Am able to do this quite easily using Delphi and some comport component (TComport), but how do i talk to my modem using python?

Gath

2 Answers 2

15

I do it like this with pyserial:

import serial

serialPort = serial.Serial(port=1,baudrate=115200,timeout=0,rtscts=0,xonxoff=0)
def sendatcmd(cmd):
    serialPort.write('at'+cmd+'\r')

print 'Loading profile...',
sendatcmd('+npsda=0,2')

Then I listen for an answer...

Sign up to request clarification or add additional context in comments.

4 Comments

How do you listen for the answer @c0m4
@c)m4 with serialPort.read(), I only get okay, not the reponse for the ussd command..
The litteral string "okay"?
hmm, multiple errors: there should be no space between the at_command, the other modems weren't responding except one. the pdu convertor was also wrong. I have fix them all now. @c0m4
4

I don't know if there is an AT module, but you can use pyserial to communicate with a serial port.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.