USBX fails to transmit string in multiples of 128 bytes

Hi,

I am using S5D5 target board and using USBX sample program given on link: www.renesas.com/.../D6003114.html

I am surprise to see when I am trying to change STRLEN = 128 bytes after modifying the actual string in the API called, controller is not able to send 128 bytes of data. surprisingly if it is 129 bytes or 127 bytes, I don't see any problem.

Pls provide solution on the same.

 

Regards,

Mahesh

  • Hi Mahesh,

    The issue is that you have data that is modulo the USB endpoint size and the packet won't be send if the data ends on a 64 byte boundary. You can force the data out by sending a zero length packet. The following code can be used:

    if ((actual_length % 64) == 0)
    {
    status = ux_device_class_cdc_acm_write(g_cdc, buffer, 0, &actual_length);
    if (UX_SUCCESS != status)
    {
    /* Handle the error. */
    }
    }

    -Gary
  • In reply to garyj:

    Hi Gary,

    Thanks for your solution. It is working.
    Similar problem found when receiving 64bytes of data. how to resolve?

    Regards,
    Mahesh
  • In reply to Maheshkumar C:

    Hi Mahesh,

    The transmitting size will have to send a zero length packet (ZLP) to complete the transfer.

    -Gary