-
During testing CC3000 and some other requires, sometimes the board stopped working and I had unplug to get it back to work.
After some testing, this workflow breaks Espruino- send code to Espruino Board
- wait to get IP adress
- disconnect from Espruino Board
connect to Espruino Board
Some secondes later I get the timeout error (4101).
Next another error comes up, "got '<' expected EOF at line 1 col 2...."
Version 1v50 and this sourcevar wlan = require("CC3000").connect(); var ip; wlan.connect( "JUMWARE-LTE", "B73FD193D04293D", function (s) { if (s=="dhcp") { ip = wlan.getIP().ip; console.log("My IP is "+wlan.getIP().ip); require("http").createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('IP is ' + ip + '<br>'); res.end(); }).listen(80); } });
- send code to Espruino Board
-
You can get the code by:
- right click in orange area on top of edit window
- in upcomin list click on 3rd item (in german element untersuchen), something like watch element
- you should now get a new chrome window
- click on console and you will see a lot
- at the end there should be something like Sending... clearInterval();clearWatch();setWatch(function() {.....
This is javascript which is sent to espruino.
You will see setTimeout and this is called 10 times, without waiting for completion before running loop next time.
- right click in orange area on top of edit window
-
Gave it a new try and got these numbers:
blinker object only, usage 50, history 37
3 blinker with object, usage 158, history 49
3 blinker with object, minified from 504 to 386, usage 149, history:31
3 blinker with require, usage 192, history:55
From my best understanding- the blinker object itself takes a few bytes only
- each instance with 4 variables(pin,duration,interval,status) takes around 600 bytes
- minifying reduces some bytes
require takes more memory than an object
Is there anything wrong with my interpretation ?function Blinker(pin,frequency){ this.interval = 0; this.status = true; this.duration = 1000 / frequency; this.pin = pin; this.start(); } Blinker.prototype.start = function(){ var me = this; me.interval = setInterval(function(){ me.status = !me.status; me.pin.write(me.status); },me.duration); }; Blinker.prototype.stop = function(){ this.pin.write(false); clearInterval(this.interval); }; var b = new Blinker(LED1,2); var c = new Blinker(LED2,5); var d = new Blinker(LED3,7);
- the blinker object itself takes a few bytes only
-
@Gordon,
I have in mind from an older response (http://forum.espruino.com/conversations/498/#comment5713) , that nightly build cannot be used directly for Espruino Board, because of missing Bootloader.
If this would be fixed, I would like to add a function to espruino_project.js to load from local drive. -
-
@Gordon, just tested uglifyjs and it doesn't handle 0b001.
I could not find any enabler in googles minify or uglifyjs to support 0b001/etc.
Pretty sure, this will change, but right now, there is no way.
If anybody knows better, please let me know.BTW uglifyjs could be the better solution compared to google minifier.
The way, how http://lisperator.net/uglifyjs/#demo supports clicking in minified code and see what this was in not modified code is great. To give one example only. -
@Kim, could you give an example which is not running after minifying. I would like to figure out, where the problems are. May be there is a way to "correct" this before sending to minify. 0b001... for example could be changed to 0x2.
-
Minifying sometimes has problems with handling requires and loading modules (Modules.-commands) The way this is minified by Google could be one reason for your problems. Same happens with binary data (0b0001...), which is also not know to minify.
May be we have to split minifying, to minify code only, not the modules. -
I have 1v47 from espruino/binaries on Espruino Board.
My understanding was the bug is for history only, sorry.
Already tested prototyping, this works fine and saves memory(about 20% less) even with the buggy calculation.
Anyway I will put any testing for memory consumption on hold, until next version is available, or we get a nightly build.
BTW, would it be possible to send mails around if new version is available ? -
Hello,
I tried it (see source) and got memory usage of 199, which is close to 4k or 3k by subtracting 4 bytes/block. Sourcecode is less than 400 bytes only.
Trace is not a help for me, my knowledge about that is too poor.
Checked memory-usage:- function Blinker only: usage is 60
- function Blinker with LED1: usage is 132
- function Blinker with LED1, LED2: usage is 199
- function Blinker with LED1, LED2, LED3: usage is 265
- used Blinker as module and required for LED1: usage is 178
- used Blinker as module and required for LED1, LED2: usage is 252
used Blinker as module and required for LED1, LED2, LED3: usage is 326
function Blinker(pin,frequency){ var me = this; me.iv=-1; me.status = true; me.dur = 1000 / frequency; me.stop = function(){ pin.write(false);clearInterval(me.iv); }; me.start = function(){ iv = setInterval(function(){ me.status = !me.status;pin.write(me.status); },me.dur); }; this.start(); } var b = new Blinker(LED1,2); var c = new Blinker(LED2,5);
- function Blinker only: usage is 60
-
Thanks a lot for this interesting answer, its very late, I appreciate this.
What I wanted to find with this question is the best way to write code.
There are at least two parameter, speed and size.
BTW, my next test used a module.
Base is an object called Blinker, which uses Interval.
Having LED1 to LED3 blinking in different frequency costs 175 blocks.
Same with function in modules takes more than 300 blocks.
Do you have a guide, something like "best architecture to save memory" ? -
process.memory() gives a total memory of 2000 and free of 1988 (after reset)
After sending a script with about 490 chars it gives free of 1841
Minifyied code has a length of about 270 and free returns 1875How should I interprete this numbers, bytes seem to be a wrong, and memory units(20 bytes) would be a lot (3000 bytes for 490 chars of code for example) .
dump() did not help either -
-
-
-
-
@Frida, great job and good point.
I will check my other boards next week, but have to solder them first -
@Kim, thanks a lot, often problems are located between the ears :-)
-
-
-
-
-
After taking a lot of care on USB port, I accidently pushed the SD card a little bit in the wrong direction. Its not broken mechanically. Has anybody a simple testroutine to see it working (hopefully).
Already tested a simple require, which stores something on SD, and that works. But I'm not sure this is a serious test. -
As far as I understand, DS18B20 is a serial device and A1/A0 are not serial ports, they are PMW/ADC, at least on Espruino Board.
Anyway, on my Espruino I tested same with port B7, and its not working.
Search failes to find the sensor.
Upgraded to 1v46 did not help.
Downgraded to 1v43 (r1.3) and it works, at least search works and I get a device back.
But 1V43 seems to have problems somewhere around "this", get an error that EOF was found where } was expected (???)
So this is not a solution for the problem.
On my board, this happens always after disconnect/reconnect.
May be I should mention, that I've also connected the display on SPI2 and a DS18B20.
Looks like reading process.env is broken after connecting.
If I disconnect it runs without this problem, at least the 6 hours in my test.