more than 15 parameters to pass to a cog?
Zap-o
Posts: 452
I need to pass more than 15 parameters to a cog. Can this be done?
Cog.start (_ff, _Tf, _X0, _X1, _Y0, _Y1, _Vr2, _aR1, _aR2, _Pb1, _Pb2, _Pb3, _Ab1, _Ab2, _Ab3,_kb1, _kb2, _kb3, _max, _min, _all)
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propeller Tools
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You can also copy the parameters in the Spin start method like:
Post Edited (Mike Green) : 8/25/2009 7:24:42 PM GMT
Either way you go, it will be painful though ... unless your interface parameters lose weight [noparse]:)[/noparse]
You could use a generic buffer instead and provide methods to do get/set on the parameters.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propeller Tools
Bad, bad, bad, no, no, no!
You are passing the long address of a set of parameters on the stack. By the time the cog has loaded the spin routine will have returned and possibly damaged the stack contents. Don't do this.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lt's not particularly silly, is it?
But I'd be much more inclined just to do a longmove from @_ff to a parallel area in the DAT section before doing the cognew.
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 8/26/2009 1:40:15 AM GMT
I usually add a delay after cognew or poll for the cog to finish in my code to make sure the cog loads before i try to use it. For example, even doing the RightThing(tm) as in FullDuplexSerial and not waiting for it to load before calling fd.str(string("Hello")) pretty much guarantees output failure. Shrug shoulders [noparse]:)[/noparse]
So, Is Python really named after Monty Python?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propeller Tools