Shop OBEX P1 Docs P2 Docs Learn Events
Cognew - Cogstop what am I doing wrong? — Parallax Forums

Cognew - Cogstop what am I doing wrong?

Laurent RLaurent R Posts: 27
edited 2009-04-10 13:36 in Propeller 1
New post bescause it's not really the same thread as precedent...

After calling the method to stop the cog I still receive the string on the serial terminal ...

Can someone tell me what I'm doing wrong???

thanks

Laurent

[code]

CON

_clkmode = xtal1 + pll16x ' use crystal x 16
_xinfreq = 5_000_000




OBJ

ser : "Extended_FDSerial" 'For debug and serial com

Var

Byte CogAlarm 'Num

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2009-04-10 11:26
    Basically, you're starting a cog which starts another cog, i.e. ser.start() has its own call to cognew(). So shutting down your wrapper cog won't stop the serial device.
  • Laurent RLaurent R Posts: 27
    edited 2009-04-10 11:34
    I agree but It shouldn't send me a string if the alarmcog is down right?

    Thanks

    Laurent
  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-10 13:33
    In your start method you start a new cog (Alarm). The first thing that Alarm.start does (as it should) is to start another cog (done by ser.start), then fill up a buffer with characters to send. When you do the Alarm.stop, it stops that cog, but leaves the serial I/O driver running. You may want to call ser.stop in Alarm.stop before you do the cogstop.
    PUB StopAlarm
      if CogAlarm
        ser.stop
        cogstop(CogAlarm~ -1 )
    
  • Laurent RLaurent R Posts: 27
    edited 2009-04-10 13:36
    thanks Mike

    I resolved that problem by using stop cog in the main object...

    But that's a better solution

    Laurent
Sign In or Register to comment.