PINK: Seeing variable string value on website
Falcon
Posts: 191
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
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
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:
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:
Just a shot in the dark, but what you've shown here looks good. Let me know if any of that did anything.
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
<META HTTP-EQUIV="REFRESH" CONTENT="60">