Pages: [1]   Go Down
Author Topic: DHCP library  (Read 1893 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

15 years since i did any programming  and this is my first post so go easy on me.
I have the ethernet shield and have tried the example sketches which work when i alter the hard coded ip addresses.

Next step see if i can get Jordan Terrel'ls DHCP library to grab an ip address, but the example that comes with it 'WebClientWithDHCP' just wont compile. I get:-

/Users/tom/Documents/Arduino/libraries/ArduinoDHCPv0/Dhcp.cpp:361: error: 'Sn_CR_RECV' was not declared in this scope

I went looking for the definition for 'Sn_CR_RECV' and its in w5100.h
looking in 'Dhcp.cpp' i see that 'w5100.h' is included right at the top as follows

// DHCP Library v0.3 - April 25, 2009
// Author: Jordan Terrell - blog.jordanterrell.com

extern "C" {
  #include "types.h"
  #include "w5100.h"
  #include "sockutil.h"
  #include "socket.h"
  #include "spi.h"
}

probably something simple but i cant see what it is

Thanks in advance
Tom
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46240
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I don't have that particular library, or example sketch, so I'm just shooting in the dark, but...

There is a quirk of the Arduino IDE that determines what gets compiled and included. Only include files that are included in the sketch (or are included in files included in the sketch) seem to be available for inclusion by code being compiled.

Does the sketch include the w5100.h file? If not, does anything change if you include it?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks paul for your input, i did think of that myself but no joy
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

bit more experimenting

this code compiles no surprise...

Code:
#include <Ethernet.h>

void setup ()
{}
void loop ()
{}

but this does not it gives the same error as the dhcp client example

Code:
#include <Ethernet.h>
#include "Dhcp.h"

void setup ()
{}
void loop ()
{}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46240
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where did you get the DHCP library?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Jordan Terrel's website here

I am a mac user do you think that any difference to the way things compile?
« Last Edit: August 13, 2010, 12:27:41 pm by tombo » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46240
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is that error the only one you get? I downloaded the library and compiled it using Arduino 0018, on Windows XP. I get a lot more errors than that one.

Which Ethernet library are you using?

[edit]I figured out my problem. I was supposed to add the DCHP library to the Ethernet library, not to a separate library. When I did that, it compiled with no errors. So, now I have to ask what board you have. I have a Duemilanove. I don't know if it makes any difference.[/edit]
« Last Edit: August 13, 2010, 06:40:53 pm by PaulS » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

woohoo! got it compiled and it works!!!

Paul,thanks so much for taking the time to try this for me.

I had sort of tried to install the library within the Ethernet folder but i had not been as thorough as i should have been. Your success meant that that was the correct approach.

For the record this is what i did to get it to compile for a Duemilanove on a Mac

Jordans library contains the main dhcp code and a utility subfolder with some basic networking code. Copy all code and header files to:-

/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet

copy the DHCP example to

/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/examples

I still have a lot to learn...

Though i have it working, is this the correct way to do it? Jordan must have created the utility folder for a reason, why do i have to move the files out of that folder
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46240
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Ethernet library also contains a utility folder. The DHCP/utility files should go in Ethernet/utility.

However, the Arduino IDE is relatively flexible in searching for include files, so it might not strictly be necessary.

It's why Jordan "created" a utility folder, though. I'm sure his library (DHCP.cpp and DHCP.h) was developed in the Ethernet directory structure, and then the DHCP specific files were extracted into their own zip file fir distribution.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Paul,

you are correct, I moved the util.c/.h and sockutil.c/.h to the ethernet utility folder and it works also

Thanks again
« Last Edit: August 14, 2010, 10:14:23 am by tombo » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone,

I just installed the DHCP library and when I compile I get a error message EthernetDCHP.h : No such file pr directory In function 'void setup()':In function 'void loop()':  I looked in the library and the header and cpp files are there. Has anyone ran into this?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46240
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I just installed the DHCP library and when I compile I get a error message EthernetDCHP.h : No such file pr directory
This is telling you "Hey, I can't find this file". It (typically) means that you did not install the library in the right place.

Did you restart the IDE after installing the DHCP library? In the IDE, using Sketch + Import Library, can you import the DHCP library?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  Re: DHCP library
Reply #11 - Today at 00:15:31 |    Quote:

I just installed the DHCP library and when I compile I get a error message EthernetDCHP.h : No such file pr directory
This is telling you "Hey, I can't find this file". It (typically) means that you did not install the library in the right place.

Did you restart the IDE after installing the DHCP library? In the IDE, using Sketch + Import Library, can you import the DHCP library?  


Yes I can import the libraries but I have error messages now out the wazoo Only when I import the EthernetDHCP library. Alot of the messages are multiple definitions. I have each one as its own library the EthernetDNS EthernetBonjour EthernetDHCP. Do I have to merge the DHCP with one of the other libraries?
« Last Edit: September 11, 2010, 07:11:30 pm by jkb3792 » Logged

Pages: [1]   Go Up
Jump to: