3 Replies Latest reply on Jan 27, 2019 10:09 PM by BragadeeshV_41

    How do I get  Parameters with UART Receive

    antrc_3264986

      I have implemented a semaphore based uart task as specified by the PSoC 101: Lesson 2-1b. However, I want some commands to allow the user to enter parameters. Is there an example that allows the user to enter parameters after selecting a command?

        • 1. Re: How do I get  Parameters with UART Receive
          BragadeeshV_41

          Could you please elaborate your request? A simple test case would be helpful to understand your requirement.

           

          Regards,

          Bragadeesh

          • 2. Re: How do I get  Parameters with UART Receive
            antrc_3264986

            Bragadeesh,

             

            The user would select a command with a single keystroke. That command would require input, such as a numeric value. So, the command would be to set a parameter and there is the need for a user response, which is the numeric value.

             

            The semaphore design only allows a single character to be entered and a getchar() receives the command character. The UART task is blocked at xSemaphoreTake(). Next the task processes the single command character.

             

            How do I get the parameter value from the UART? Is there example code that I can use?

             

            The polling code allowed the building of a user response string. A call to a function getUserReponse() could block the command processing until a turnaround character LF. A flag would be set in the UART task and the getUserResponse() would unblock. The command processor function would then process the user response string (i.e. sscanf the parameter value).

             

            With the semaphore design I cannot block the UART task.

             

             

             

            Is this enough to go on? Thanks.

             

             

            • 3. Re: How do I get  Parameters with UART Receive
              BragadeeshV_41

              Hi,

               

              Can you try this idea and see?

               

              1. Generate an interrupt every time a character is received.

              2. Start forming the packet till carriage return is not received

              3. Once the packet is ready, give the semaphore from ISR. This will unblock the UART_Processtask

              5. Separate the command and parameters in the UART_Processtask

               

              The sample project is attached with this comment. Let us know in case of any clarifications.

               

              Regards,

              Bragadeesh