Page 1 of 3

XC2 webserver

Posted: Tue Nov 23, 2010 12:47 am
by smuraski
Does anyone know how to modify the web pages served by the demo? I have tried changing the html files, but the web pages do not change that the XC2 serves. I have looked for documentation, but cannot find much of anything.

Re: XC2 webserver

Posted: Tue Nov 23, 2010 5:52 pm
by leon_heller
You might have to convert them with the Perl script makeData.pl.

Re: XC2 webserver

Posted: Wed Nov 24, 2010 12:00 am
by smuraski
How does perl script get used? Is this something that can be run from Windows? XDE?

Re: XC2 webserver

Posted: Wed Nov 24, 2010 12:07 am
by leon_heller
Strawberry Perl is a good Windows implementation:

http://strawberryperl.com/

Linux comes with a Perl.

Re: XC2 webserver

Posted: Thu Nov 25, 2010 2:06 am
by smuraski
I have been trying to perform this operation. I downloaded "strawberry perl". Rebooted. ran "perl makeData.pl" from command line within the "xmos_tcpip_1v3\app_xc2_firmware.1v3\src\httpd\web" directory/folder where "makeData.pl" exists in an unzipped format.

I searched my computer for files with the name "fsdata.c" which were modified same date as perl was run. No files found.

I am only trying to establish a proof of concept and really do not have time or desire to learn PERL. I just need to be make some basic changes to the web pages to match the intended target environment for a quick demonstration in order to get management approval to proceed forward. I have no intention of using the PERL method in the final product because I want to be able to dynamically load/modify HTML in final product.

Can someone please provide some quick guidance on the proper method to use the PERL script? Your assistance would be greatly appreciated.

Re: XC2 webserver

Posted: Fri Nov 26, 2010 11:33 am
by davelacey
There is a dsicussion about this on the xmos support forum:

http://www.xmos.com/discuss/viewtopic.p ... t=makedata

Re: XC2 webserver

Posted: Fri Nov 26, 2010 12:28 pm
by leon_heller
According to that, the Perl script works on Linux and generates the fsdata.c file OK, but it doesn't work on Windows. I couldn't get it to work, either.

Re: XC2 webserver

Posted: Fri Nov 26, 2010 12:57 pm
by RogerH
I have the following script running fine under windows and use this to update
web pages on my ARM (LPC2478) based uIP server.

Code: Select all

#!/usr/bin/perl

open(OUTPUT, "> httpd-fsdata.c");

chdir("httpd-fs");

opendir(DIR, ".");
@files =  grep { !/^\./ && !/(CVS|~)/ } readdir(DIR);
closedir(DIR);

foreach $file (@files) {  
   
    if(-d $file && $file !~ /^\./) {
	print "Processing directory $file\n";
	opendir(DIR, $file);
	@newfiles =  grep { !/^\./ && !/(CVS|~)/ } readdir(DIR);
	closedir(DIR);
	printf "Adding files @newfiles\n";
	@files = (@files, map { $_ = "$file/$_" } @newfiles);
	next;
    }
}

foreach $file (@files) {
    if(-f $file) {
	
	print "Adding file $file\n";
	
	open(FILE, $file) || die "Could not open file $file\n";

	$file =~ s-^-/-;
	$fvar = $file;
	$fvar =~ s-/-_-g;
	$fvar =~ s-\.-_-g;
	# for AVR, add PROGMEM here
	print(OUTPUT "static const unsigned char data".$fvar."[] = {\n");
	print(OUTPUT "\t/* $file */\n\t");
	for($j = 0; $j < length($file); $j++) {
	    printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
	}
	printf(OUTPUT "0,\n");
	
	
	$i = 0;        
	while(read(FILE, $data, 1)) {
	    if($i == 0) {
		print(OUTPUT "\t");
	    }
	    printf(OUTPUT "%#02x, ", unpack("C", $data));
	    $i++;
	    if($i == 10) {
		print(OUTPUT "\n");
		$i = 0;
	    }
	}
	print(OUTPUT "0};\n\n");
	close(FILE);
	push(@fvars, $fvar);
	push(@pfiles, $file);
    }
}

for($i = 0; $i < @fvars; $i++) {
    $file = $pfiles[$i];
    $fvar = $fvars[$i];

    if($i == 0) {
        $prevfile = "NULL";
    } else {
        $prevfile = "file" . $fvars[$i - 1];
    }
    print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
    print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
    print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
}

print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
print(OUTPUT "#define HTTPD_FS_NUMFILES $i\n");

Roger...

Re: XC2 webserver

Posted: Fri Nov 26, 2010 4:38 pm
by smuraski
Thank you Roger...looks a lot easier to decypher than the script included with the xc2...much appreciated.

Re: XC2 webserver

Posted: Sat Nov 27, 2010 11:39 am
by smuraski
I believe that there is an underlying issue with the script or PERL on a WindowsXP Pro machine...I compared the fsdata.c file from the zip distribution with those generated when the script is run and the the image files which contain 0x0D drop the first occurence of 0x0D...any additional occurences within a file do not get dropped. Does anyone know why this might occur? So far it only seems to affect image files...hard to believe that none of the HTML files have 0x0D data within them, although I have not searched these yet...I only ran a file compare on the individual sections and only concerned myself with the data that did not match...HTML files will be searched next to see if they contain the data.