I can't find an example of passing *two* parameters into cogstart method
John Kauffman
Posts: 653
C language: I can't find an example of passing two parameters into cogstart method
I'm learning how to pass parameters into cog's function at cogstart.
Passing one arg works (below).
I can't find an example for passing two args.
Any advice? Thanks.
I'm learning how to pass parameters into cog's function at cogstart.
Passing one arg works (below).
I can't find an example for passing two args.
Any advice? Thanks.
/** Multicore Example Stripped to Most Basic -- With parameters version Blink 2 LEDS at different Hz from different cogs Arg1 passes which pin to use remaining task: ??? how to pass 2nd arg (duration of blink) to method in cog? */ #include "simpletools.h" // allocate shared memory. Values are copied from examples unsigned int stack1[(160 + (50 * 2)) / 4]; unsigned int stack2[(160 + (50 * 2)) / 4]; // forward declare methods void blink(void *pin); // ??? second param ??? //---------------------------------------------- // main starts in cog 0; only starts cogs, no other tasks int main(){ // pin circuit test high(11); high(12); pause(500); low(11); low(12); pause(500); int cog1 = cogstart(blink,(void*) 11, stack1, sizeof(stack1)); // ??? second param ??? pause(10); int cog2 = cogstart(blink,(void*) 12, stack1, sizeof(stack2)); pause(10); } //main() //---------------------------------------------- // to do: pass in duration as second param so blink at different Hz void blink(void *pin){ // ??? second param ??? while(1){ //keep blinking high(pin); pause(1000); // // ??? use second param here instead of hard-code 1000 low(pin); pause(1000); } // while(1) to keep blinking } // blink()
Comments
I'm going to hold off on that until I get better at C. Passing one pram will do for now.
But will try this after other parts work
Thanks
This is for my Basic PBASIC Tasks in C guide for people converting, so your time answering should be leveraged.