What is the problem with receiving the reply before executing xSemaphoreTake()? If that happens the fact the interrupt occurred is latched by the semaphore, so the call to take the semaphore will return immediately as the semaphore is already there. If interrupts occur quickly you may want to use a counting semaphore instead. Also, if it is always the same task that is signaled from the interrupt, consider using a task notification in place of a semaphore. There are some code examples here: FreeRTOS task notifications, fast Real Time Operating System (RTOS) event mechanism
Mine doesn’t work that way for some reason. If the interrupt occurs before xSemaphoreTake(),it does not return immediately. It hangs. Do I need to initialize the semaphore before transmitting the command? I will look into your other suggestions. Thanks!!
Are you generating an interrupt on every character received? If so, if you are receiving multiples character at a faster rate, there are chances that you might miss the interrupt event and hence the received character is lost when using Binary Semaphore. As suggested you can use a counting semaphore or task notifications. You can also try using level interrupts instead of RX FIFO NOT EMPTY interrupt so that your ISR is not triggered often.
Also, is the xSemaphoreTake() not returning even once?
What is the priority of the UART interrupt and what is the setting of configMAX_API_CALL_INTERRUPT_PRIORITY in your project?