How can you tell which cog pub main is using in your parent object?
turbosupra
Posts: 1,088
I believe I'm only using 7 cogs and cannot get my 8th object to start, so I'm wondering if their is a variable assignment I can do to find out which cog pub main in my parent object is using? Or does parent object pub mail always use cog0?
If so, I am missing cog1
I'm also using this and am not sure why, it was just something I saw someone else doing. Why do you add the +1 at the back of the return value?
return l_cog := cognew(@simulatecrank, @l_cog) + 1
Here are my current objects and the numeric cog number value assigned to them. The bottom/bolded one is not starting.
If so, I am missing cog1
I'm also using this and am not sure why, it was just something I saw someone else doing. Why do you add the +1 at the back of the return value?
return l_cog := cognew(@simulatecrank, @l_cog) + 1
Here are my current objects and the numeric cog number value assigned to them. The bottom/bolded one is not starting.
simCrank: 3
simCam: 4
simMaf: 5
calcCrank:6
calcCam: 7
simVvtli: 8
simSol: 0
Comments
So adding one to the reulst gives you a cog number 1 to 8 or zero on error.
That means you can the use a test for zero or false to see if the thing worked or not. So if you cognew was in a method called "start" you can do a simple
Your top level object starts first in cog 0.
As you only have 7 uses of cogs listed there and the initial top level cog uses another one that is only 8 and all should be well.
Are you sure simSol can be started correctly by itself?
The +1 is to make testing easier for whether the cog has already been started. COGNEW returns -1 if it can't start a new cog or the cog number (0-7) if one is started. By adding 1, this becomes a 0 if there's no cog running or 1-8 if a cog is started. This value can be stored in a byte and tested for zero / non-zero.
Your simSol is probably not starting because you're already using all the cogs. I don't know what your program is doing, but one of your objects may be using another cog. If your main program is using FullDuplexSerial for example, that takes a cog for the assembly part of its operation.
Thanks for the reply, I think it is the pst that is hogging my "phantom cog" . I commented out the cognew for simMaf and then got the quoted results below.
Any ideas on how to combine the functionality of pub main which besides being responsible for starting the other objects only manages comm data ... and the pst object?
The issue then is to find a place to put your com code.
Alternatively are you sure you can't combine two of your lower level cogs code into one?
@ Mike, I probably need a higher baud speed as I will be sending a lot of and infrequently receiving serial data over that. I may try that though, thank you.
If then have the following code in my program:
I get the following output in the terminal window:
In this example, I'd know that cog #2 called the "DebugStr" method. If I have more than one cog using a serial object I use locks so I don't get gibberish from two cogs sending data to the serial driver at once.
I think there's a multicog debug object that keeps track of the locks for you, but I haven't tried it or looked at the code.
Edit: I just read a bunch of what I had just skimmed over. It looks like my post is way off of what you're trying to figure out. Sorry about that.
I'm timing my com object and it's about 6M cycles without all of the extras.
Maybe I'll have to call that and the other object together? That's about the only idea I have besides trying to combine two of the PASM objects of which I don't want to do.
I remember in previous threads that there were more optimized serial comm objects, maybe I should consider one of those?
Now it is configured as
The problem is this, the sims will still be used in "production" because I want to read the sensor signal, intercept it and then send a new "simulated" signal to the ECU so I still need the simulation portion.
I really didn't want to complicate this project by having two props and a serial rx/tx combining circuit. I'm not even sure how to do that?