-
• #2
Updated Version 2 May 2016
allObjects gave me some pointers about object constructors, making the object methods exist only once for the object and not in each instance and the use of the keyword “bind” when starting intervals.
http://forum.espruino.com/conversations/286055/
These lessons are applied to this project.
It has been pointed out that using eval() is a security problem. Having commands in the object being shipped over an open channel is also a security problem. I hope to further rework this code to address this issue.
The output:>echo(0); N,Date,Time,A0,A1,A2,A3,Board Temp C,Board Temp F, Test End =undefined 1, 2 4 2016, 14:51:40, 0.81, 31.39, 0.73, 0.71, 35.39, 95.33 2, 2 4 2016, 14:51:41, 0.80, 32.57, 0.74, 0.72, 35.37, 95.33 3, 2 4 2016, 14:51:42, 0.82, 33.57, 0.75, 0.72, 35.37, 95.33 4, 2 4 2016, 14:51:43, 0.85, 34.69, 0.75, 0.72, 35.39, 94.88 5, 2 4 2016, 14:51:44, 0.87, 35.77, 0.76, 0.73, 35.18, 95.27 6, 2 4 2016, 14:51:45, 0.87, 35.79, 0.76, 0.73, 35.18, 95.33 7, 2 4 2016, 14:51:46, 0.88, 36.50, 0.76, 0.73, 35.18, 95.27 8, 2 4 2016, 14:51:47, 0.88, 36.94, 0.76, 0.73, 35.39, 96.10 9, 2 4 2016, 14:51:48, 0.88, 37.35, 0.77, 0.73, 35.18, 95.27 10, 2 4 2016, 14:51:49, 0.89, 37.26, 0.77, 0.73, 35.58, 95.66 >
Testlog8.js is attached.
1 Attachment
On the Client side HTML and script is used to construct and edit the following object:
Notice several methods are used to scale the analog inputs using a slope/offset (intercept).
The Client script stringifies the object and sends it after the HTTP POST header.
On the Server side the HTTP header is used to determine that the client request is a post and that the Filename in the HTTP header matches “LOG”.
The stringified object is buffered using the Length in the HTTP header.
At this point I’m testing the code to process the request. It writes to console.log instead of a file.
The JSON.stringify() doesn’t work with embedded methods. The transmitted LogObj1 object is JSON.parsed into the LL field of the LogObj object.
The code that executes the LogObj follows:
The “eval()” command is not used and each Client request creates a new LogObj.
The left side screen using WebIDE:
Notice that the Test function ends after the CSV headers are printed but before the data are printed.
1 Attachment