[Python] Sending dictionary value with hex numbers over serial in python

Discussão em 'Python' iniciado por Stack, Fevereiro 17, 2025.

  1. Stack

    Stack Membro Participativo

    I have a dictionary with commands (ASCII with extended characters and hex numbers), that should be send over serial to a microcontroller.
    But I'm not able to get the right format for the value to be send.
    Any idea, how to do this? (Python 3.13.2 )

    command= {
    "cmd_a": 'AT\r',
    "cmd_b": 'AT+HTTPINIT\xAE\r',
    "cmd_c": 'AT+CGMM\xC7\xB4\r',
    }

    cmd_to_send = at_cmd.get("cmd_c")

    comport.write(cmd_to_send ??)

    Continue reading...

Compartilhe esta Página