How to use struct.pack for uart?

hi,i am trying to sent binary data to stm32.
here is my code:

uart = UART(1, 115200, timeout_char=1000)                        
uart.init(115200, bits=8, parity=None, stop=1, timeout_char=1000)


def uart_sent(reason,data_):
    global uart
    needtosend = struct.pack("cc",reason.to_bytes(1,byteorder='little'),data_.to_bytes(1,byteorder='little'))
    uart.write(needtosend)
    return

but when i called “uart_sent” function like this:
uart_sent(0x00,0xff)

I got error:
Traceback (most recent call last):
File “”, line 172, in
File “”, line 41, in uart_sent
TypeError: function doesn’t take keyword arguments

but I do the same thing in jupyter notebook to test my code:

this code can work perfectly.
forgive my poor english :sob:

Hi, you need to use the API for the OpenMV Cam. We don’t have an emulator in Jupiter notebooks… so, whatever code you run there that’s not pure Python doesn’t transfer.

Thank for your answer.now,i am using struct.pack(“bb”,reason,data_) instead of the previous code. * The code works as I expected. :smile: