Could you please elaborate your request? A simple test case would be helpful to understand your requirement.
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.
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.
UART.cyprj.Archive03.zip 1.7 MB