import serial
binary_string = lambda n: n>0 and binary_string(n>>1)+str(n&1) or ''
ser = serial.Serial('/dev/ttyS0', 115200)
ser.flushInput()
ser.flush()

def next_chr():
   c = str(ord(ser.read()))
   return " " * (3 - len(c)) + c

#while True:
#    num = ord(ser.read())
#    bs = binary_string(num)
#    print ("0" * (8 - len(bs))) + bs, num
#while True:
#     a = [next_chr(), next_chr(), next_chr()]
#     print [" " * (3 - len(n)) + n for n in a]
#while True:
#      print "val", next_chr(), "low addr", next_chr(), "high addr", next_chr()
while True:
     print next_chr()
