def hex_encode(data, errors='strict'):
    return (serial.to_bytes([int(h, 16) for h in data.split()]), len(data))
'40 41 42' -> b'@ab'
dataset/ETHPy150Open pyserial/pyserial/serial/tools/hexlify_codec.py/hex_encode