Last active
September 25, 2015 08:09
-
-
Save imrehg/4ce605ef01261f42046c to your computer and use it in GitHub Desktop.
PCIeDuino test script 01
This file contains hidden or 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
#!/usr/bin/env python2 | |
""" | |
Script to test the PCIeDuino serial connection | |
""" | |
import serial | |
import time | |
import datetime | |
for i in range(10): | |
try: | |
ser = serial.Serial('/dev/ttyACM%d' %(i), 115200, timeout=1) | |
print "Connected to ttyACM%d" %(i) | |
break | |
except SerialException: | |
continue | |
start = datetime.datetime.now() | |
print "Starting at %s" %(str(start)) | |
while True: | |
try: | |
ser.write("\n") | |
res = ser.read() | |
if res != '?': | |
print res | |
time.sleep(0.1) | |
except KeyboardInterrupt: | |
finish = datetime.datetime.now() | |
elapsed = finish - start | |
print "\nTest run for %s" %(elapsed) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment