XC2 webserver

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
smuraski
Member++
Posts: 20
Joined: Fri Oct 22, 2010 3:06 pm

XC2 webserver

Postby smuraski » Tue Nov 23, 2010 12:47 am

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.
User avatar
leon_heller
XCore Expert
Posts: 546
Joined: Thu Dec 10, 2009 10:41 pm
Location: St. Leonards-on-Sea, E. Sussex, UK.

Postby leon_heller » Tue Nov 23, 2010 5:52 pm

You might have to convert them with the Perl script makeData.pl.
smuraski
Member++
Posts: 20
Joined: Fri Oct 22, 2010 3:06 pm

Postby smuraski » Wed Nov 24, 2010 12:00 am

How does perl script get used? Is this something that can be run from Windows? XDE?
User avatar
leon_heller
XCore Expert
Posts: 546
Joined: Thu Dec 10, 2009 10:41 pm
Location: St. Leonards-on-Sea, E. Sussex, UK.

Postby leon_heller » Wed Nov 24, 2010 12:07 am

Strawberry Perl is a good Windows implementation:

http://strawberryperl.com/

Linux comes with a Perl.
smuraski
Member++
Posts: 20
Joined: Fri Oct 22, 2010 3:06 pm

Postby smuraski » Thu Nov 25, 2010 2:06 am

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.
User avatar
davelacey
Experienced Member
Posts: 104
Joined: Fri Dec 11, 2009 8:29 pm

Postby davelacey » Fri Nov 26, 2010 11:33 am

There is a dsicussion about this on the xmos support forum:

http://www.xmos.com/discuss/viewtopic.p ... t=makedata
User avatar
leon_heller
XCore Expert
Posts: 546
Joined: Thu Dec 10, 2009 10:41 pm
Location: St. Leonards-on-Sea, E. Sussex, UK.

Postby leon_heller » Fri Nov 26, 2010 12:28 pm

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.
User avatar
RogerH
Active Member
Posts: 55
Joined: Fri Oct 15, 2010 12:14 am

Postby RogerH » Fri Nov 26, 2010 12:57 pm

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...
smuraski
Member++
Posts: 20
Joined: Fri Oct 22, 2010 3:06 pm

Postby smuraski » Fri Nov 26, 2010 4:38 pm

Thank you Roger...looks a lot easier to decypher than the script included with the xc2...much appreciated.
smuraski
Member++
Posts: 20
Joined: Fri Oct 22, 2010 3:06 pm

Postby smuraski » Sat Nov 27, 2010 11:39 am

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.

Who is online

Users browsing this forum: No registered users and 1 guest