Quick Basic Question
steprog
Posts: 227
Hi anyone,
I have been away from using props for a while, but I wanted to run some code in another cog, but I don't want to run in assembly. When you start a new cog all the samples I quickly looked at go to assembly. Any that just point to spin language? any examples out there?
Sorry, in a hurry to finish a project.
Thanks for any help
Greg
I have been away from using props for a while, but I wanted to run some code in another cog, but I don't want to run in assembly. When you start a new cog all the samples I quickly looked at go to assembly. Any that just point to spin language? any examples out there?
Sorry, in a hurry to finish a project.
Thanks for any help
Greg
Comments
The method "ModbusTestCogInit" starts a continuous loop.
The variable "result" (it's a "free" local variable in each method) contains the cog's ID number. You could display this number to see which cog was launched (though you don't really have to keep track of this).
If, in this example, the value of "return" were "-1", then I'd know there weren't any available cogs and the cog had not been successfully launched.
The array "modbusTestStack" is defined in the VAR section like this.
A stack of 100 is larger than will likely be needed.
There's discussion and code to determine stack space needed in this thread.
I personally like my technique of finding stack space better than the alternatives I've seen.
BTW, Only use cognew. Don't use coginit unless you have a really good reason to do so and really need it. I've never used coginit and I've written a lot of Propeller code.
Greg