Shop OBEX P1 Docs P2 Docs Learn Events
Trouble referencing variables from other objects to send data. — Parallax Forums

Trouble referencing variables from other objects to send data.

Michelle S.Michelle S. Posts: 5
edited 2010-04-19 02:04 in Propeller 1
To anyone who may be able to help smile.gif,

I'm trying to send my temp/humidity data that i collected using my modified SensirionDemo1 object and Sensirion subroutine object, thru my 433MHz RF Transceiver. Using the Transceiver TX Demo object and RF_Transceiver subroutine object to send my data. The Transceiver RX Demo object and RF_Transceiver subroutine object to receive my data. I want my data to look the same in the Parallax Serial Terminal on the receiving end, as it looked when i used my modified SensirionDemo1 object. The problem I'm having is that when i added some strings to the Transceiver TX Demo object shown below. It keeps giving me an error " expected expression term" and highlighting the word "rawtemp". I think "rawtemp" is a variable. Can one top object access another top object's variables?

The original Transceiver TX Demo object, The original RF_Transceiver subroutine object, my two most resent modified Transceiver TX Demo object and the Transceiver RX Demo object are attached below. Also, my original modified SensirionDemo1 object, the Sensirion subroutine object and my two most resent modified SensirionDemo1 objects are attached below. If you can respond as soon as possible. I would be very grateful!!!

Thank You Very Much for your time and help.

MichelleS



{{ TransceiverTXDemo1.8.spin}}

CON

  _CLKMODE = XTAL1 + PLL16X
  _XINFREQ = 5_000_000

  PacketLength  = 32             'Total Number of data BYTES   'Changed packetlength from 11 to 32.

OBJ
                                                                               
RF      :       "RF_Transceiver"
fp      :       "FloatString"
f       :       "Float32"
sht     :       "Sensirion"
sen     :       "SensirionDemo1.6"

{PUB sen.  rawTemp
 rawTemp := f.FFloat(sht.readTemperature) 'Tried to make "rawTemp" accessible to PUB TX_Main. }

PUB TX_Main
    RF.Initialize(PacketLength)
    sen.Start
    repeat
      RF.PutTXString(String("Hello World"))                     ''<-- Loads Transmit buffer
      RF.PutTXString(String("      Temp:"))
      RF.PutTXString(sen.main(rawTemp := f.FFloat(sht.readTemperature))
      RF.PutTXString(fp.FloatToFormat(rawTemp, 5, 0))
      RF.PutTXString(String("   RH:"))
      RF.Send                                                   ''<-- Sends Transmit buffer


Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-19 02:04
    There is no direct way to reference the variables from one object in another object. You also can't just take a demo program and treat it as a "child" object for some other program. The demo programs are simply not written to be used that way. For example, "rawTemp" is a local variable in the method "main" in SensirionDemo1.6. You can't even reference that from outside the call to "main".

    You're better off using cut and paste to take routines from any demo program and paste them into your own program, then modify them as needed to work with your overall needs.
Sign In or Register to comment.