• AVR Freaks

get number of bytes receive from USBHostIssueDeviceRequest ?

Author
cutemonster
Junior Member
  • Total Posts : 93
  • Reward points : 0
  • Joined: 2009/03/22 22:01:17
  • Location: 0
  • Status: offline
2011/02/28 12:03:36 (permalink)
0

get number of bytes receive from USBHostIssueDeviceRequest ?

Hi, I wonder what is the best way to get a byte count on the IN transaction?
Usually, for example, the byte count is the first byte of the device descriptor if we are processing setup in (device descriptor).
In my case, I need to know exactly how many I receive from pic24f host because first byte received is not always the count byte.
 
thanks!
#1

3 Replies Related Threads

    yts
    Super Member
    • Total Posts : 583
    • Reward points : 0
    • Joined: 2005/09/06 17:45:30
    • Status: offline
    Re:get number of bytes receive from USBHostIssueDeviceRequest ? 2011/03/02 01:11:57 (permalink)
    0
    As I am not so familiar with USB, I am interested in your case. Will you teach me your case in detail? It seems to me that you issue a “custom (not standard) device request” to a client devise by using a function USBHostIssueDeviceRequest(), and read (IN) some data through EP0 from the devise. Right?
    #2
    cutemonster
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2009/03/22 22:01:17
    • Location: 0
    • Status: offline
    Re:get number of bytes receive from USBHostIssueDeviceRequest ? 2011/03/03 15:31:25 (permalink)
    0
    Hi yts. Your're correct.
    I want to be a middle man between PC/other host and device.
    So I have a pic24 host and pic18f(device),  which communicating via spi.
    the pic18(device) will tell my pic24 how many bytes it receives so that my pic24 can clone the request to the other device.
    #3
    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    Re:get number of bytes receive from USBHostIssueDeviceRequest ? 2011/03/08 21:30:07 (permalink)
    0
    Hi, I wonder what is the best way to get a byte count on the IN transaction?

    For control read transfer using USBHostIssueDeviceRequest() also,
    it's the same application interface as other transfer type, bulk, interrupt and isoc.

    a) USBHostTransferIsComplete()
    This routine returns TRUE, when a transfer finishes on the target endpoint.
    At this time, the transferred data size is returned at the last parameter, *byteCount.

    BOOL USBHostTransferIsComplete( BYTE deviceAddress, BYTE endpoint, BYTE *errorCode, DWORD *byteCount );

    b) EventHandler
    When transfer completes, the eventHandler on the TPL is called with EVENT_TRANSFER.
    At this point, data->dataCount holds the transferred size.

    BOOL your_Event_Handler( BYTE address, USB_EVENT event, void *data, DWORD size )
    {
        switch (event)
        {
            case EVENT_TRANSFER:         // A USB transfer has completed
                #if defined( USB_ENABLE_TRANSFER_EVENT )
                    transferred_size = ((HOST_TRANSFER_DATA *)data)->dataCount;
                #endif


    Tsuneo
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5