Cog ID confusion
Moskog
Posts: 554
in Propeller 1
Hi again.
In some of my projects I need to keep track of the cogs to be able to stop them and then restart if there are problems.
Yes, I optionally I should have written the cog methods good enough to handle such kind of situations, but I'm not there yet.
But I'm a little bit on my way by using the first, startup cog to act like a watchdog, to keep watching the other cogs.
In one of my project, the first method (cog 0) starts three other cogs like this:
InitDisplay starts like this:
InitRF starts like this:
When debugging the Cog ID numbers I get this result:
The problem here is that two cogs seems to get the same ID. I have faced the same problem in other projects too. I am not sure if this is for real or if it just "looks like". But if I need to do a cogstop, I'm not sure if I stop the right cog.
Thats my problem, and I would appreciate if any of you could give me an idea on what I'm doing wrong here.
In some of my projects I need to keep track of the cogs to be able to stop them and then restart if there are problems.
Yes, I optionally I should have written the cog methods good enough to handle such kind of situations, but I'm not there yet.
But I'm a little bit on my way by using the first, startup cog to act like a watchdog, to keep watching the other cogs.
In one of my project, the first method (cog 0) starts three other cogs like this:
PUB Main ' Start other routines and keep watching the status of them PSTCog := debug.Start(PSTBaud) ' Temporary, only at design time InitDisplay ' Launch Display Cog, Get values and display on LCD and TV InitRF ' Launch RF Cog, Receive values from remote station MainCog := cogid ' Save Main cog's ID repeat...
InitDisplay starts like this:
PUB InitDisplay DisplayCog := cognew (Display , @DisplayStack) PUB Display | a, count TVTextCog := TVtext.start(TVPin) ' Starts TV_Text.spin (that again starts TV.Spin in new cog)
InitRF starts like this:
PUB InitRF RFCog := cognew (receiveRF , @RFstack) ' Start RS485 routines in new cog PUB receiveRF |i,a , Index, startbyte, NightLight dira[RFLED]~~ dira[LightOut]~~ ' Night Light Pin set to output FDSCog := SER.start(RX433,TX433, %0000, 1200) waitcnt(80_000_000+cnt)
When debugging the Cog ID numbers I get this result:
' 6 Cogs in use: CogID: ' Watchdog (main loop) 0 ' ├──→Debug (PST) 2 ' ├──→Init Display 2 ' │ └──→TV 6 ' └──→Init RF 3 ' └──→FDS 5
The problem here is that two cogs seems to get the same ID. I have faced the same problem in other projects too. I am not sure if this is for real or if it just "looks like". But if I need to do a cogstop, I'm not sure if I stop the right cog.
Thats my problem, and I would appreciate if any of you could give me an idea on what I'm doing wrong here.
Comments
Will check it out and come back with the Result.
So, when updating the CogID list, adjusting for +1, all begins to make sense:
Thank you, Wuerfel_21, really appreciate your fast respond.
BTW If you wait a short time after starting a cog that starts another, you will get them in order.
Your prop OS looks very interesting, saved on my Favorite list already!
On cogs in order, that doesn't matter for me as long as the Propeller itself keep them under control
IIRC the “ver” command will list the in-use cogs.