Hi,
I just trying to do a Virtual COM communication based on the USB CDC example from SDK.
I tested the example with success.
I cancel the "echo" part of the APPTask:
static void APPTask(void)
{
    usb_status_t error = kStatus_USB_Error;
    if ((1 == s_cdcVcom.attach) && (1 == s_cdcVcom.startTransactions))
    {
        /* User Code */
        /* endpoint callback length is USB_CANCELLED_TRANSFER_LENGTH (0xFFFFFFFFU) when transfer is canceled */
        if ((0 != s_recvSize) && (USB_CANCELLED_TRANSFER_LENGTH != s_recvSize))
        {
            int32_t i;
			/* Copy Buffer to Send Buff */
            for (i = 0; i < s_recvSize; i++)
            {
                s_currSendBuf[s_sendSize++] = s_currRecvBuf[i];
            }
			s_recvSize = 0;
        }
/*
        if (s_sendSize)
        {
            uint32_t size = s_sendSize;
			s_sendSize    = 0;
            error = USB_DeviceCdcAcmSend(s_cdcVcom.cdcAcmHandle, USB_CDC_VCOM_BULK_IN_ENDPOINT, s_currSendBuf, size);
            if (error != kStatus_USB_Success)
            {
                // Failure to send Data Handling code here
            }
        }
*/
If I send "HELLO" wth a terminal from a PC, the first time s_currSendBuf fills with the characters.
With the second "HELLO" I send, the terminal stucks.
I just need to receive characters but not send them back.
What would be the right way to do it?
Thanks
Solved! Go to Solution.
Hi,
Yes, this is a good solution. After you have data, just call the the function to send.
BR
Xiangjun Rong
USB_DeviceCdcAcmSend();
Hi,
Can you tell us the part number you are using?
BR
XiangJun Rong
Hello XiangJun,
The part I'm using is the MK27FN2M0VM115 in a custom board, but I also tested it in a FRDM-K64F.
I solve the issue partially calling the USB sending fuction without data after receiving:
 if (s_sendSize)
        {
            uint32_t size = s_sendSize;
			s_sendSize    = 0;
            error = USB_DeviceCdcAcmSend(s_cdcVcom.cdcAcmHandle, USB_CDC_VCOM_BULK_IN_ENDPOINT, NULL, 0);
            if (error != kStatus_USB_Success)
            {
                // Failure to send Data Handling code here
            }
        }
Is there a better solution?
Hi,
Yes, this is a good solution. After you have data, just call the the function to send.
BR
Xiangjun Rong
USB_DeviceCdcAcmSend();