def build_outgoing_serial_message(pkttype, ser_payload):
    payload_size = 0
    if (ser_payload is not None):
        payload_size = len(ser_payload)
    packet = (payload_size.to_bytes(length=1, byteorder='big', signed=False) + pkttype.to_bytes(length=2, byteorder='big', signed=False))
    if (ser_payload is not None):
        packet = (packet + ser_payload)
    ascii_packet = ''.join((('%02X' % i) for i in packet))
    return ascii_packet.encode('utf-8')
def build_outgoing_serial_message(pkttype, ser_payload):
    payload_size = 0
    if (ser_payload is not None):
        payload_size = len(ser_payload)
    packet = (payload_size.to_bytes(length=1, byteorder='big', signed=False) + pkttype.to_bytes(length=2, byteorder='big', signed=False))
    if (ser_payload is not None):
        packet = (packet + ser_payload)
    ascii_packet = .join((('%02X' % i) for i in packet))
    return ascii_packet.encode('utf-8')