cancel
Showing results for 
Search instead for 
Did you mean: 

USB: how to increase the input and output receive buffer

bruzzim
Associate II
Posted on December 02, 2014 at 21:24

Hello,

I designed my own application starting from VirtualComport_loopback example project.

I have a modbus client protocol running on USB and using CDC_Send_DATA() and CDC_Receive_DATA() send and get data from PC virtual comm. port.

I have problems with modbus commands with read and/or writes longer that 64 bytes. I resolved the output problem splitting the answer into 64 bytes blocks. I wonder if I can do the same thing with input or increase the input buffer to 256 bytes (max. protocol message length).

Here is some piece of code:

uint32_t CDC_Send_DATA (uint8_t *ptrBuffer, uint16_t Send_length)

{

  uint8_t len;

  uint8_t *buff = ptrBuffer;

  packet_sent = 0;

  while (Send_length)

  {

    if (Send_length < 64) len = Send_length;

    else len = 64;

    

    /* send  packet to PMA*/

    UserToPMABufferCopy((unsigned char*)buff, ENDP1_TXADDR, len);

    SetEPTxCount(ENDP1, len);

    SetEPTxValid(ENDP1);    

    

    Send_length -= len;

    buff += len;

    Delay_10ms(2);

  }

  return 1;

}

0 REPLIES 0