import serial import struct from google.protobuf.message import DecodeError from serial.tools import list_ports from cls_device_pb2 import RequestList, Device, ResponseList from usb_pb2 import PackageType from vcp_driver import * if __name__ == "__main__": ser = setup_connection() # Create a RequestDeviceList message request = RequestList() request.msg = 1 # or whatever value you want to set # Serialize the request to a bytearray request_data = request.SerializeToString() # Send the request send_package(PackageType.REQUEST_DEVICE_LIST, request_data, ser) # Now wait for the response while True: # Read the header from the serial port response_header = ser.read(5) # assuming the header is 5 bytes long # Unpack the header to get the length and type length, typeid, check = struct.unpack('