Skip to content

Instantly share code, notes, and snippets.

@alejomongua
Last active August 29, 2015 14:01
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 alejomongua/82667dcc4eba6fe7e546 to your computer and use it in GitHub Desktop.
Save alejomongua/82667dcc4eba6fe7e546 to your computer and use it in GitHub Desktop.
Test para el loop
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()
print
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