dev_cdc_vcom_lite_bm is not full duplex ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

dev_cdc_vcom_lite_bm is not full duplex ?

852 Views
_Ferrari_
Contributor IV

 

Dear all,

I have a LPC55S28-EVK and I tried to install the demo software dev_cdc_vcom_lite_bm.

It works perfecyly but .... it seems that is half fuplex VCOM port.

I connected to a PC via USB the board and, usin putty program, I'm able to send chars to the board and receive chars from it.

Unfortunately if I wnat only send chars to the board and I don't wont to receive anithyng from it the putty software stop working.

I commented out the lines from 767 to 777 in the file virtual_com.c

 

       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_DeviceSendRequest(s_cdcVcom.deviceHandle, USB_CDC_VCOM_BULK_IN_ENDPOINT, s_currSendBuf, size);
//
//            if (error != kStatus_USB_Success)
//            {
//                /* Failure to send Data Handling code here */
//            }
//        }

so the software is able to receive messages from USB connection but it can't trasmit messages.

Than I recompile the project and I enter in debug mode.

I connect the USB port of the board to USB port of a computer and I run the demo USB software. The computer recognize the board as COM device.

Using putty program I press a key on the keyboard that the board receives correctly but if I press any other ket on the keyboard of the PC no other char is received from tha board.


Did you have any simnilar problem ? how did you fixed it ?

thank you very much for your help and cooperation

regards

 

Tags (1)
0 Kudos
Reply
7 Replies

802 Views
_Ferrari_
Contributor IV

Dear Alice,

thank you for you reply.

I have to develope a project that receives and transmits data from USB port. I have three cases:

a) The application has to receive and send data

b) The application only has to receive data (it doesn't transmit anything)

c) The application only has to transmit data (it doesn't receive anything)


I'm using LPC55S28-EVK and MCUXpresso IDE v11.5.1 [Build 7266] [2022-04-13]

I started from the sdk example dev_cdc_vcom_bm and I connected the USB port of PC to the board via 'full speed' USB port. Using PuTTY software I can send and receive chars to and from theboard and it works fine: Case a) is OK.


Than I commented out the lines from 630 to 639 of the file virtual_com.c

     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 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 */
            }
        }
#endif

in order to simulate the case b)

I set a breakpoint on the line 632 as you suggested in your previouse post

s_currSendBuf[s_sendSize++] = s_currRecvBuf[i];

Then I started PuTTY software and I typed one key on the PC keyboard. The software stops at the brackpoint and the the s_recvSize is equale 1. The received char on the first position of s_currRecvBuf is 'a' (I typed 'a' on the PC keyboard).

Than I clicked on the 'Resume' icon of the MCUXpresso IDE software to continue the debug.

Than I typed another char ('b') on the PC keyboard but the software doesn't stop at the breakcpoint: the character 'b' is not received. Case b) does'nt work.

Than I modified the virtual_com.c file as follow:

     /* endpoint callback length is USB_CANCELLED_TRANSFER_LENGTH (0xFFFFFFFFU) when transfer is canceled */
#if 0
        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;
        }
#endif
        s_currSendBuf[0]='a';
        s_currSendBuf[1]='b';
        s_currSendBuf[2]=' ';
        s_sendSize=3;
        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 */
            }
        }

in order to simulate the 'Case c) (the application transmits but doesn't receive)

As usual I used the PuTTY software and I noticed that the string 'ab ' is correctly transmited and received by the PC: case c) is OK.

Just for summaty:
a) The application has to receive and send data: It works.

b) The application only has to receive data (it doesn't transmit anything): It doesn't work.

c) The application only has to transmit data (it doesn't receive anything): It works.

Did yoy have any similar problem ?
How did you fixed it ?

Thank you for your help and cooperation
regards

0 Kudos
Reply

741 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

Yes, the same on my side.

And I think this is not the issue with MCU side code, because the terminal software on PC send data failed, so MCU can not received. How about try other terminal tools?

 

BR

Alice

0 Kudos
Reply

708 Views
_Ferrari_
Contributor IV

Dear Alice,

maybe I fixed the problem: I modified the software as follow:

 

  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;
        }
		
		// I added the line
		//------------------------------------------------------------------------------------------
        error = USB_DeviceCdcAcmSend(s_cdcVcom.cdcAcmHandle, USB_CDC_VCOM_BULK_IN_ENDPOINT, NULL, 0);
		//------------------------------------------------------------------------------------------

        if (s_sendSize)
        {
            uint32_t size = s_sendSize;
            s_sendSize    = 0;
			
			// I added the line
			//------------------------------------------------------------------------------------------			
            SDK_DelayAtLeastUs(100U, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);
			//------------------------------------------------------------------------------------------	
			
            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 */
            }
        }

 

By adding the two lines as the problem seems to be fixed. I transmit a NULL after receiving a data from USB port, but I have to delay the transmission if I have to receive and send data.

Thank you very much for your help and cooperation

regards

 

0 Kudos
Reply

739 Views
_Ferrari_
Contributor IV

Dear Alice,

thank you for your reply ?

you wrote:

>And I think this is not the issue with MCU side code, because the terminal software on PC send data failed, so MCU can not received.

If I understand your answer you wrote that the MCU firmware is ok. The problem is on PC site.

Could you, please, confirm your sentence ?

Thank you very much for your help and cooperation

regards

 

0 Kudos
Reply

835 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello ,

How about do not comment out the lines you mentioned,  while set a breakpoint with if received data :

   s_currSendBuf[s_sendSize++] = s_currRecvBuf[i];

 

BR

Alice

0 Kudos
Reply

832 Views
_Ferrari_
Contributor IV

Dear Alice,

thank you for your reply.

You suggested to comment out the line

s_currSendBuf[s_sendSize++] = s_currRecvBuf[i];

but I think that the result doesn't change because if I comment out the line that you have suggested, the value variable s_sendSize will be 0 (zero) so the lines that I commented out

        if (s_sendSize)
        {
            uint32_t size = s_sendSize;
            s_sendSize    = 0;

            error = USB_DeviceSendRequest(s_cdcVcom.deviceHandle, USB_CDC_VCOM_BULK_IN_ENDPOINT, s_currSendBuf, size);

            if (error != kStatus_USB_Success)
            {
                /* Failure to send Data Handling code here */
            }
        }

will be never executed

thank you for your help and cooperation

best regards

 

0 Kudos
Reply

818 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

"

You suggested to comment out the line

s_currSendBuf[s_sendSize++] = s_currRecvBuf[i];

"

->> No,  I mean set a breakpoint on here, and do no change any code.

Because you said board can receive and send data, while comment out send, the receive can't work.

So suggest you stop the project at receive step, check whether received data.

 

BR

Alice

0 Kudos
Reply