This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

reading data from USB endpoint

Hello,

I modified a "memory" example for AT91SAM7X-EK board and I am trying to read data from Endpoint 2 (OUT).
The function USB_ReadEP returns a byte count of data received. But When I try to read the data buffer that is suppose to hold this data it doesn't match what the Host sent.

Here is the code I used:

         BYTE * EP_Data;
        DWORD cnt;
        // Read EP2 data
        cnt = USB_ReadEP (0x02, (BYTE*)EP_Data);

         // Write data back to host
        USB_WriteEP(0x83, (BYTE *)EP_Data, cnt);

So I get the correct count of bytes received but the data in the EP_Data buffer doesn't match what I sent from the Host.
Does anyone know if this is the correct way to read data from Endpoints?

Thanks
Mario

Parents
  • I just noticed this morning that I need to have an declared array and not just a pointer. I thought it would work either way since I wanted to do some data comparison using strncmp() function. Since I now know I have to declare it as BYTE EP_Data[] now I can't use that function anymore.
    So you are right, I didn't have it declared properly.

    Thanks

Reply
  • I just noticed this morning that I need to have an declared array and not just a pointer. I thought it would work either way since I wanted to do some data comparison using strncmp() function. Since I now know I have to declare it as BYTE EP_Data[] now I can't use that function anymore.
    So you are right, I didn't have it declared properly.

    Thanks

Children