Most recent activity
-
Thank you Gordon for your helpful reply, it (your example) still is not working and "hangs" the espruino. I even put the whole thing into an onInit function without success:
function onInit() { var eth = require("WIZnet").connect(); eth.setIP({ ip : "192.168.0.10" }); var data = JSON.stringify([{ topic: 'espruino', messages: ["199-hello\nldskjfds"] }]); var t = setInterval(function() { console.log("Write should be done every 2 seconds"); //ws.send(data); }, 2000); var WebSocket = require("ws"); var ws; setTimeout(function() { ws = new WebSocket("192.168.0.6",{ port: 8080, protocolVersion: 13, origin: 'Espruino', keepAlive: 30 // Ping Interval in seconds. }); ws.on('open', function() { console.log("Connected to server"); //Send message to server ws.send(data); console.log("Sent first time"); }); ws.on('message', function(msg) { console.log("MSG: " + msg); }); ws.on('close', function() { console.log("Connection closed"); }); }, 10000); // I extended this to 1o secs to see what below setInterval function delivers } setInterval(function() { console.log("Halo"); }, 1000); onInit();
The output is as follows:
Halo
Halo
Write should be done every 2 seconds
Halo
Halo
Write should be done every 2 seconds
Halo
Halo
Write should be done every 2 seconds
Halo
Halo
Write should be done every 2 seconds
Halo
Halo
Write should be done every 2 seconds
Connected to server
Sent first timeSo as long as ws = new WebSocket("192.168.0.6",... is not executed times work well and the event loop runs, but after 10 Seconds ws is created the ws.on("open", ... is executed correctly but afterwards the espruino hangs and does not execute any more, as well as I have to plug usb out and in again to renew the script. To me it seems on ws.on("open",... the event loop gets blocked.
Another thing I encountered is on the general Info page (http://www.espruino.com/Notes) it says:
If you create a function called onInit, that will be executed too:
In my case I needed to run the function manually otherwise onInit did not get fired (see last line).
Thanks for your help!
Best regards Manuel
-
-
Hello Gordon,
thanks for your wonderful work, I love this javascript based hardware (use it for home automation). Unlikely with one problem concerning websocket.My espruino is monitoring some temperatures which I would like to stream via websocket to my dataserver. I tried some firmwares (also the latest cutting edge espruino_1v84.155_espruino_1r3_wiznet.bin) but have issues with it. Generally this latest version feels better then the older ones, but it freezes my espruino console on the left side of the Chrome IDE (it is not possible to type something into it, I use ist for reset() sometimes).
My test script (as attached) is basically websocket trying to use setInterval every 2 seconds. If you run it with commented websocket part (line 17 - 37) the timer works and the script gets read in completely. If you uncomment lint 17-37 the setInterval timer never gets to run and the last console.log on line 40 sometimes shows up sometimes not (on startup).
The espruino "hangs" as I wrote above and needs to be plugged out and in again every time I want to flash a new script. But the websocket connection is correctly set and also the first message (line 27 ws.send(data); is showing up on the dataserver)I really tried a lot of things and for me it looks like there is a problem with the event loop, maybe this ws.on('open',... ) never finishes and blocks the event loop (would explain the odd behaviour of the timer/console.logs).
It would be great if you have an idea to put me in the right direction to solve this issue (I hope I haven't missed something and the problem is all mine).
Many thanks and a happy / successful 2016!
Best regards, Manuel
var eth = require("WIZnet").connect(); eth.setIP({ ip : "192.168.0.10" }); var data = JSON.stringify([{ topic: 'espruino', messages: ["199-hello\nldskjfds"] }]); var t = setInterval(function() { console.log("Write should be done every 2 seconds"); //ws.send(data); }, 2000); var WebSocket = require("ws"); /* var ws = new WebSocket("192.168.0.6",{ port: 8080, protocolVersion: 13, origin: 'Espruino', keepAlive: 30 // Ping Interval in seconds. }); ws.on('open', function() { console.log("Connected to server"); //Send message to server ws.send(data); console.log("Sent first time"); }); ws.on('message', function(msg) { console.log("MSG: " + msg); }); ws.on('close', function() { console.log("Connection closed"); }); */ console.log("Script read in completely");
-
@DrAzzy: Thanks I'll definitely try your solution next time.
Sure networking has lots of different conditions which adds many layers of possible issues. I'm glad it's that easy to set IP's manually though, which works under my circumstances. -
Dear Gordon,
thanks very much for the great project and the quick answer. Fortunately I now have a working version.
Maybe some hints for anyone struggling to make wiznet working:
I have to tell it was a little more tricky than I had expected (my ubuntu phyton had no clue what serial Module is (so i had to sudo apt-get install python-pip and afterwards sudo pip install pyserial) to make all phyton dependencies working.
That being said it was able to build the new firmware which I desperately put on a webserver in order to get an url to use for the ChromeApp Firmware Updater. Didn't work this way (and crashed Espruino), but was able to restore original firmware. Afterwards using make serialflash worked perfectly...http://www.espruino.com/WIZnet says to use dhcp you only need:
eth.setIP();
This didn't work for me (no connection was set up, there was an error "no sockets free" and App and Esprunio need a restart to work again afterwards), so I finally put in all params by hand (see below), which is my solution after some hours and a little bumpy ride this time.
var eth = require("WIZnet").connect(); eth.setIP({ ip: "192.168.0.205", dns : "8.8.8.8", subnet: "255.255.255.0", gateway: "192.168.0.254" }); setTimeout(function() { console.log(eth.getIP()); var http = require("http"); http.createServer(function (req, res) { res.writeHead(200); res.end("Hello World, here may come some json!"); }).listen(80); }, 10000);
Thanks for all the hard work, maybe there is a little room for improvement to get wiznet Moduls working as easy as reading temperatures via ADC or the one-wire sensors (which is insanely genius) .
-
Dear Espruino Fans,
after some quick wins with my Espruino I thought "now let's use it for real things" and ordered some Wiznet LAN modules to get connected. Connecting the pins seems quite simple but I'm struggling quite some time to get the Firmware compiled.
I used - like Gordon told - :
git clone https://github.com/espruino/Espruino.git
cd Espruino
make
And this works, but (as http://www.espruino.com/WIZnet says)...
WIZNET=1 RELEASE=1 ESPRUINO_1V3=1 make
is not working.CC libs/filesystem/fat_sd/fattime.o make: arm-none-eabi-gcc: Command
not found make: *** [libs/filesystem/fat_sd/fattime.o] Error 127I downloaded the Compiler from the first post of this thread (mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/).
Now it builds correctly, but fails because it gets too big:LD espruino_1v68_espruino_1r3.elf GEN espruino_1v68_espruino_1r3.lst
GEN espruino_1v68_espruino_1r3.bin bash scripts/check_size.sh
espruino_1v68_espruino_1r3.bin FAIL - size of 224324 is over 215040
bytes make: *** [espruino_1v68_espruino_1r3.bin] Error 1 make: ***
Waiting for unfinished jobs.... Build failedI'd be happy if someone could help me figure out how to get WizNet LAN working on my Espruino.
Best regards, Jack
-
-
My dear Espruino users,
I have 2 Espruinos to monitor some temperatures and to set some relays for home automation. One wire communication for temperature sensors works like a charm. Thanks for all the great work!
Unlikely I have one issue I can't sort out (and maybe I'm not the only one out here). I have connected the Espruino to my Raspberry Pi (as well as my ubuntu notebook before) and wanted to build a small webserver which outputs the sensor data as json object.
As stated out in http://www.espruino.com/Internet the Espruino should have Internet on Linux (and Raspberry) out of the box.I used standard http server module:
var http = require("http"); http.get("http://www.espruino.com", function(res) { res.on('data', function(data) { console.log(data); }); });
but Espruino is telling me it has no internet connection. USB connection from Raspberry to Espruino is working > I'm able to set LED's and send Scripts via minicom to Espruino.
I'm thankful for any advice.
Dear Jack
P.S. Raspberry itself has of course a working internet connection ;-) Just to be sure.
I checked my dataserver running on 192.168.0.6 port 8080 and this nodejs part works as expected (it even gets the initial data sent on ws.on('open') perfectly, and also saves data from other sources too). Maybe I have time to check your code in the WebSocket library, like I mentioned above I think it dies there (or maybe it needs an acknowledge message from dataserver to finish).
I cannot confirm that there is a timeout which ends the blocking (waited 15mins or more).
Tanks for your clarification about onInit.