PDA

View Full Version : PINK module online with test code



TimC
01-30-2006, 01:17 AM
Hi all,

I just got my Pink module this Saturday. This pup is FAST. Thought it would be best to share for a FEW days.

Have a look at:

71.192.248.146 (http://71.192.248.146)



Attached to the BS2p stamp is:
- One LED which can be changed from the web page (does work.. but slowly)
- TSL230 light sensor working great
- SHT1x TEMP/HUMID sensor. Working well but seems to pick up the warm regulator
- HTML links to webcams, weather in Boston MA


I have attached my code that changes the variables, Not great code but it works and includes mail and UDP broadcast example.

I would love to see a flag added to tell if the web page has been hit, the Red-i web server had this feature. Also since the SB70 has so much power why not add a HTTP GET function to feed to the serial port?? This way the stamp could search for tags within remote web pages.


Regards
Tim

Chris Savage
01-30-2006, 02:00 AM
Tim,

·· I'm surprised your equipment and even yourself can operate at such extreme temperatures!

The Temperature in the room is: 1139 Fahrenheit·· <-----From your page!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

TimC
01-30-2006, 02:17 AM
Amazing. I think this is called the demo factor. Everything works until you show it to someone!

The temp was showing 75-80F for the last 24 hours.

Last thing it did was delete the TMP* files on the FTP part of the PINK module because the ON/OFF icon was not showing.

The icon now shows on the web page but the temp and humid are bad within the Stamp variables.

Tim

ADDED: It's working. Just needed a little smack on the table.

Post Edited (TimC) : 1/29/2006 6:21:20 PM GMT

Ryan Clarke
01-30-2006, 05:19 AM
You could make an image to indicate an LED that is on, one that is off, and have the graphic tag change (via a PINK register) to have the status of the light reflected graphically.

:)

Ryan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support

RClarke@Parallax.com (mailto:RClarke@Parallax.com)

TimC
01-30-2006, 06:37 AM
Ryan,
You should see two different images that change with the LED status. They are the same ones from the old Red-i demo. Once or twice I have seen a small bar when the ON or OFF image does not get downloaded to the client browser.
What are you seeing?

Perfection would be if the user pressed change and the web page LED status would change without a redisplay. (:

Regards
Tim

stamptrol
01-30-2006, 09:22 AM
Tim,

Thanks for sharing! You're way ahead of me. I'm working to get only the data to be refreshed so the page doesn't have to be redrawn each time.

Tom

Peter Verkaik
01-30-2006, 09:22 PM
Tim ,do you ever receive an udp message?

In my pink it is status bit5 that is set when an udp
message is received, and it is received because I continuesly
read out the status and Nb_varBM and I see the message appear.
Status is then %00100001.

Can you confirm it IS bit4 of the status byte that is set after udp reception?

I noticed that status bit4 gets set after sending an email (I assume an empty udp message
is received from the smtp server, because Nb_varBM value is 0 bytes),
Whenever I send an udp message from the pc, status bit5 gets set (bit5 is undocumented).

I use the attached program to send udp messages to my pink.

regards peter

TimC
01-31-2006, 06:17 AM
Peter,
No I have not tried to recieve a UDP message on my PINK.

I downloaded your udpclient.exe and could not get it to work becasue I get a message box every time that says:

Message not set!


Check the variable update bit just in case there is an alignment problem in your status field. I assume you are showing a 1 on position 0 and 5:

%00100001

No this does not make sense to me either. When I send a UDP message no flag bits are set.

Regards
Tim

Peter Verkaik
01-31-2006, 07:41 AM
Tim,
Ryan Clarke once responded with:
· There is a separate status bit for UDP message waiting, vs. register updated.
· I'll give more detail when I get into the office (not in there yet, still at home!)
but he never got back to it. Perhaps he can answer it now.

The udpclient requires·Framework .NET v2.0
You can download this runtime package here
http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5&DisplayLang=en

regards peter

TimC
01-31-2006, 10:06 AM
Peter,
One idea to break the logjam would be to download and try my code at the top of this message.
The code worked fine with the Red-i web server, I just changed the tags to work for the PINK. So the UDP subroutines should work :)


I will find or write a Java UDP messager to test the code as well.

Maybe there is someone out there who has tried UDP on the PINK sucessfully??

Regards
Tim

Peter Verkaik
01-31-2006, 10:18 AM
Hi Tim,

I tried to receive UDP with the pink, and that works (sending udp also works btw).
I just noticed it was bit5 of the status byte that was
set upon receiving udp, not bit4 (and it is not misaligned).
Unfortunately I don't have a basic stamp available right now. I used a javelin.

regards peter

