本帖最后由 mig29 于 2020-11-6 21:01 编辑
Demo程序里只开了256字节的Buf ,所以,发送数据大于255个时就会有问题。(这也是某些 USB转串口芯片有时候会出问题的根源)
uint8_t usb_recvBuffer[256];
uint8_t usb_sendBuffer[256];
/*Communication by VirtualComport*/
recvLen = CDC_Receive_DATA(usb_recvBuffer, 256);
if ( recvLen > 0 )
{
/*Send data to PC Host*/
sendLen = CDC_Send_DATA(usb_recvBuffer, recvLen);
AT32_LEDn_Toggle(LED3);
}
255个字符时正确收发:
[20:52:04.058]发→◇123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-abcde□
[20:52:04.061]收←◆123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-abcde
发两次256字符 + 一次255字符,光粗略看程序,应该会有问题,但实际上 MCU端还是全部收下来了,再一次发出来,在只有256字节Buf前提下不知道怎么做到的。。。。
[20:52:08.278]发→◇123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-abcdef□
[20:52:12.531]发→◇123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-abcdef□
[20:52:15.659]发→◇123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-abcde□
[20:52:15.665]收←◆123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-abcdef123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-abcdef123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-abcde
|