Shop OBEX P1 Docs P2 Docs Learn Events
Displaying the Cog ID started by the cognew command ? — Parallax Forums

Displaying the Cog ID started by the cognew command ?

JMLStamp2pJMLStamp2p Posts: 259
edited 2008-02-14 11:39 in Propeller 1
I have used the Methods on page 118 of the Prop. manual and want to
display the Cog_ID·of a new Cog started ·on my serial LCD display. I am using FullDuplexSerial to send the serial data to the display but a little confused about how to display the "Success" varible below·that is returned. Am I right in that the Success varible will hold the number of the Cog started and return that to my Main Method upon exiting ? Does this mean that I have to assign a varible in the OBJ. that contains my Main method ? And if so, could someone give me an example of how to display it via my LCD.
Note: I am using, data.start(1,0,2,9600) To write to the LCD.
Thanks,
JMLStamp2p

............................................
Method Containing Main below
............................................
CON
·_CLKMODE = XTAL1 + PLL16X···
·_XINFREQ = 5_000_000········

VAR

OBJ
·GO: "Sloss Timer Program_TX"

PUB Main
·GO.Start


....................................................
Method that Starts a new Cog below
....................................................

VAR
·long Stack[noparse][[/noparse]9]
·byte Cog

OBJ
·DELAY: "Clock"
·DATA: "FullDuplexSerial"
......................................................................................................·
PUB Start : Success··········· ·'The varible Success Returns the # of the Cog
········································' Started to Main after the Method exits.

·Stop
·data.start(3,2,0,1900)·········· 'Start Cog-1 to handle FullDuplexSerial
·data.rxflush

·Success := (Cog := cognew(Toggle(Pin,Delay,Count), @Stack)+ 1 )
····························· 'Start Cog-2 to handle Toggle
......................................................................................................·

Comments

  • JMLStamp2pJMLStamp2p Posts: 259
    edited 2008-02-14 00:32
    The following seemed to have done it. If someone sees a problem in this please correct me.
    JMLStamp2p
    ..................................


    PUB Main| Success

    GO.Start

    Success := GO.Start

    data.start(3,2,0,19200)
    data.dec(Success)
  • tpw_mantpw_man Posts: 276
    edited 2008-02-14 11:39
    That is the correct way to do it. Good job!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1010, so be surprised!
Sign In or Register to comment.