Saturday, March 19, 2011

My First Chumby Widget

So here is my first Chumby Widget:

video

This is some pretty simple Actionscript. Now, to try to use XML sockets, this Actionscript appears to work:

var xmlSocket:XMLSocket=new XMLSocket();
xmlSocket.onConnect=function() {
xmlSocket.send(new XML("Hello, World!"));
}
xmlSocket.onXML=function(myXML) {
trace(myXML.firstChild.childNodes[2].firstChild.nodeValue);
xmlSocket.close();
}
xmlSocket.connect("localhost",6666);

And on the python side:

>>> from socket import *
>>> s=socket(AF_INET,SOCK_STREAM)
>>> s.bind(('localhost',6666))
>>> s.listen(1)
>>> conn,addr=s.accept()
>>> conn.recv(1024)
'Hello, World!\x00'

Now I just need to have the Chumby widget XML socket messages control Firmata transmissions to contol the Arduino.

Followup: Well, the Actionscript and Python worked fine on my laptop, but a Chumby Widget needs a proper "crossdomain.xml" served out for the pair to work...see the next post!

No comments: