This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Parameters for task function

Other Parts Discussed in Thread: SYSBIOS

The function passed to Task_create must be declared as follows,

typedef xdc_Void (*ti_sysbios_knl_Task_FuncPtr)(xdc_UArg, xdc_UArg);

What parameters do the parameters xdc_UArg  and xdc_UArg?  I can't seem to find any info on that.

  • When the task gets spun up (either dynamically at run time or via the cfg file) there are two paramaters arg0 and arg1 that can be supplied.

    If not used you can just dummy these out.

    Here is the example from the cdocs...

    var params = new Task.Params;
      params.instance.name = "tsk0";
      params.arg0 = 1;
      params.arg1 = 2;
      params.priority = 1;
      Task.create('&tsk0_func', params);

     

  • So I implement a function like

    Void tsk_func(UArg a0, UArg a1)

     {

      // task function

    }

    Do the  the a0 and a1 parameters hold the same values as the params.arg0 and params.arg1 variables?  I hope so, it'll make implementing class based tasks a lot easier.

  • Still having one problem,

    I'm trying to define a base class called AppTask from which all other tasks will be derived. 

    class AppTask {
    private:
        /**
        * Task handle.
        * Within SYS/BIOS tasks are identified by their task handle.  This variable maintains the private handle that is accessible through the  get_taskHandle function
        */
        Task_Handle _taskHandle;
        Error_Block _eb;
        char * _taskName;
    protected:
        Void systemLog(char *logMsg);
    public:
        AppTask(char * taskName);
        virtual ~AppTask();
        Task_Handle get_taskHandle(void);
        void get_eb(Error_Block * eb);
        char * get_taskName(void);
        virtual Void taskFxn(UArg a0, UArg a1);
        bool initialize();
    };

    extern "C" Void taskWrapper(UArg a0, UArg a1);

    AppTask::AppTask(char * taskName) {
        int i;
        i = strlen(taskName);
        _taskName =(char *)malloc(i);
        memcpy(_taskName,taskName,i);
    }

    bool AppTask::initialize()
    {
        bool result;
        char holdBuf[128];
        Task_Params taskParams;

        Task_Params_init(&taskParams);
        taskParams.priority = 1;
        taskParams.arg0 = (UArg)this;
        _taskHandle = Task_create(taskWrapper, &taskParams, &_eb);
        if (_taskHandle == NULL) {
            sprintf(holdBuf,"AppTask::AppTask Failed to create task %s\n",_taskName);
            systemLog(holdBuf);
            result = false;
        }
        else
        {
            sprintf(holdBuf,"AppTask::AppTask Task name: %s Handle: %p",_taskName,_taskHandle);
            systemLog(holdBuf);
            result = true;
        }
        return (result);
    }

    AppTask::~AppTask()
    {
        // TODO Auto-generated destructor stub
        char holdBuf[128];
        Task_delete(&_taskHandle);
        sprintf(holdBuf,"AppTask:~AppTask Task %c (%p) destroyed.",_taskName,_taskHandle);
        free(_taskName);
    }

    void AppTask::systemLog(char * logMsg)
    {
        System_printf("%s",logMsg);
    }
    Task_Handle AppTask:: get_taskHandle(void)
    {
        return _taskHandle;
    }
    void AppTask:: get_eb(Error_Block * perrorBlock)
    {
        memcpy(perrorBlock,&_eb,sizeof (Error_Block));
    }
    void AppTask::taskFxn (UArg a0, UArg a1)
    {
        while(1)
        {
            Task_sleep(10);
        }
    }
    char * AppTask:: get_taskName(void)
    {
        return _taskName;
    }

    Void taskWrapper(UArg a0, UArg a1)
    {
        AppTask * aTask;
        aTask = (AppTask *)a0;
        aTask->taskFxn(a0,a1);
    }

    The compoler is complaining that "argument of type "void (*)(UArg, UArg) C" is incompatible with parameter of type "ti_sysbios_knl_Task_FuncPtr""

    I can't see the prblem, can anyone else?



  • Hi Andrew,

    I added your code into a SYS/BIOS C++ Example and I didn't get your error.

    Can you try to create a "C++ Example (bigtime)" SYS/BIOS example using the TI Resource Explorer? Note, I did try this on a ARM based project.