Skip to content

Instantly share code, notes, and snippets.

@imrehg
Last active September 25, 2015 08:09
Show Gist options
  • Save imrehg/4ce605ef01261f42046c to your computer and use it in GitHub Desktop.
Save imrehg/4ce605ef01261f42046c to your computer and use it in GitHub Desktop.
PCIeDuino test script 01
#!/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