Serial Port with Timeout using Timer Event

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Serial Port with Timeout using Timer Event

582 Views
waynetaylor
Contributor II

Many people have asked about solutions for adding timeouts to the fgetc() blocking function. How about using a timer event to restart the task that called fgetc()? I don't know how to do it, but I think it might have something to do with _taskq_resume().

Has anyone used task queues.

Wayne

1 Reply

386 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Wayne,

If you want the task to exit form fgetc() and continue you would need to modify the bsp. But if you dont have problem on restarting the task you may use a timer as you say.

In MQX installation you can find hwtimer and timer examples. C:\Freescale\Freescale_MQX_4_2\mqx\examples

You can also use lwtimer.

For restarting the task you need _task_restart()

E.g.

_task_id uart_task_id;

uart_task_id = _task_create(0, UART_TASK, 0);

_task_restart(uart_task_id, NULL, 0);

Best regards,

Carlos

0 Kudos
Reply