jordixou wrote:Hello,
I've been trying to make a widget that reads data received from the serial port. I'm trying to do so using a perl cgi that reads the serial and formats the data as a xml file.
If I manually create a xml file with the data generated from the perl script in a regular server I can access the xml from the widget without any problem, but if I place the very same file in the chumby it doesn't work. I think it may have something to do with the crossdomain file, but i just placed a crossdomain.xml file in /www without any luck at all.
The only difference I've noticed accessing to the file in my server and in the chumby is that firefox shows the first one as an xml file and tries to download the second one.
Anyone knows how to solve this?
Thank you
hi jordixou,
not quite sure what your problem is but I already do the activity you your trying to do so maybe have a look at follow approach i use.
I use a single CGI script to return the data and the crossdomain file - its just called with different parameters.
heres a sample CGI
#! /usr/bin/perl
#
# get the arguments in the URL
#
$request = $ENV{'QUERY_STRING'}; # get the URL parameters
$request =~ s/\%20/ /g; # unencode spaces - may need other later
@fields = split/\?/, $request; # split into seperate arguments
$fields[0] = uc($fields[0]); # convert to upper case
if ($fields[0] eq "FILELIST") #URL get a file list
{
print "Content-type:text/xml\r\n\r\n";
print "\<\?xml version=\"1.0\" encoding=\"utf-8\"\?\>\n";
print your XML file here BLAH BLAH BLAH
print "<USBFiles>\n";
}
if ($fields[0] eq "POLICY") # URL get policy
{
# send the crossdomain policy file
print "Content-type:text\/xml\r\n\r\n";
print "<\?xml version=\"1.0\"\?>\r\n\r\n";
print "<\!-- my crossdomain file -->\n";
print "<cross-domain-policy>\n";
print " <allow-access-from domain=\"\*.chumby.com\" \/>\n";
print "<\/cross-domain-policy>\n";
}
Then in the actionscript
I have 2 http requests as follows.
System.security.loadPolicyFile("http://"+ipaddress+"/cgi-bin/custom/photos.pl?POLICY");
filelist.ignoreWhite = true;
url = "http://"+ipaddress+"/cgi-bin/custom/photos.pl?FILELIST?" + grepargs ;
filelist.load(url);
first sets up the crossdomain file (policy)
second actually get the data.
hope this helps
cheers
Nigel