Printing on terminal using USB CDC VCOM example

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

Printing on terminal using USB CDC VCOM example

Jump to solution
1,839 Views
huy_dang
Contributor III

Hi all,

I'm using MCUXpresso IDE with SDK 2.2. I'm currently looking over the example which is titled usb_device_cdc_vcom_bm . From what I understand, the code is a polling loop that reads user input one character once at a time and sends it to the program. My question is if there's a way to go backward and print out to the terminal from the program instead.

Thank you in advance!

Tags (2)
0 Kudos
1 Solution
1,559 Views
huy_dang
Contributor III

Hi Sabina, 

Thank you for the tip. That is in the right direction but it didn't work. However, I got it working now by following this example here. There's a couple more steps I have to do in addition to your suggestions.

https://community.nxp.com/thread/458760?commentID=939834#comment-939834 

Thank you so much for your help!

Huy

View solution in original post

0 Kudos
6 Replies
1,560 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello,

Can you please provide the part number of the mcu that you are using?

Also, just to make sure I understand, do you want to print on the terminal from the program as part of the execution, without needing to type or expect a user input?

Best Regards,

Sabina

0 Kudos
1,560 Views
huy_dang
Contributor III

Hi Sabina,

Thank you for the reply. I'm currently using the FRDM-KL25Z and yes you got it right, I just want to print on the usb terminal as part of the execution.

Best,

Huy

0 Kudos
1,560 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hi Huy,

 In this case if you'd like to use the same functions that are being used in the examples.

Take a look at how usb_echo() works.

usb_echo you will find that you can print directly in the console. For example,

usb_echo("Hello World!"\r\n);

and you will see hello world printed in the serial terminal that you are using.

If you see the root function it is essentially a printf.

Hope this helps. Let me know if I answered your question or if you have other questions.

Best Regards,

Sabina

0 Kudos
1,560 Views
huy_dang
Contributor III

Hi Sabina,

usb_echo would only print to the IDE's console. I want to print it to the usb terminal that is reading the user input instead.

For example, if I add a usb_echo line to line 640 and print out the character being received through the terminal like this 

pastedImage_3.png

I will see this on the IDE's console. 

pastedImage_2.png

and here's the terminal that I want to print to instead. 

pastedImage_1.png

The hello world right here is written when I type it in. Now I want to be able to print something else instead of just what I typed in. 

I hope that clarifies it.

 

Thanks,

Huy

0 Kudos
1,559 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello,

Ok in this case you can use the same function used in the example to send what you type.

USB_DeviceCdcAcmSend

However instead of sending an array that is being filled as you type, you can send an array that has a static string. Just make sure that you the size is corrected for your string.

Please try this and let me know your results. Try using a breakpoint to see if it writes as you expect.

Best Regards,

Sabina

0 Kudos
1,560 Views
huy_dang
Contributor III

Hi Sabina, 

Thank you for the tip. That is in the right direction but it didn't work. However, I got it working now by following this example here. There's a couple more steps I have to do in addition to your suggestions.

https://community.nxp.com/thread/458760?commentID=939834#comment-939834 

Thank you so much for your help!

Huy

0 Kudos