1 2 Previous Next 17 Replies Latest reply on Oct 11, 2020 10:18 PM by BragadeeshV_41

    PSoC 5LP - Prompt message & commands definition

    RoRo_4659551

      Hi,

       

      I am using the Term_v2_2 component, USB_UART mode.

       

      1. I am trying to configure that I will receive a prompt message '#' when I turn the unit ON, I tried to use '\n' and '\r' but for some reason its not working.

      2. I want the user to type the command and finish it with the "ENTER" key [currently it is defined as 10 digits].

       

      Please your support, this is my current code:

       

      int main()

      {

          char rdBuffer[RD_BUFFER_LEN];

          char newString[10][10];

          //char prompt[4]="\r# ";

       

       

          /* Enable Global interrupts - used for USB communication */

          CyGlobalIntEnable;

       

       

          SPIM_Start();

          LCD_Char_Start();

          ADC_SAR_0_Start();

          DVDAC_1_Start();

          DVDAC_2_Start();

          Opamp_1_Start();

          Opamp_2_Start();

       

          /* When implementing a <=5 channel mux, the Analog sequencing Mux is faster

           * on an average than the Analog Hardware mux. However, additional code is

           * required to select channels non-sequentially.

           */

          AMux_0_Start();

      Term_Start();

          /* Place your initialization/startup code here (e.g. MyInst_Start()) */

      CySysTickStart();

      CySysTickSetCallback(0,&isr_systick_0);

         

          /* Start of forever loop */

          for(;;)

          {

      char rdValue;

          int r=0;

          int t=10;

          int i=0;

          int j=0;

          int ctr=0;

          uint8 y=0;

         

             

              for(r=0; r<65;r++)

              {

              rdBuffer[r]=0;

              }

             

             

              //while(Term_GetChar()!=' ');

              //Term_PutString(prompt);

             

              while(t>0)

              {

                  if((rdValue=Term_GetChar())!='\0')

                  {

                      //PIN_LED_BLUE_Write(1);

                      //CyDelay(100);

                      rdBuffer[i]=rdValue;

                      i++;

                      t--;

                      Term_PutChar(rdValue);

                      Term_PutString("");

                      rdValue='\0';

                      //PIN_LED_BLUE_Write(0);

                      //CyDelay(100);

                  }

              }

              //while(Term_GetChar()!='\r');

             

             

             

              /* Split the command by space into words */       

              for(y=0;y<=(strlen(rdBuffer));y++)

              {

              // if space or NULL found, assign NULL into newString[ctr]

                  if(rdBuffer[y]==' '||rdBuffer[y]=='\0')

                  {

                  newString[ctr][j]='\0';

                  ctr++;  //for next word

                  j=0;    //for next word, init index to 0

                  }

              else

                  {

                  newString[ctr][j]=rdBuffer[y];

                  j++;

                  }

              }

             

              /* The splited command will be directed to the relevant path.

              If read, the function prints the relevant port's hex value.

              If write, the function activate the port in accordance to the command and returns '#' */

              Command(newString[0], newString[1], newString[2], newString[3]);

             

          } /* End forever loop */

        1 2 Previous Next