I am using the Linux portable layer of FreeRTOS for my application. Each of the FreeRTOS tasks is created as pthreads. When I am trying to give user input through stdin using scanf() inside such a FreeRTOS task, it does not seem to work. The scanf() always returns -1 and does not wait for user input. How can I get around this?
I tried another workaround. If I created a new pthread from within the FreeRTOS task, scanf() seems to work. How does this work and is it legitimate to create a pthread from within a FreeRTOS task?
I also doubt you can have a FreeRTOS task block to wait for user input because FreeRTOS tasks can only block on FreeRTOS primitives known to the scheduler. If the task is blocked waiting for user input it is blocked on a Linux primitive unknown to the FreeRTOS scheduler - so the scheduler doesn’t know the task isn’t running and can’t unblock the task when user input arrives.