Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 8 months ago.
how to send USBHID data from mbed Micro to pc using another Endpoint?
I run Helloword example of USBHID, there using hid.send(report), it is possible to send "report" to pc. Assume that this function uses Endpoint1. I want to send data using another Endpoint (e.g. Endpoint2) and in pc side can realize which received data is from Endpoint1, and which one from Endpoint2. Please help me to do this.
Question relating to:
1 Answer
9 years, 8 months ago.
Hi Ghasem,
I'm not very familiar with USBHIDs and endpoints, but maybe I can still help. For writing the pc side program, you could take a look at this wiki page: http://developer.mbed.org/cookbook/USBHID-bindings-. It goes through a few Python examples.
Also, regarding the endpoints, is there a specific reason why you need multiple endpoints? Are you just trying to sort different types of data? You could always do something like make the first byte of the HID message a unique ID depending on the type of message. Then on the pc side you would just look at the first byte to figure out how to handle the remaining message.
If it's something more complex, could you explain the situation? There might be a simpler solution.
All the best, Brian
I want to send data in parallel; in one way send the commands and in another way the pure data. The purpose is to reduce the complexity of coding and design as I have a lot of signals to handle; that's why I'm thinking about using 2 Endpoints.
About unique ID, in default, packet sizes are 64 byte consists of 8 8-byte, and USBHID always put a byte of "00" in the beginning of each packet. I think name of this byte is reportID. If I can change this reportID, yes, it is possible to identify the packets in pc side. How to chages this reportID?
posted by 17 Mar 2015I think if you just set the first byte of the HID_REPORT struct to match your reportID it should work.
I found this comment in the source of /USBHID/USBHID_Types.h
/* HID Report */ /* Where report IDs are used the first byte of 'data' will be the */ /* report ID and 'length' will include this report ID byte. */ typedef struct { uint32_t length; uint8_t data[MAX_HID_REPORT_SIZE]; } HID_REPORT;