Skip to content

Instantly share code, notes, and snippets.

@yosemitebandit
Created September 12, 2015 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yosemitebandit/505d3a22eeeca9e33850 to your computer and use it in GitHub Desktop.
Save yosemitebandit/505d3a22eeeca9e33850 to your computer and use it in GitHub Desktop.
testing fona modules with serial commands on the beaglebone black
import Adafruit_BBIO.UART as UART
import serial
UART.setup("UART1")
ser = serial.Serial(port="/dev/ttyO1", baudrate=9600, timeout=1)
ser.close()
ser.open()
def write_and_read(command):
ser.write(command + "\n")
result = []
c = ser.read()
result.append(c)
try:
while c:
c = ser.read()
result.append(c)
finally:
output = ''.join(result).strip()
print 'command "%s" -> "%s"' % (command, output)
if __name__ == '__main__':
if ser.isOpen():
write_and_read('AT+CMGD=51,4')
write_and_read('ATI')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment