我可以从VCP(虚拟COM端口)获取255个数据包吗?

问题描述 投票:0回答:1

我知道STM32库在usb_desc.h的'VIRTUAL_COM_PORT_DATA_SIZE 64'的默认设置值。但是,由于我们的项目包太长,我想一次获得255个字节。因此,我更改了以下修改代码点,但由于“ USB缺陷问题”而无法获得正确的值。

/****** usb_prop.c **********/
DEVICE_PROP Device_Property =  {
Virtual_Com_Port_init,
Virtual_Com_Port_Reset,
Virtual_Com_Port_Status_In,
Virtual_Com_Port_Status_Out,
Virtual_Com_Port_Data_Setup,
Virtual_Com_Port_NoData_Setup,
Virtual_Com_Port_Get_Interface_Setting,
Virtual_Com_Port_GetDeviceDescriptor,
Virtual_Com_Port_GetConfigDescriptor,
Virtual_Com_Port_GetStringDescriptor,
0,
0xFF /*MAX PACKET SIZE*/ // default : 0x40
};

/****** usb_desc.c **********/
/* USB Standard Device Descriptor */
const uint8_t Virtual_Com_Port_DeviceDescriptor[] =  {
0x12,   /* bLength */
USB_DEVICE_DESCRIPTOR_TYPE,     /* bDescriptorType */
0x00,
0x02,   /* bcdUSB = 2.00 */
0x02,   /* bDeviceClass: CDC */
0x00,   /* bDeviceSubClass */
0x00,   /* bDeviceProtocol */
0xFF,   /* bMaxPacketSize0 */ // default : 0x40
0x83,
0x04,   /* idVendor = 0x0483 */
0x40,
0x57,   /* idProduct = 0x7540 */
0x00,
0x02,   /* bcdDevice = 2.00 */
1,              /* Index of string descriptor describing manufacturer */
2,              /* Index of string descriptor describing product */
3,              /* Index of string descriptor describing the device's serial number */
0x01    /* bNumConfigurations */  }; 

/****** usb_desc.h **********/
#define VIRTUAL_COM_PORT_DATA_SIZE              255 // 0xFF, default : 64 

请告诉我如何修改以便从USB数据包发送为255个字节。

usb stm32 descriptor
1个回答
0
投票

您不能这样操作。数据包的大小与USB端点相关,对于FS USB,它始终为64个字节。我的建议是:请勿修改和描述除非您真的知道自己要做什么(这里不是这种情况)。

如何接收更大的数据块:

  1. 创建缓冲区
  2. 当数据到达时,将其复制(附加)到该缓冲区
  3. 检查您是否已收到所有需要的数据
  4. 如果不转到第(2)点,否则转到第(5)点
  5. 对数据(您的大数据包)进行处理
  6. 重置缓冲区并转到点2
© www.soinside.com 2019 - 2024. All rights reserved.