Shop OBEX P1 Docs P2 Docs Learn Events
Need some help figuring out this mess... trying to transfer a message — Parallax Forums

Need some help figuring out this mess... trying to transfer a message

Don MDon M Posts: 1,652
edited 2013-03-07 16:15 in Propeller 1
Lets say I have a Main cog running something like this:
var

  byte  message[128]

pub

  term.start(31, 30, %0000, 115_200)
   
  object_in_own_cog.start(@message)

  repeat
    if message[0] <> 0
      repeat idx from 0 to 128
        term.tx(message[idx])
      term.tx(13)
      bytefill(message, 0, 128)  


And the statement "object_in_own_cog.start" starts an object in it's own cog like this:
PUB Start(MasterMessage) :okay 

  stop
  
  subobject1.start
  
  subobject2.start
  
  okay := cog := cognew(method(MasterMessage) ,@Stack)+1

pub method(MasterMessage)


  if something_happens
    bytemove(MasterMessage, @mess, 34)


dat

mess  byte  "Message to display in Main program"  ' 34 chanracters



I'm trying to pass messages from the child object running their own cog whenever something happens so that the Main program will just "pick up" the message and print it when it happens.

I can get the child object to run ok on it's own but I never get any messages passed.

I know I'm missing something here trying to understand how this works or if it's even possible. Or if there is a better way of doing something this this.

Thanks.
Don

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2013-03-07 16:15
    Assuming your sub object start methods don't block anything the issue is with the main object. bytefill should take an address (@message). And printing the string could be done better with term.str(@message). Right now - while you print some characters - you also print the remaining zeros from the array which is usually interpreted as clear screen within PST.
Sign In or Register to comment.