Sending data to STM32 using Python

105 views Asked by At

I'm trying to send data using USB communication to STM32 with Python, but I cannot find a solution for this.

Currently , I can do it using Serial data and I can also receive data responses from the board, using the following way.

    def send_data_to_board(self):
        available_ports = list(serial.tools.list_ports.comports())
        if available_ports:
            board_port = available_ports[0].device  # Get the first available port
            try:
                board_connection.write('data')
                board_connection.close()
            except serial.SerialException as e:
                print(f"Failed to establish connection with the board: {e}")
        else:
            print("No available COM ports found.") 

But this will work only with serial data, I want to send USB data. Does anyone know how to do this ?

0

There are 0 answers