| Copyright: | Copyright 2007 Dean Hall. All rights reserved. |
|---|---|
| Author: | Dean Hall |
| Revision: | 01 |
| Date: | 2007/12/14 |
Init pseudo-Argonaut side (in a separate terminal):
>>> import serial >>> fn = "/dev/cu.SLAB_USBtoUART" >>> s = serial.Serial(fn, 9600)
Init ROS side:
>>> import serial >>> fn = "/dev/cu.usbserial-A70041iX" >>> s = serial.Serial(fn, 9600)
Get Firmware Version:
>>> s.write("+++")
>>> s.readline(eol='\r')
'OK\r'
>>> s.write("ATVR\r")
>>> s.readline(eol='\r')
'1220\r'
Get Hardware Version:
>>> s.write("+++")
>>> s.readline(eol='\r')
'OK\r'
>>> s.write("ATHV\r")
>>> s.readline(eol='\r')
'1941\r'
Set Baud rate to 19200:
>>> s = serial.Serial(fn2,9600) >>> atcmd(s,"BD4,WR,CN") OK >>> s = serial.Serial(fn2,19200) >>> s.readline(eol='\r') OK
Set the module's Network Identifier (and write to NV memory):
>>> s.write("+++"); time.sleep(1.1); s.readline(eol='\r');
'OK\r'
>>> s.write("ATNIROS,WR,CN\r"); s.readline(eol='\r')
'OK\r'
Here's a function to make sending AT commands simpler (be sure to import time before using this function):
def atcmd(s, cmd, arg=""):
s.write("+++")
time.sleep(1.1)
assert "OK\r" == s.readline(eol='\r')
s.write("AT%s%s\r" % (cmd, arg))
print s.readline(eol='\r')
s.write("ATCN\r")
assert "OK\r" == s.readline(eol='\r')