USB CDC Example Receive only fail

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

USB CDC Example Receive only fail

跳至解决方案
499 次查看
etronic_arg
Contributor III

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

 

标记 (3)
0 项奖励
回复
1 解答
411 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Yes, this is a good solution. After you have data, just call the the function to send.

BR

Xiangjun Rong

USB_DeviceCdcAcmSend();

 

在原帖中查看解决方案

0 项奖励
回复
3 回复数
450 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Can you tell us the part number you are using?

BR

XiangJun Rong

0 项奖励
回复
437 次查看
etronic_arg
Contributor III

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?

标记 (1)
0 项奖励
回复
412 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Yes, this is a good solution. After you have data, just call the the function to send.

BR

Xiangjun Rong

USB_DeviceCdcAcmSend();

 

0 项奖励
回复