View Single Post
  #12   Spotlight this post!  
Unread 08-02-2012, 15:35
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: How to use tasks

BTW, FUNCPTR and VOIDFUNCPTR are custom types. I don't have Wind River in front of me at the moment so I can't find the definitions of FUNCPTR and VOIDFUNCPTR for you. But I think VOIDFUNCPTR defines a function that returns void and FUNCPTR defines a function that returns an integer. Apparent, the task function should be returning an integer. Probably wouldn't matter but more correctly:
Code:
static int TestTaskFunction(void)
{
    std::cout<<"task has been started"<<endl;
    return 0;
}
 
4174robot::4174robot()
{
    task1 = new Task("testtask", (FUNCPTR) TestTaskFunction);
}
BTW, in WPILib\task.h, the Task class constructor is defined as:
Code:
Task(const char* name, FUNCPTR function, INT32 priority = kDefaultPriority, UINT32 stackSize = 20000);
So it is expecting the type FUNCPTR.
__________________

Last edited by mikets : 08-02-2012 at 15:38.
Reply With Quote