2018-09-02 12:13 AM
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.
2018-09-02 04:24 AM
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.
2018-09-02 08:40 AM
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.
2018-09-02 09:26 AM
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?
2018-09-02 10:27 AM
> 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
2018-09-03 01:15 PM
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.
2018-09-04 03:55 AM
Yes I test on stm32f4discovery with 32 bit length not worked I must split array.
it has OTG cores .