TimC
01-31-2006, 10:37 AM
Hi Peter,
Confirmed!
It is status bit 5 NOT 4. I sent up a trap for both and the 5th bit fired.

The Message: Hi Peter! is on the PINK Web site Now 9:30pm Eastern

Regards
Tim

Peter Verkaik
01-31-2006, 11:13 AM
Hi Tim,

Thanks for confirming that.
Now, can you also confirm that status bit4 gets set
after the pink sends an email? I noticed that too.
Wether that is a confirmation that the email has
been sent and accepted, or just sent, I don't know.

Nice website btw.
regards peter

Post Edited (Peter Verkaik) : 1/31/2006 3:16:01 AM GMT

DiablodeMorte
01-31-2006, 10:44 PM
TimC. I think i've already posted this but intead of using 2 webpages to show the status of the LED why not do something like:

<img src="<Nb_var10>.gif"> (I assume <Nb_var10> means display value)

That way you could have ON.gif and OFF.gif on your server and the browser would only see the picture you want(IE. only one webpage)

Ryan Clarke
01-31-2006, 11:38 PM
DiablodeMorte said...
TimC. I think i've already posted this but intead of using 2 webpages to show the status of the LED why not do something like:


<img src="<Nb_var10>.gif"> (I assume <Nb_var10> means display value)



That way you could have ON.gif and OFF.gif on your server and the browser would only see the picture you want(IE. only one webpage)


That is the scheme I prefer- the problem (potentially) is that you need a refresh for the new graphic to be displayed- be aware of that...

Ryan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support

RClarke@Parallax.com (mailto:RClarke@Parallax.com)

TimC
02-01-2006, 03:46 AM
Post not needed
Deleted
See my comments directly below
Tim

Post Edited (TimC) : 1/31/2006 9:15:22 PM GMT

TimC
02-01-2006, 04:31 AM
Thanks everyone for the help.
I have been populating Nb_var10 with On.gif and Off.gif from the beginning.
This is the -FORM- part of the HTML I am currently using:
--------------------------------------------------------------
<form method="POST" action="random.htm">
<center>
<font face="Comic Sans MS"> Signal LED will change after a HTML refresh. Aprox
Total Changes: <Nb_var20> . </font>
<pre><img src="<Nb_var06>" width="20" height="20" border="0"></pre>
<font face="Comic Sans MS">
ON <input type="radio" name="Nb_var10" value="ON">
OFF <input type="radio" name="Nb_var10" value="OFF">


<input type="submit" value="Change">
</font>
</center>
</form>
--------------------------------------------------------------

The problem as Ryan mentioned is I almost always have to do a redisplay.
So I added a 3rd web page that forces a redisplay and in javascript does the increment for the total LED changes
Now my Stamp code is smaller and faster because the LED count stays within the PINK.

On average it works about 95% of the time even WITHOUT a redisplay :)

DiablodeMorte you were the one that gave me the idea because I was using 2 web pages.
When I went back to 1 web page it got worse!


Regards
Tim

Peter Verkaik
02-01-2006, 05:31 AM
Tim,

You say:
On the debug console sometimes the stamp is just not seeing the variable change flag.
I am not sure if I should be speeding up the status query ["!NB0ST"] or waiting longer.

There is an issue with status I know off:
using Telnet I noticed the following:
When ready to send email I issue the send email command. Telnet says:

Received from Stamp: [!NB0SM]
Setting up to send E-Mail
Received from Stamp: [!N] Missformed message
Received from Stamp: [B]
Received from Stamp: [0]
Received from Stamp: [S]
Received from Stamp: [T]

Apparently Pink does not recognize the first getStatus command after sending an email,
and therefore the command getStatus will timeout, returning a timeout value to my main program.

Even a 1 second delay between the send email command and the getStatus command
does not resolve the error. The fastest way I have found is to force a Missformed message
by sending '!','X' directly after the send email command.
Following telnet session illustrates:

