Shop OBEX P1 Docs P2 Docs Learn Events
PINK: Seeing variable string value on website — Parallax Forums

PINK: Seeing variable string value on website

FalconFalcon Posts: 191
edited 2011-07-30 14:44 in BASIC Stamp
I'm enjoying the PINK but can't get a string to show on a simple web page.

I'm using this BS2 code to write the strings to the PINK:

RX PIN 14 ' Serial Receieve Pin --> PINK.TX
TX PIN 15 ' Serial Transmit Pin --> PINK.RX

'
[ Constants ]

Baud CON 396 ' 2400 bps (BS2)

'
[ Variables ]

index VAR Byte ' Index Variable
nbvar VAR Byte ' PINK Data Variable

'
[ EEPROM Data ]

String1 DATA "Garage Door OPEN", 0
String2 DATA "Garage Door CLOSED", 0

'
[ Program Code ]

Main:
SEROUT TX, Baud, ["!NB0W20:"] ' Command To Write Variable 20
GOSUB WriteString ' Read DATA/Write PINK Data

SEROUT TX, Baud, ["!NB0W21:"] ' Command To Write Variable 21
GOSUB WriteString ' Read DATA/Write PINK Data
END

'
[ Subroutines ]

WriteString:
DO ' Start Of LOOP
READ String1 + index, nbvar ' Read Current Character
index = index + 1 ' Increment Index (Offset)
IF nbvar = 0 THEN EXIT ' Check For End Of String
SEROUT TX, Baud, [nbvar] ' Send To PINK
LOOP
SEROUT TX, Baud, [CLS] ' Terminate String Command
RETURN

I can see that the variables do update on the PINK when I run that code to update the SYSTEM VARIABLES page. So that much works.


This is the html for the web page:

<html>
The value in variable 20 is: <Nb_var20>
<p>
The value in variable 21 is: <Nb_var21>
</html>

When I reload the above html code I only see this:

The value in variable 20 is:

The value in variable 21 is:

Is there a different method for string data?

I have inputs to my BS2 that monitor the position of the garage door so, with the web page, I can check it with my Droid X from anywhere.

falcon

Comments

  • xanatosxanatos Posts: 1,120
    edited 2011-07-16 12:42
    OK... me and my dumb questions again :-)

    First, the web page you are using is resident in the PINKs Flash memory, correct? Not sitting on your desktop or something? :-) Sorry...

    Your html looks fine. I do this all the time to monitor MANY conditions for exporting into big Excel files:
    <TR><TD BGCOLOR="#ddeedd"><P><B>09:</B> <Nb_var29></P></TD></TR>
    

    The data that - in my example - would be shown in Nb-var29 is 2011/07/16 19:00, which is definitely a string.

    If you CAN see the variables containing the string with the SysVar page, and not your HTML... either it's somehow not looking in the right place, or there's something else that it requires from the inquiring code.

    Just for the heck of it, try filling out your HTML a bit by adding head & body tags, as in:
    <html><head></head><body>
    The value in variable 20 is: <Nb_var20>
    <p>
    The value in variable 21 is: <Nb_var21>
    </body></html>
    

    Just a shot in the dark, but what you've shown here looks good. Let me know if any of that did anything.

    Dave
  • FalconFalcon Posts: 191
    edited 2011-07-29 23:47
    xanatos (Dave),
    I did have the file on the PINK, but I think I messed up by not closing it and opening it again after the variable changed. It all seems to work now.

    A follow-up question: Is there an html code that I can add to my webpage that will cause it to update itself once a minute? I can view the page on my Android Droid X, but changes are only updated when I manually refresh the page. BTW, this is not an Adroid app, I'm just viewing it via a web browser.

    Thanks for your help with this,

    falcon
  • Mike2545Mike2545 Posts: 433
    edited 2011-07-30 14:44
    This code snippit should update refresh your page every 60 seconds.

    <META HTTP-EQUIV="REFRESH" CONTENT="60">
Sign In or Register to comment.