Newbie Ethernet trouble

08 Dec 2009

Hi guys, I know I'm probably being very, very stupid here, but I'm trying to use the HTTP Client library and I'm not getting anywhere!

I have Orange stripe going to 'RD-', Orange to 'RD+', Green stripe to 'TD-' and Green to 'TD+' but when I boot my mbed the LEDs flash the outer pair then the inner pair repeatedly and nothing seems to happen! What is my mbed trying to tell me?

Thanks in advance

08 Dec 2009 . Edited: 09 Dec 2009

Hi,

That pattern of LEDs flashing is the Blue Lights of Death (BLOD).. you get them when there is a runtime error.

Runtime errors are often caused by things like pin misconfigurations, see http://mbed.org/handbook/Debugging for more details.

If you dont mind sharing, right click on your project in the compiler, click "publish", and post the URL you get to this thread. We'll be able to see your code and suggest what might be wrong.

Cheers,
Chris

08 Dec 2009

Thanks! I should have checked simpler code first - my code is now published here so you have have a look if you like but I'll have a go at debugging it myself!

08 Dec 2009

Wow, that is pretty hardcore for a first program :-)

I was expecting to see something obvious, but this need to be looked at a bit more closely!

When you get the BLOD, you also get some output on the USB serial port, so you could try hooking up a terminal program and seeing what the runtime error is... might also help to have some printf debug...

Take a look at http://mbed.org/handbook/SerialPC

Cheers,
Chris

08 Dec 2009 . Edited: 08 Dec 2009

Hehe, yeah it is a little optimistic! I think I've figured out why it's throwing a tantrum - the maths following the http.get works with the received httpdata, so if none is received then it'll complain.

I am however finding that

http.get("http://stuff",httpdata);


works but

char url[80] = "http://stuff";
http.get(url,httpdata);

doesn't! I've only just gotten this far so I'm still playing around, but if there's an obvious reason you can spot then let me know! (Will the HTTPClient tolerate the \00 padding of the string? My C is rusty :S)

 

EDIT: I'm working through the HTTPClient examples and it'll get fixed soon enough, probably with a little bit of sleep :P

 

Thanks for your advice, I'll get the USB port hooked up to get some debug output!

08 Dec 2009 . Edited: 09 Dec 2009

I originally posted about strong termination as i'd had problems with that myself. On closer examination it's probably not that - now that i've got the bottom of why my program was going wrong with string termination.

Since the topic has raised here and will appear in future searches, it seems a good idea to set the record stright about strings.

Example 1 :

http.get("http://stuff",httpdata);

This examples call http.get with two character pointers, one to a location in readonly flash memory, and one in RAM. The Flash memory wil lhave initialised by the compiler which understands string representation and so will have.terminated correctly.

 Example 2 :

char url[80] = "http://stuff";
http.get(url,httpdata);

In this example url is a pointer to the first of 80 characters in RAM. It is being assigned from a string literal in flash which will also have been terminated correctly when the compiler created, so a correctly terminated string will be copied to url.

 Example 3 :

char url[80];
int val = 42;
sprintf(foo,"http://stuff/bar.php?arg=%d",val);

In this example url is also a pointer to the first of 80 characters in RAM, and when sprintf formats the string and places it in url , it will also be terminated correctly.

Example 4 : (the one I got wrong) 

char url[80] = {'h','t','t','p',':','/','/','s','t','u','f','f'};



In this example url is still a pointer to the first of 80 characters in RAM, but it is not being assigned with a string, the contents are being manipulated manually.  In this scenario there is no string termination, and so a printf of url would show the string described followed by the (most likely random) content of the rest of the array.

This is the scenario in which adding a null terminator after the last character would be important if the array was to be treated as a string later.

Hope that helps clear things up about strings.

Cheers,
Chris

09 Dec 2009

I've editted my previous posts in this thread to clear up some facts abotu strings and terminations.

It looks like the problem is the instance of I2C

I2C i2c(p28,p27);

The constructor for I2C is :

I2C (PinName sda, PinName scl);

The pin numbers are the wrong way around, try :

I2C i2c(p28,p27);

Thanks,
Chris