-
• #2
Sorry, and to follow up, any ideas why this code does not work ? It's the CC3000 code transplanted (which does work when the CC3000 is behaving). The .248 address is pingable, but port 80 is not there (I did a port scan). No errors reported ..
E.enableWatchdog(10); var eth = require("WIZnet").connect(); eth.setIP({ ip : "192.168.254.248" }); eth.setIP({ dns : "208.67.222.222" }); eth.setIP({ gateway: "192.168.254.100" }); function onPageRequest(req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write('<html><body>'); res.write('<p>Button is '+(BTN.read()?'on':'off')+'</p>'); res.write('<p>Turn LED1 <a href="/on1">on</a> or <a href="/off1">off</a></p>'); res.write('<p>Turn LED2 <a href="/on2">on</a> or <a href="/off2">off</a></p>'); res.write('<p>Turn LED3 <a href="/on3">on</a> or <a href="/off3">off</a></p>'); res.end('</body></html>'); if (req.url=="/on1") digitalWrite(LED1, 1); if (req.url=="/off1") digitalWrite(LED1, 0); if (req.url=="/on2") digitalWrite(LED2, 1); if (req.url=="/off2") digitalWrite(LED2, 0); if (req.url=="/on3") digitalWrite(LED3, 1); if (req.url=="/off3") digitalWrite(LED3, 0); } require("http").createServer(onPageRequest).listen(80);
-
• #3
Oh dear. All sorts of oddities ...
On a high proportion of occasions now when I issue eth.setIP() I see a single DHCP_DISCOVER message, and then a few seconds later the USB connection to the Espruino drops (COM port gone, warble from computer). Tried on a couple of different boards. Repeatable. Strange ! Began to suspect USB cable, but happens on several different ones.
On some (rare) occasions I get a successful DHCP round trip
_____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v61 Copyright 2014 G.Williams >echo(0); =undefined >eth.setIP() > Send DHCP_DISCOVER > Receive DHCP_OFFER > Send DHCP_Request > Receive DHCP_ACK =true >eth.getIP() ={ "ip":"192.168.254.194", "subnet":"255.255.255.0", "gateway":"192.168.254.100", "dns":"208.67.222.222", "mac":"000000000101" } >
but a strange mac address (ending 01:01)
In fact, I have wireshark running to monitor what I think is the correct mac address (00:08:dc:1d:4c:33) and there is no DHCP to be seen. Is it all happening on that 01:01 address ??
Stuck again. Any ideas?
-
• #4
I'm really not sure about the DHCP - could be be that it starts off in the wrong subnet/gateway? You could try setting it up to something basic first.
Also, not that it matters I guess but I'd try doing:
eth.setIP({ ip : "192.168.254.248", dns : "208.67.222.222", gateway: "192.168.254.100" });
not
eth.setIP({ ip : "192.168.254.248" }); eth.setIP({ dns : "208.67.222.222" }); eth.setIP({ gateway: "192.168.254.100" });
Did you get an HTTP get working first, so you know if it's connecting properly?
I'm pretty sure I did something almost identical when testing and that worked fine.
-
• #5
This code ..
E.enableWatchdog(10); var eth = require("WIZnet").connect(); eth.setIP({ ip : "192.168.254.248", dns : "208.67.222.222", gateway: "192.168.254.100" }); var http = require("http"); http.get("http://www.espruino.com", function(res) { res.on('data', function(data) { console.log(data); }); });
works once and the console fills up with the HTML returned. If you try to run again, you get
reset();
=undefined
....
1v61 Copyright 2014 G.Williams
echo(0);
=undefined
ERROR: Socket error -7 while sendingSo sort of heading in the right direction. Totally mystified by the DHCP behaviour really. Can't persuade the server code to work at all.
-
• #6
Well, the good news is that this has been running now for 20 hours or so (continuous ping) without a blip :)
Still getting DHCP funnies, the Socket error -7 above and unable to create a server, though ...
-
• #7
Strange about the server. The Socket error -7 is something I was hoping WIZnet would get back to me on - but if you wait 30 seconds between GETs you shouldn't have a problem.
-
• #8
Hi, is the server thing likely to be me doing something wrong? Ditto DHCP .. or is it possible there are some bugs lurking. On the Socket error -7 front, it is only apparent if I execute the whole script again. If I just run the http.get onwards it will work a number of times and eventually give up with an ERROR: No free sockets found, at which point my COM port disconnects, I get the disconnect warble from my PC. Have to Reset or Power Off/On at that point.
Perplexed.
-
• #9
Hmm. Could you be doing subsequent HTTP GETs before the last ones have finished?
I don't know about the DHCP - when I tested it, it worked (as did servers). I guess it's possible that something has regressed recently :(
-
• #10
I am not having any luck with the WIZ550io myself. The DHCP deal with eth.setIP() seems to mostly work (although the MAC address is never correct) but it does grab a valid IP, and set the Subnet, Gateway & DNS appropriately. I can then ping it without issue. If I use a port scanner, I can see that port 80 is open right after I flash code to the Espruino but if I scan a couple of times the port will eventually be closed and if I actually try and point a browser to the IP the port will close immediately. If I try to use another port, such as 8080, it will never show up as open. I've been trying to use the simple code below without success?
var eth = require("WIZnet").connect(); var http = require("http"); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end("Hello World"); }).listen(8080);
If I try to do an http.get I just get the "Socket error -7" message.
I have two duplicate setups and I get the same results with both.
I've been using the latest binary located at http://www.espruino.com/binaries/git/commit_date/2014-04-14%2019:20:19%20+0100/espruino_1v62_espruino_1r3_wiznet.bin
Any ideas?
-
• #11
I'm afraid I don't have much of an idea - that does look correct though.
I'll take another look at it - however I'm really busy getting stuff ready for the Maker Faire, so probably won't get a chance for the next 2 weeks I'm afraid.
-
• #12
Hi, well you got further than me on the DHCP front. I'll have another go. But I never got the server working, in fact I was never sure I got port 80 open at all, but will take a look again.
-
• #13
I don't believe I ever got the server working either... port 80 seems to be open by default right after I send code to the Espruino... even if I have my code set to listen on another port such as 8080 (like in my example) it will be port 80 that is open temporarily?
Basically, the WIZ550io is pretty much useless with the Espruino as-is... which is a bummer for me because it is the last piece of the puzzle for my project I am working on.
-
• #14
Ditto. A real shame, as it looked so promising. I had actually been trying to get the CC3000 working, which it sort of did, but was very unreliable. However, the server code did work (when the CC3000 was working).
-
• #15
Rock solid Ethernet/Wifi communication with support for nativ sockets as we have in the arduino world as an example is something i miss too.
I hope that Gordon will find the time to improve this.
Sacha
-
• #16
Yes, I will try and sort this out - however I'm a little overworked at the moment ;)
In the mean time if anyone wants to help out, that'd be appreciated...
By the way, I'd be interested to know how stable CC3000 in Arduino really is - they're using the CC3000 driver almost as-is, which means that any communications issue or lockup in the CC3000 will cause the Arduino to freeze completely.
-
• #17
I still cannot get DHCP to behave .. this code
E.enableWatchdog(10); var eth = require("WIZnet").connect(); eth.setIP({ ip : "192.168.254.248", dns : "208.67.222.222", gateway: "192.168.254.100" }); var http = require("http"); http.get("http://www.espruino.com", function(res) { res.on('data', function(data) { console.log(data); }); });
Works up to a point. If I execute the get 6 times (one after another) .. manually .. so I wait for the get to complete .. they all work and pull the html back correctly.
The 7th time (always) I get "ERROR: No Free Sockets Found" and about 5 seconds later, the Espruino COM port disconnects from the PC. Have to reboot. I sometimes see a huge number of SPI TimeOut on TX messages before the COM port dies, but most often not.
-
• #18
I thought this used to be more reliable...
Recently, I remember a few issues with SPI (the one that was discovered with the PCD8544 on hardware SPI vs software SPI) - Were those issues deep enough into the Espruino code that they could have effected communication with Wiznet/CC3000? (ie, i'm wondering, could the problems we see now be a result of previous hacks to try to make it work before the SPI issue had been discovered)
-
• #19
Hmm, don't know. There are definitely occasions (like this) where something very bad happens that I presume is causing a significant crash on the Espruino to the point where the COM port disconnects.
-
• #20
The SPI issues were at the JavaScript API level, and CC3000/WIZnet are one step lower than that - so there shouldn't have been an issue.
I know about the GET issue on WIZnet (it was reported elsewhere) - it's because it's trying to find a free 'socket'. The WIZnet chip has 8, and they should be free after a GET completes. Did you do the GETs in quick succession? I was pretty sure I tested it, but I probably did so with maybe a minute between each GET - with that kind of delay the socket probably would have timed out and returned to its original state.
-
• #21
Yes, I did do them one after another. I'll try with a longer gap and report back !
-
• #22
I think the general thing is, I'm keen to get a really rock-solid CC3000/Wiznet (or something else totally) talking to the network.
-
• #23
I know... Believe me, I want that too! It's frustrating about the DHCP + Server issues, because that worked fine for me last time.
Perhaps I tested server, and DHCP, but not both at the same time.
WIZnet themselves said they'd give it a try and would contribute any changes they came up with, so I wasn't giving the W5500 huge priority... However it looks like they've forgotten about it now so I'll have to do it :(
I'd thought that the eventual CC3000 hang was due to some issues I'd had with the internal timer, but it seems not. That one's especially frustrating because I tend to have to leave it running for hours on a debugger before the problem manifests itself.
-
• #24
Gordon, I am so sorry to add to the pressure :( I wish I knew enough/was smart enough to actually help fix the problem, but I'm afraid my Rocket Scientist days are long gone ! The CC3000 is better now, but still crashy. It may be that a firmware upgrade would help, but the process is hideous and I have not attempted it. Perhaps I'll just have a few strong coffees and go for it !
-
• #25
Well, 99% of people are going to use the old firmware, so I need to be able to support it reliably. Whatever happens, power cycling the CC3000 should be able to bring it back to life - so there's definitely a bug in Espruino somewhere if it hangs.
It will get done eventually - but probably not this or next week given how much is going on!
I'm surprised that the Watchdog timer didn't manage to fix the reliability issues when enabled though? That should have reset Espruino at a very low level if anything bad happened.
Have given up on the CC3000 for now, just cannot get it to behave nicely for a decent extended period. Received a WIZ550io today and am running against the 1.61 Wiznet build.
Basically working, but I cannot get eth.setIP() to DHCP nicely ..
I see ..
After this, I see ..
I am 100% sure my DHCP is working, so am a bit lost. Resetting the board and executing the following code works fine ..
and I then see
So my question is, where could the problem be ?
ARP -A on my (sorry, um, Windows) PC shows ..
192.168.254.148 00-08-dc-1d-4c-33 dynamic
So that mac address is being seen, but those DHCP_DISCOVER requests are not working for reasons I don't follow yet.
TIA!