GetTaskNextExec

From chipKIT
Jump to: navigation, search

Synopsis

 unsigned long getTaskNextExec(int id)

Parameter

id  : Task identifier for the task

Description

This function returns the scheduled time for the next execution of the specified task. The time is returned as the value of the system millisecond tick counter when the task is next scheduled to run. If the specified task identifier is invalid, or the task is currently disabled, the value 0 will be returned. Note that this can be ambiguous, as it is possible (1 in 232 chance) that the task is a valid, enabled task that happens to be scheduled to next run at the exact time that the millisecond tick counter overflows. The millisecond tick counter overflows once every 49.71 days. If necessary, a return value of 0 can disambiguate by calling getTaskState().

Return Value

System millisecond tick time when the task is scheduled to run.

Conforming To

The Task Management Functions are specific to ChipKit and exceed the Arduino 1.6.x specification.

Example

 int blink_id;
 unsigned long next_run;
 unsigned long blink_var;
 void blink_task(int id, void * tptr) {
   digitalWrite(led, !digitalRead(led); // Toggle pin state
 }
 void setup() {
   pinMode(led, OUTPUT);
   blink_id = createTask(blink_task, 200, TASK_ENABLE, &blink_var);
   next_run = getTaskNextExec( blink_id);
 }

See Also

createTask(), destroyTask(), getTaskId(), getTaskNextExec(), getTaskPeriod(), getTaskState(), getTaskVar(), setTaskPeriod(), setTaskState(), setTaskVar(), startTaskAt(),