Skip to main content
rNabi
Associate
September 2, 2018
Question

USB VCP Bug?

  • September 2, 2018
  • 6 replies
  • 1236 views

Hi .I use CDC to transmit data to computer .

I want to transmit big array to the computer using CDC_Transmit_FS

what is the maximum buffer length that support this function ?

this is my code:

CDC_Transmit_FS((uint8_t *)buffer,(uint16_t)73728);

but some amount of data lost in the computer.

This topic has been closed for replies.

6 replies

Tobias Wedell
Associate II
September 2, 2018

Hi,

When you cast to uint16 then the highest value is 2^16=65536.

I don't know if the function support a length value of uint32. If not you must split your array.​

Tesla DeLorean
Guru
September 2, 2018

Confusing a limitation of the API with a bug.

>> If not you must split your array.​

Indeed, going to need to iterate through the array breaking into pieces which fit through the interface.

>>(uint16_t)73728

That's never going to be viable, and going to fail in any/all applications of such a cast.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
rNabi
rNabiAuthor
Associate
September 2, 2018

Hi thanks for your response

in usbd_cdc.h

typedef struct

{

 uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE/4];     /* Force 32bits alignment */

 uint8_t CmdOpCode;

 uint8_t CmdLength;   

 uint8_t *RxBuffer; 

 uint8_t *TxBuffer;  

 uint32_t RxLength;

 uint32_t TxLength;   

 __IO uint32_t TxState;    

 __IO uint32_t RxState;   

}

USBD_CDC_HandleTypeDef;

Tx lenght is 32 bits so do you think I can change

USBD_CDC_SetTxBuffer

CDC_Transmit_FS

input functions to uint32_t Len?

Pavel A.
September 2, 2018

> so do you think I can change USBD_CDC_SetTxBuffer CDC_Transmit_FS  

input functions to uint32_t Len?

You do not want to tinker with USBD_CDC_SetTxBuffer because it is part of the library maintained by ST.

CDC_Transmit_FS is OK to modify, it is part of your code (generated from a template, though). For example, you can a do a loop there.

-- pa

Ben K
Senior III
September 3, 2018

This question is also dependent on your target. If you are using a chip with OTG cores, the maximum length is limited by the peripheral, but on chips with normal USB the length is software limited only.

rNabi
rNabiAuthor
Associate
September 4, 2018

Yes I test on stm32f4discovery with 32 bit length not worked I must split array.

it has OTG cores .