cognew program halt
csae8126
Posts: 14
in Propeller 1
I have got 2 Spin objects: main.spin, serialInterface.spin
in main i'm calling
serInt.Start
...
display result
Which should fire up a cog and listen on the serial interface for communication. But as long as i have the "_CogNumber := cognew(init, @_StackSpace)" in serialInterface.spin program execution not goes over that instruction. Can anyone please tell me wath im doing wrong?
serialInterface.spin:
OBJ
pst : "Parallax Serial Terminal"
VAR
long _StackSpace[8]
byte _CogNumber
PUB Start | i
Stop
'_CogNumber := cognew(init, @_StackSpace)
PUB Stop
if _CogNumber > -1
cogstop(_CogNumber)
PRI init
pst.Start(115_200)
repeat
pst.StrIn(@serialIn)
handleInput
PRI handleInput
if(serialIn == startSequence)
pst.Str(String("init_ok"))
else
pst.Str(String("uC"))
DAT
startSequence byte "init"
serialIn byte 50
in main i'm calling
serInt.Start
...
display result
Which should fire up a cog and listen on the serial interface for communication. But as long as i have the "_CogNumber := cognew(init, @_StackSpace)" in serialInterface.spin program execution not goes over that instruction. Can anyone please tell me wath im doing wrong?
serialInterface.spin:
OBJ
pst : "Parallax Serial Terminal"
VAR
long _StackSpace[8]
byte _CogNumber
PUB Start | i
Stop
'_CogNumber := cognew(init, @_StackSpace)
PUB Stop
if _CogNumber > -1
cogstop(_CogNumber)
PRI init
pst.Start(115_200)
repeat
pst.StrIn(@serialIn)
handleInput
PRI handleInput
if(serialIn == startSequence)
pst.Str(String("init_ok"))
else
pst.Str(String("uC"))
DAT
startSequence byte "init"
serialIn byte 50
Comments
-Phil
First of all you where right, increasing the stack was needed.
But the program halted because i was to stupid:
In the Start- function the first thing i did was calling Stop which then stopped the cog if _CogNumber was > -1. In my case the _CogNumber was 0 and it stopped my main cog
Thank you one more time for your Help!
The line "if(serialIn == startSequence)" only compares the first character of the received data.
As your code presently stands, there's no need to start another cog. You could just call "Init" from the "Start" method. As it is now you allow the initial cog (cog #0) to die.
You pass a pointer to "serialIn" to PST in order to store a string but the "serialIn" is only one byte long.
I think the above code is close to what you trying to accomplish.
Edit: I missed the part about this being a child object. In the case of a child object you may well want to start another cog. A lot depends on what the parent object is doing. Because of the mistakes made in the object you posted, I'm afraid you may also have serious errors in your parent object. If you want to post your complete program we could take a look at it. Use the Propeller Tool's "archive" feature to archive all the objects used in a program.
thats a good advice, i will remeber it!