cognew(otherObj)
janb
Posts: 74
Hi,
I was wondering if it is allowed to fire a method from an OBJ being a member variable of the main OBJ on another cog?
Sth like this:
VAR
· long stack[noparse][[/noparse]32]
OBJ
· tt: "J_test"
PUB main
· tt.init
· cognew(tt.toggle,@stack)
··tt.setFlag(10) ' this value is NOT passed ·to tt ?!
the method tt.toggle blinks LED so I see it works, but
tt.setFlag(10) should·set internal varibale of J_test and
trun off the LED - this does not work.
If I reverse the order:
··tt.setFlag(10) ' this value is passed
··cognew(tt.toggle,@stack)
·than LED turns off instatntly - as it should.
So it looks like after cognew() the main cog is loosing access to the sub-OBJ.
In the manual it says only
cogenew(SpinMethod, ....
SpinMethod must be a method but does not say it must belong to the main OBJ. But perhaps it is implicit?
Thanks
Jan
·
I was wondering if it is allowed to fire a method from an OBJ being a member variable of the main OBJ on another cog?
Sth like this:
VAR
· long stack[noparse][[/noparse]32]
OBJ
· tt: "J_test"
PUB main
· tt.init
· cognew(tt.toggle,@stack)
··tt.setFlag(10) ' this value is NOT passed ·to tt ?!
the method tt.toggle blinks LED so I see it works, but
tt.setFlag(10) should·set internal varibale of J_test and
trun off the LED - this does not work.
If I reverse the order:
··tt.setFlag(10) ' this value is passed
··cognew(tt.toggle,@stack)
·than LED turns off instatntly - as it should.
So it looks like after cognew() the main cog is loosing access to the sub-OBJ.
In the manual it says only
cogenew(SpinMethod, ....
SpinMethod must be a method but does not say it must belong to the main OBJ. But perhaps it is implicit?
Thanks
Jan
·
Comments
It's hard to tell without looking at all of your code, but I think what might be happening
is that when you call...
cognew(tt.toggle,@stack)
...then...
tt.setFlag(10)
...never gets executed because the 'tt.toggle' is in an endless loop. When you reverse the
order, the 'tt.setFlag(10)' gets set prior to running 'tt.toggle'.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.