Xuecheng Xi wrote: > Dear Developers, > > I am writing a real time thread function in which I need to use the > channel number. Take pid.c as an example, the number of channel = > num_chan. For each channel, we have exported > > calc_pid(void* arg, long period). > > by using > > hal_export_funct(bu, calc_pid, &(pid_array[num]), 1, 0, comp_id). > > My question is in the function of calc_pid(void* arg, long period), > how can I know for which channel I am doing the calculations. As from > the arguments (void* arg, long period), there is no information > regarding the number of channel. >
pid_array is an array of structures, each with all the data needed for a PID loop. Each function gets a pointer to one structure with the data it needs, and is unaware of the other structures. If you are writing a HAL component, you are the one who defines that structure. You can have any fields you want in that structure, not just HAL pins and parameters. (See stepgen for an example of a large struct with lots of data in it). For your situation, you can add a "channel_num" field to the structure, and initialize it before you call export_funct during startup. Regards, John Kasunich ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Emc-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-developers