Diagnostic display of Stamp to Netburner I/O
type logout to exit the monitoring session
Received from stamp:[!NB0WEV:smtp.zonnet.nl<CLS>]
Set Var [EV] to [smtp.zonnet.nl]
Received from stamp:[!NB0WEC:directly typed text 2<CLS>]
Set Var [EC] to [directly typed text 2]
Received from stamp:[!NB0WES:pink email test 2<CLS>]
Set Var [ES] to [pink email test 2]
Received from stamp:[!NB0WEF:verkaik6@zonnet.nl<CLS>]
Set Var [EF] to [verkaik6@zonnet.nl]
Received from stamp:[!NB0WET:peterverkaik@boselectro.nl<CLS>]
Set Var [ET] to [peterverkaik@boselectro.nl]
Received from stamp:[!NB0ST]
Write Status value = 01
Sent to Stamp:[]
Received from stamp:[!NB0SM]
Setting up to send E-Mail
Received from stamp:[!X] Missformed message
Received from stamp:[!NB0ST]
Write Status value = 05
Sent to Stamp:[]
Received from stamp:[!NB0ST]
Write Status value = 01
Sent to Stamp:[]
Received from stamp:[!NB0RBM]
Read Var [BM] value is []
Send to Stamp:[<CLS>]
Received from stamp:[!NB0RBI]
Read Var [BI] value is []
Send to Stamp:[<CLS>]
Received from stamp:[!NB0REV]
Read Var [EV] value is [smtp.zonnet.nl]
Send to Stamp:[smtp.zonnet.nl<CLS>]
Received from stamp:[!NB0REC]
Read Var [EC] value is [directly typed text 2]
Send to Stamp:[directly typed text 2<CLS>]
Received from stamp:[!NB0RES]
Read Var [ES] value is [pink email test 2]
Send to Stamp:[pink email test 2<CLS>]
Received from stamp:[!NB0REF]
Read Var [EF] value is [verkaik6@zonnet.nl]
Send to Stamp:[verkaik6@zonnet.nl<CLS>]
Received from stamp:[!NB0RET]
Read Var [ET] value is [peterverkaik@boselectro.nl]
Send to Stamp:[peterverkaik@boselectro.nl<CLS>]
Received from stamp:[!NB0ST]
Write Status value = 11
Sent to Stamp:[]
Received from stamp:[!NB0RBM]
Read Var [BM] value is []
Send to Stamp:[<CLS>]
logout
GoodBye

The 1st status read after send email command returns status bit2 set (not ready to send email)
The 2nd status read after send email command returns status bit2 clear (ready to send email)
The 3rd status read after send email command returns status bit4 set (manual states received udp message)


Please check your telnet session very carefully for any missformed messages or if the variable change flag
is not set when you are sure that it must.

regards peter

TimC
02-01-2006, 06:49 AM
Peter,
What I did was to increase the ALL serial recieve timeouts to the SB70 to 250
Such as:
SERIN FromNB,Baud,250,Main_Loop,[RiStatus]

I also got rid of any delays in other parts of the code.
Overall the Web page is working a lot better than just 2 hours ago.

I see about 4 lines a second go by on the Telnet console, all status, variable requests and updates.
So I watched for about 10 minutes and I did not see a single problems. -phew-


I have now changed the app to send an e-mail when a UDP message is received.
Can start testing tonight or tomorrow without ever taking the web site down :)

Regards
Tim

TimC
02-01-2006, 01:54 PM
Peter
I have not been having any problem SENDING email but it is clear that we have a small problem from the telnet logs
Also my Subject line is not working.
Will take a fresh look at it in the morning.
Regards
Tim



My stamp debug output is as follows:
--------------------------------
Got RiStatus: 100001 .
UDP Rec! (bit5)
Entered Mail routine
mail command to send (SM) finished
Got RiStatus: 101 .
Email Buzzy.. (Bit 2)
Got RiStatus: 10001 .
Email Sent (bit4)!
--------------------------------


Telnet log: (the cross outs and bolding came from the PINK LOGS!)
--------------------------------

Sent to Stamp:[]
Received from stamp:[!NB0ST]
Write Status value = 01
Sent to Stamp:[]
Received from stamp:[!NB0ST]
Write Status value = 21
Sent to Stamp:[!]
Received from stamp:[!NB0BM!N] Missformed message
Received from stamp:
Received from stamp:[0]
Received from stamp:[W]
Received from stamp:[E]
Received from stamp:
Received from stamp:[:]
Received from stamp:[H]
Received from stamp:[e]
Received from stamp:[l]
Received from stamp:[l]
Received from stamp:[o]
Received from stamp:[:]
Received from stamp:[ ]
Received from stamp:[0]
Received from stamp:[<CLS>]
Received from stamp:[!NB0WEC:yes.txt<CLS>]
Set Var [EC] to [yes.txt]
Received from stamp:[!NB0SM]
Setting up to send E-Mail
Received from stamp:[!N] Missformed message
Received from stamp:
Received from stamp:[0]
Received from stamp:
Received from stamp:[T]
Received from stamp:[!NB0ST]
Write Status value = 05
Sent to Stamp:[]
Received from stamp:[!NB0ST]
Write Status value = 01
Sent to Stamp:[]
------------------------------------------

