Shop OBEX P1 Docs P2 Docs Learn Events
Objects out of scope — Parallax Forums

Objects out of scope

PaulPaul Posts: 263
edited 2008-09-22 19:10 in Propeller 1
I have a program that has two objects:

OBJ
BS2: "BS2Functions" and
SNMP: "SNMP".

I found I need to call a BS2 function (SHIFTOUT) from the SNMP object. The manual indicates this is out of scope.

Whats the best way around this? Add another BS2Function object to SNMP object?

I can't actually do this because SNMP has FullDuplexSerial as an object and there are conflicts about DEBUG pins.

How about copy and paste just the SHIFTOUT code into SNMP? (too kludgy?)

stumped again.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki Rocks! - propeller.wikispaces.com

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-22 03:33
    You could certainly cut and paste the SHIFTOUT code into SNMP. There are a couple of constants that SHIFTOUT references that you'd have to add to SNMP as well. I've done this sort of thing myself when I needed just one or two routines from BS2Functions. It works very nicely. You could even simplify SHIFTOUT since you're probably only using one case (LSBFIRST or MSBFIRST) and the number of bits transferred is probably fixed.
  • hippyhippy Posts: 1,981
    edited 2008-09-22 11:02
    Paul said...
    Whats the best way around this? Add another BS2Function object to SNMP object?

    I can't actually do this because SNMP has FullDuplexSerial as an object and there are conflicts about DEBUG pins.

    Doesn't the conflict only arise if you try to use the conflicting resources and isn't that potentially the case anyway should SNMP and BS2Function compete ?

    The only problem you're likely to have is if you need interaction between the top-most BS2Function and the BS2Function which is a sub-object of SNMP. That depends on how BS2Function is coded but if what you need to call is a self-contained, standalone method there shouldn't be any problems.
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-09-22 13:30
    I had an application where I had more than one object using the same UART interface different levels. I created a singleton version of FDS by moving all variables·from the VAR section to the DAT section. That way, all instances of the FDS object in the program share the same data - in effect they are all the same instance. Also, note that multiple instances of an object use the same code in memory. Only the VAR section is duplicated. But in this case since all variables are in DAT it uses very little if any additional memory.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
  • PaulPaul Posts: 263
    edited 2008-09-22 19:10
    Thanks to Mike, Hippy and Ken.

    Yes there was a conflict because I usually ran some 'debug' statements in both the main and SNMP modules. things would get clobbered sometimes.

    I've copied the SHIFTOUT to a local PUB and added the associated constants. Everything is working ok.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki Rocks! - propeller.wikispaces.com
Sign In or Register to comment.