Serial Port with Timeout using Timer Event

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Serial Port with Timeout using Timer Event

931 次查看
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 回复

735 次查看
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 项奖励
回复