EthernetNetIf repeated setup attempts and strings via RPC (and general NetServices issues)

19 Nov 2010 . Edited: 19 Nov 2010

Dear all

If you've called setup on EthernetNetIf and had a failure (eg. cable not connected or DHCP not ready), you'll have found that you couldn't call setup again in a loop until success; it would just lock up on the second attempt.

This meant that on setup failure you would have no choice but to reset the mbed - not very desirable IMO.

I've debugged the code and think I've fixed it - it's a problem in lwip where the timer list (not even fully used) is not initialised properly. I've also modified the setup method to clean up if already called previously. With the new code, repeated failed calls to setup don't seem to cause a memory leak on the main memory (tested using AvailableMemory function).

I'll update the library here soon, I'm also going to add access to the mac address of the ethernet interface in use.

If anybody has got any other useful fixes to Donatien's stack then please let me know. I've already added ability to set hostname under DHCP, fixed a bug in NTPClient, and added proper URL decoding to the RPCHandler of HTTPServer - and most importantly utilised the AHBSRAM1 memory bank rather than main memory for the lwip memory pools.


19 Nov 2010

I've updated the library and sample hello world program at

The sample program now includes a test of the RPC string decoding. You can enter a string like the following into a browser:

http://<mbed ip>/rpc/echo/run "quoted string with <>"

It will get encoded in the browser address bar as follows:

http://<mbed ip>/rpc/echo/run%20%22quoted%20string%20with%20%3C%3E%22

The echo function prints it back to the browser (and also the USB serial) in the decoded version:

"quoted string with <>"

With the test program, it can be started with the ethernet unplugged, and then plugged in after a few timeouts.

19 Nov 2010

It would nice to have a way to turn debugging statements on and off at run time, rather than having to recompile.

It's probably way more work than it's worth, though.