Peter Verkaik
02-01-2006, 02:30 PM
Hi Tim,
Sending email is no problem. The problem is the command following the sendEmail command.
This generates a missformed message response. My workaround is to enforce such a response
by using !NB0SM!X instead of !NB0SM as the sendEmail command. Any next command
then does not generate the missformed message response. Especially if the next command
is the getStatus command you can be assured you get the new status.

Also noticed your log confirms status bit4 gets set after sending email
whereas the manual states that bit4·identifies udp received (we already know
bit5 gets set for udp received).

regards peter

TimC
02-02-2006, 03:28 AM
Peter,
Confirmed: Status Bit 4 means the email has been sent.
Confirmed: Status Bit 2 is working as expected - set when busy sending e-mail
Confirmed: After the send mail command is issued the next command will fail. So to workaround the problem send a dummy message. (!X seems like a good choice)


In addition I found a new (small) problem:
-----------------------------------------------------------------------------------------------
SEROUT NBReceive, Baud, ["!NB0WES:Hello:",CLS] 'Load Subject
-----------------------------------------------------------------------------------------------
Will not work and will send a BLANK Subject line because of the final ":"
PINK seems to have a parse problem because
["!NB0WES:Hello:There",CLS] Works Fine


TELNET LOG:
-------------------------------------------------------------
Received from stamp:[!NB0WES:Hello<CLS>]
Set Var [ES] to [Hello]
Received from stamp:[!NB0WEC:yes.txt<CLS>]
Set Var [EC] to [yes.txt]
Received from stamp:[!NB0SM]
Setting up to send E-Mail
Received from stamp:[!X] Missformed message
Received from stamp:[!NB0ST]
Write Status value = 05
Sent to Stamp:[]
Received from stamp:[!NB0ST]
Write Status value = 01
------------------------------------------------------------

Regards
Tim

Peter Verkaik
02-02-2006, 06:46 AM
Hi Tim,

The closing ':' problem is new to me. I wonder if this only applies to
Nb_varES·or if it applies to all variables (I think it·applies to all vars).
Will a starting : also give problems: "!NB0WES::Hello",CLS

A possible·workaround is to use a replacement character for :
for example ; or the single quote.

So if your data contains a : then use ;

Upon reading the variable, you can change a ; back to :

regards peter

TimC
02-03-2006, 02:01 AM
All,

Just added a LIVE webcam image FTP'd to the PINK every 15 sec.


During the day the LED is very hard to see - but it is possible.
Do a redisplay to see LED change.
The power LED is to the left of the changing LED and can be seen all the time

Since my laptop is doing the upload, the FTP images will not be 24/7

Enjoy

Regards
Tim

steve_b
02-03-2006, 05:06 AM
That's cool!!

Anychance of sharing some code? I'd be interested to see how you got the camera image referenced or actually in the PINK!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·

Steve

"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."

Paul Baker
02-03-2006, 05:30 AM
He uses Webcam32 (http://www.surveyor.com/) to ftp a new picture (dynamic.jpg) to the PINK, the html code for the page is availible via View>Source in IE.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10

TimC
02-03-2006, 08:51 AM
Yes Paul you are right.
Using Webcam32 is the easy part. All I have to do is tell Webcam32 where the website is to send the jpg to. My Pink as a result gets pounded with all the inbound FTP traffic.

Steve, to do this yourself you would add a line like this:

<img src="dynamic.jpg" width=233 height=175 border=2 alt="Live Web Cam into PINK">

Regards
Tim

steve_b
02-03-2006, 09:04 PM
Very cool.
Did you have to buy their product to use their server?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·

Steve

"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."

TimC
02-04-2006, 01:09 AM
Yes Steve I purchased Webcam32 about 3 years ago.
I would choose a different product since the company no longer supports or updates the software.
In addition, Webcam32 needs a running PC which means lots of electricity to run 24/7.

If I were to start over again and had a little more cash I would try:
www.axis.com/products/video/camera/index.htm (http://www.axis.com/products/video/camera/index.htm)

Or for about $100 US you could get a D-Link DCS-900 10/100TX Internet Camera
www.dlink.com/products/?pid=270 (http://www.dlink.com/products/?pid=270)

Or for a real hobby experience this camera rocks:
www.acroname.com/robotics/parts/R245-CMUCAM2-PLUS.html (http://www.acroname.com/robotics/parts/R245-CMUCAM2-PLUS.html)

Have Fun!
Tim

steve_b
02-04-2006, 01:18 AM
I've got an AXIS camera. Haven't set it up....but it's direct TCP so it'll not require a pc!

At work we use a Flexwatch camera server. You can plug in your normal video feeds and it will display it on its built in webserver.
TCP configured as well.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·

Steve

"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."