tags:

views:

2210

answers:

2

Can someone please show me a full python sample code that uses pyserial, i have the package and am wondering how to send the AT commands and read them back!

H-e-l-p !

+2  A: 
import serial
ser = serial.Serial(0)  # open first serial port
print ser.portstr       # check which port was really used
ser.write("hello")      # write a string
ser.close()             # close port

use http://pyserial.wiki.sourceforge.net/pySerial for more examples

bb
A: 

I have not used pyserial but based on the API documentation at http://pyserial.wiki.sourceforge.net/pySerial it seems like a very nice interface. It might be worth double-checking the specification for AT commands of the device/radio/whatever you are dealing with.

Specifically, some require some period of silence before and/or after the AT command for it to enter into command mode. I have encountered some which do not like reads of the response without some delay first.

Paul Osborne