Created
September 12, 2015 00:11
-
-
Save yosemitebandit/505d3a22eeeca9e33850 to your computer and use it in GitHub Desktop.
testing fona modules with serial commands on the beaglebone black
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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