I'm using Keil's RL_TCPnet HTTP server with an AT91SAM7XC512.
I'm trying to embed JQuery (jquery-1.4.2.min.js), however it appears that the FCARM tool is mangling the file. There are a number of characters (I'm guessing escapes of some sort) that are missing.
The original, uncompressed jquery-1.4.2.min.js is 72,174 bytes. When I download the file from the uC, the file size is 69,321 bytes.
Obviously, none of the jquery functions will work.
Any ideas?
There are a number of characters (I'm guessing escapes of some sort) that are missing.
Why guess when you can know for sure? Surely you have a file comparison tool. So use that to find out what exactly is missing.
Not only would you need that information to solve the problem yourself, but also to meaningfully ask for help about it (here or elsewhere).
What may get stripped - possibly without breaking the file - are multiple white-space characters to compress space and bandwidth. A number of tools exists to compress HTML pages etc.
What may also get stripped - most probably breaking everything - is break-encoded characters. Maybe \\ gets converted to \ and \\b gets converted to <bell>.
But as noted - no need to speculate when it's so easy to verify.
Apologies, my use of the word 'suppose' was misleading.
I have indeed used KDiff to examine the two files and identified the missing characters.
FCARM appears to strip text between '/*' and '*/' tags. For example, the file header comments are removed, along with a critical section later in the code.
For reference, here is the original JQuery (min) source file: http://pastebin.com/vLkFL5UM
Here is the file downloaded from the uC: http://pastebin.com/p5KA0Zxn
Referring to the first pastebin link (the original source file), the missing characters start on line 123, immediately after the '/*' characters. The closing 'tag' can be seen on line 128. All text in between is missing in the file downloaded from the uC.
In any case, short of manually modifying the original jQuery source file, is there a way to 'force' FCARM to ignore these tags?
FCARM appears to strip text between '/*' and '*/' tags
No "appears" about it. It obviously strips C comments from the input. As can be seen from the fact that the first 15 lines of your input file were removed from the output.
The problem is really quite obvious: the file compression phase of FCARM fails to properly recognize that the /* and */ sequences occur inside strings, where they are not evaluated by an actual HTML or JS parser, so they should be left alone.
To know for sure what actually happens, a look at the C file generated by FCARM would be necessary. Other than that, this really looks something to be taken up with Keil support.
Yes, the problem is clear; it is the solution that is proving to be somewhat elusive.
I will contact Keil support, however, in the meantime - what would you suggest I look for in the C file generated by FCARM?
The generated C file is essentially just 2 arrays - one array contains the raw byte data from the file(s), the other is a list of offset indices for each file.
Update: I manually extracted the raw byte data from the original jQuery file, then modified FCARM's generated C file accordingly (replaced the appropriate section in the raw data array and updated the file offsets).
Everything works properly.
So, short term I'll need manually edit FCARM's generated C file whenever I modify, add, or remove any of the other custom files associated with the web server.
Long term, it would be nice to see a fix for FCARM.
What is your FCARM version number?
It seems you are using an outdated version. Current version is 2.28
It's version 2.20. Has this issue been resolved in 2.28?
That was an early FCARM version with compression. I have checked the current FCARM release and seen no problems.
Excellent!
I've just downloaded RL-ARM v4.12 from the file download area. The FCARM version appears to be v2.27.
I'll extract it and give this version a go.
Is v2.28 available for general release?
v2.27 resolves the issue with the '/*' and '*/' characters, however, there still appears to be an issue with spaces inside quoted strings in javascript.
For example,
Original: match = " " + match[1].replace(/\\/g, "") + " ";
After FCARM: match=""+match[1].replace(/\\/g,"")+"";
The first " " and last " " need to remain as-is for the expression to remain the same.
Hi, As for jQuery the better way for embedding in app. is to let the browser download from static high bandwidth host such as google rather than from web server itself (ajax.googleapis.com/.../jquery.min.js), since it consumes your internal flash image and hard to maintain an updated version of jQuery.
I hope keil solve the problem for web server in SD card also, since it appears unable to reference the file in subfolder of SD card (root only), therefore limits the number of file access in root directory and hard to maintain files in group.
kom.
I agree with your point about using the google link for the jQuery file, however, in my case the end user is unlikely to have an internet connection (they'll typically be on-board a ship at sea).
I've got 512KB of flash to play with, so there is plenty of space available to embed the library.
Along with some of the regular jQuery niceties, I'm using 'flot' to plot some runtime variables. http://code.google.com/p/flot/
This is not true. I have added your code:
match = " " + match[1].replace(/\\/g, "") + " ";
to your javascript file JQuerry.js (http://pastebin.com/vLkFL5UM)
and this is the FCARM output:
((function(A,w){function ma(){match=" "+match[1].replace(/\\/g,"")+" ";if(!c.isReady){try{s.documentElement
As you can see, the spaces inside a quoted strings are not removed.
What exactly did you do?
Keep in mind I'm using FCARM v2.27 - this is the version packaged with the latest release of RL-ARM (4.12) available on the Keil web site.
My process is as follows:
1. Use FCARM to convert the jQuery file.
2. Download to the uC.
3. Visually confirm proper functionality of the jQuery library by accessing the embedded web page. I'm using Firebug to view error messages. In my case, it's easy to see if things are working or not - if yes, there are 6 real-time charts on the page, if not, there is nothing.
4. Download the jQuery-1.4.2.min.js file directly from the embedded web server, and compare against the original file.
With version 2.27, the downloaded file differs by 16-bytes from the original.
Here is another example:
Original:
g[4]=" "+g[4]+" ";
After FCARM:
g[4]=""+g[4]+"";
.replace(/ /g,"&")}}
.replace(//g,"&")}
Here is the 'after FCARM v2.27' jQuery that I downloaded from the uC: http://pastebin.com/BctHu6sg
To resolve the issue, I have been replacing the FCARM-generated bytes (for the jQuery file) in 'Web.c' with a manually-generated byte array.
Thanks again for your assistance!