def sixteen(data):
 n = 0
 for b in serial.iterbytes(data):
  (yield ('{:02X} '.format(ord(b)), (b.decode('ascii') if (' ' <= b < '\x7f') else '.')))
  n += 1
  if (n == 8):
   (yield (' ', ''))
  elif (n >= 16):
   (yield (None, None))
   n = 0
 if (n > 0):
  while (n < 16):
   n += 1
   if (n == 8):
    (yield (' ', ''))
   (yield ('   ', ' '))
  (yield (None, None))

def sixteen ( data ) : n = 0 for b in serial . iterbytes ( data ) : ( yield ( '{:02X} ' . format ( ord ( b ) ) , ( b . decode ( 'ascii' ) if ( ' ' <= b < '\x7f' ) else '.' ) ) ) n += 1 if ( n == 8 ) : ( yield ( ' ' , '' ) ) elif ( n >= 16 ) : ( yield ( None , None ) ) n = 0 if ( n > 0 ) : while ( n < 16 ) : n += 1 if ( n == 8 ) : ( yield ( ' ' , '' ) ) ( yield ( '   ' , ' ' ) ) ( yield ( None , None ) )
yield tuples of hex and ascii display in multiples of 16 .