Shop OBEX P1 Docs P2 Docs Learn Events
Newbie question : How to use PC_debug in multiple object — Parallax Forums

Newbie question : How to use PC_debug in multiple object

steamboysteamboy Posts: 2
edited 2007-03-26 21:44 in Propeller 1
Hello,

I am trying to put debug statement in my code using PC_debug. I am defining the Object PC_debug in my top level object with "debug : "PC_debug"".
So I am able of course to do debug statement in this object. But what is the best way to do debug statement in child object using the same PC_debug object.
How a child object could see an upper object ?

Thanks for your help,
Best Regard
Christophe

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-26 21:11
    Christophe,
    It is messy to use an object like PC_debug in more than one object. It can be done. Easiest if you just want to use it in the top level and one lower level is to define it in the lower level and provide some PUB routines to export the PC_debug functions to the higher level. In the lower level object you'd have:
    OBJ debug : PC_debug
    PUB deb_start(Baud)
       debug.start(Baud)
    
    PUB deb_out(char)
       debug.out(char)
    
    PUB deb_newline
       debug.newline
    
    PUB deb_dec(value)
       debug.dec(value)
    
    


    and so on for any of the debug routines that you need at the higher level. At the higher level, if you had 'OBJ low : "lower_level"', you'd call "low.deb_start(9600)" or something similar, then "low.deb_dec(5500)" and "low.deb_newline" or whatever you need.
  • steamboysteamboy Posts: 2
    edited 2007-03-26 21:44
    Thanks for your advice. But this method only works for an object tree without branches. Is it possible in spin to have an object with a global scope (I didn't find a way in the documentation)?

    Best regards,
    christophe.
Sign In or Register to comment.