EspruinoWiFi - UDP / Broadcast not stable #4620
Replies: 1 comment
-
Posted at 2018-03-11 by Sacha "listening" is not implemented. Espruino code reduced to:
Posted at 2018-03-12 by @gfwilliams Thanks for the steps to reproduce. Just tried it here and I got it to happen once, missing the last 2 characters. No corrupted IP though. Please can you try adding Posted at 2018-03-12 by Sacha Thanks Gordon Without the debug enabled, i get the error and crash within a few minutes. I enabled debug to my projectcode. It shows the wrong ip's, fragments of the udp messages and crashes very fast. I think it makes no sense to post the projectcode. It to big. Here is the output. I only add a console.log of the UDP ip, port and message received. Starting with "UPD Msg: " The correct source ip is 192.168.68.13
Posted at 2018-03-12 by Sacha It's a bit frustrating. I waited so long for that feature ;-). My fealing is that there are two problems. First that something is mixed up resulting in wrong data. Wrong IP and trancated messages. The second problem, truncating the last chars is resulting in a crash. Like on the last line above. Sacha Posted at 2018-03-12 by Sacha I enabled turbomode in the isolated code and the mixed up data is shown up. I was able to catch debug code. Did not crash.
Posted at 2018-03-12 by Sacha Next test in isolated code. Turbomode enabled debug not enabled. It crashed too.
Posted at 2018-03-12 by Sacha Last message for today Gordon.
The last message was truncated to. Not two chars. I think you should be abe to reproduce it with my isolated code. Just change the linux server to 100ms and enable debug on the espruino side. Posted at 2018-03-13 by @gfwilliams Thanks for all your work checking this out! You seem to be having the exact same issues I had - that normal debug mode pretty much fixes it (I left it going for hours and it didn't crash). It was a great idea to try turbo mode. I've checked the code and I think I know what the problem is now. The actual C based UDP code always assumes that it has the whole UDP packet - but the JS code provides the data in chunks as it is received. The code handles the first packet totally fine, but then if there are only a few bytes left, when then remainder arrives there's a buffer overflow and it crashes. I'm working on a fix for this now that should improve the native UDP handling. Posted at 2018-03-13 by @gfwilliams Ok, builds from http://www.espruino.com/binaries/travis/master/ should now have the fix in. Seems to work reliably now and to always report the right host address, however there are still sometimes missed bytes from the end of UDP packets - but at least you can filter that out. Posted at 2018-03-13 by Sacha Hi Gordon Posted at 2018-03-13 by IanET Funny, I was just about to post a similar UDP issue and so far it looks like this fixes it! Posted at 2018-03-13 by Sacha Hello Gorden
Thanks Gorden for fixing the crash that fast. Sacha Posted at 2018-03-14 by @gfwilliams Thanks - surprising you get the corruption that bad... For me it was 1 in 100 packets or so. I'm away at the moment but I'll see if I can figure out what's wrong when I return - probably next week. Posted at 2018-03-14 by Sacha That's fine Gordon. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2018-03-11 by Sacha
Hi Gordon
I try to use the new UDP/Broadcast feature. First to receive UDP packages/messages.
Here is the code on the serverside, nodejs on linux. It sends a small JSON string every 10 seconds:
Please replace "BROADCAST_ADDR" with yours.
Please start it with node:
node test.js
And now, this is the code running on EspruinoWiFi. Please replace your WLAN SSID and PW:
Please type "save" on the EspruinoWiFi.
Espruino receives packets. They are often corrupt, not complete or even from a wrong IP Address ??
It's a question of time, then the espruino is crashing.
Thanks for your help.
Sacha
Beta Was this translation helpful? Give feedback.
All reactions