Skip to main content
Erenburg.Evgeny
Associate III
February 26, 2018
Question

Getting string on virtual com port.

  • February 26, 2018
  • 2 replies
  • 1392 views
Posted on February 26, 2018 at 12:04

I'm getting a string from a terminal.

 int main(void)

{

  Set_System();

  Set_USBClock();

  USB_Interrupts_Config();

  USB_Init();

 

  while (1)

  {

    if (bDeviceState == CONFIGURED)

    {

      CDC_Receive_DATA();

      /*Check to see if we have data yet */

      if (Receive_length  != 0)

      {

        if (packet_sent == 1)

          CDC_Send_DATA ((unsigned char*)Receive_Buffer,Receive_length);

        Receive_length = 0;

      }

    }

  }

And I see in Receive_Buffer my string. But I want to evaluate every char and to format a string as I need. For example I want to trim all '\n' and '\r' on reception level.

I didn't find a function I get chars from terminal. Where should it be?

    This topic has been closed for replies.

    2 replies

    AvaTar
    Senior III
    February 26, 2018
    Posted on February 26, 2018 at 12:24

    I didn't find a function I get chars from terminal. Where should it be?

    ...

      CDC_Receive_DATA();

      CDC_Send_DATA ((unsigned char*)Receive_Buffer,Receive_length);

    Obviously from the USB device.

    I suggest you need to read the USB spec. then, especially the sections about the CDC device profile.

    The air gets a bit thinner there - less people are really familiar with it.

    Erenburg.Evgeny
    Associate III
    February 27, 2018
    Posted on February 27, 2018 at 07:49

    AvaTar wrote:

    The air gets a bit thinner there - less people are really familiar with it.

    Thinner? Anorexic!

    AvaTar
    Senior III
    February 27, 2018
    Posted on February 27, 2018 at 08:05

    At least you have not lost your senso of humour ... ;)

    You intend to use the VCP functionality for debugging / instrumentation, right ?

    I would have trouble to justify coding effort, code size impact and performance requirements which a target USB implementation requires.

    Except you see it as a kind of apprentice piece.

    Andrew Neil
    Super User
    February 26, 2018
    Posted on February 26, 2018 at 12:48

    I'm a bit confused:

    I see in Receive_Buffer my string

    If you can see it in the Receive_Buffer, why can't you just process it from there?

    I didn't find a function I get chars from terminal

    But you said you have all the characters - in the 

    Receive_Buffer

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.