mBed crashes when using httpServer and UDP

24 May 2011

I have an application using three tx/rx UDP sockets that seems to work fine. I''m trying to add Donatien's httpServer into the code to provide a configuration interface. The application works fine until the web server is accessed whereupon it serves one page, even a simple html file and then the mBed crashes totally.

Now I suspect I have to do something with handling IP buffers better but has anyone any immediate suggestions ? I'd perhaps naively hoped the libraries just did this for me in the reserved extra RAM. Is there anyway I can see how much RAM is being used there and will the compiler warn me if I run out ?

I know example code would be helpful so I'm just reducing my code to the minimal that illustrates the issue. I removed all three UDP sockets and the remaining application code and the webserver work but as soon as I add one back it crashes. Without the webserver all three UDP sockets and the application are working fine.

I'm mid learning on mBed / C++ , but wrote a similar app on another embedded platform in ANSI C . Without runtime debugging this is proving quite difficult to track down.

K

PS Also noticing that from the webserver larger files are problematic - small jpg OK but larger one kills it.

31 May 2011

I have spent a while on this and everytime I think I'm moving forward I go back again, so a general question...

Is TCP/UDP reliable in the current libraries with multiple sockets / clients or should I await some updates and in the meantime use another platform ? As soon as I add multiple sockets or indeed use a simple webserver implementation with POST processing accessed by two different browsers near simultaneously but not coincident, it all dies. I am fairly sure there are no char array overruns in my code. Are there things I need to do to manage the IP buffers differently and is there documentation at all that might help me ?

It's probably me as I'm new to mBed and not very experienced in C++ but I did get this all working on another ANSI C platform with many simultaneous sockets. Just wanting a bit of reassurance that this should all work well using the current libraries and sample code.. so should I persevere ?

K

01 Jun 2011

Hi Kevin

The NetServices based stack is very useful in certain situations, but if you trawl the forum you'll see lots of issues as people try to push it. It makes extensive use of C++ STL which is a problem when memory management on the mbed is so limited. NetServices is also a case of form over function - you can plug in lots of things that the majority will never use, and performance goes out the window with that abstraction.

If you can avoid using NetServices and base your code on raw lwip then you'll have a good chance of something solid. It then depends on your appetite for dealing with raw lwip (some useful code in the contribs section of that project). It's possible that somebody will write a tighter implementation of a non-blocking sockets implementation on top of lwip as well, so you don't have to deal with raw lwip, but that is a little bit away yet.

Regards
Daniel

01 Jun 2011

Hi,

Just for information, have a look at this thread tittled Let's make TCP/IP really work on mbed!

I hope something will come out soon, I also desperately need a reliable udp/ip stack on mbed :)

Benoît.

04 Jun 2011

Thanks Benoît and Daniel,

I had seen the various other posts and inparticular that 'let's make TCP really work' one but I guess I wasn't sure they related to my paricular issue. It just seemed so basic what I was trying to do that I couldn't believe it was a library issue or that many more people hadn't posted about similar problems.

Anyway I've shelved my mBed networking project for the time being and reverted to the previous platform. I shall revisit it when the TCP thread concludes, I know Andy is working really hard on that. BTW I know I have long UDP packet payloads approaching 1500 bytes so if there is still a lower restriction in there then that would be one issue.

Kevin