Last active
August 29, 2015 14:01
-
-
Save alejomongua/82667dcc4eba6fe7e546 to your computer and use it in GitHub Desktop.
Test para el loop
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 serial, sys | |
import Adafruit_BBIO.UART as UART | |
UART.setup("UART1") | |
ser = serial.Serial(port = "/dev/ttyO1", baudrate=1000000, timeout=1, parity='O', stopbits=2) | |
send = 'hola mundo hola mundo' | |
def printHexS(myString): | |
sys.stdout.write('\r') | |
for x in myString: | |
sys.stdout.write('{0:#04X} '.format(ord(x))) | |
sys.stdout.flush() | |
intentos = 0 | |
fallidos = 0 | |
try: | |
while intentos < 1000000: | |
ser.flushInput() | |
ser.flushOutput() | |
ser.write(send) | |
recibido = ser.read(len(send)) | |
print "enviado:" | |
printHexS(send) | |
if send == recibido: | |
intentos += 1 | |
print "OK", intentos | |
else: | |
fallidos += 1 | |
print "Mierda!", fallidos | |
print "recibido:" | |
printHexS(recibido) | |
print "longitud recibido:", len(recibido) | |
except: | |
print "Terminado" | |
print "Buenos:", intentos | |
print "Malos:", fallidos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment