Pages: [1]   Go Down
Author Topic: Adding ethernet library from the arduino IDE results in multiple #includes  (Read 578 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 4
Posts: 289
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I went to add the ethernet library from the Sketch -> Import Library -> Ethernet and I get the following list of #includes in my sketch:

Code:
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>
#include <util.h>

Has it always been like this?  I am just setting up a small webserver to pass instructions from my android phone to the arduino over the internet.
« Last Edit: September 02, 2012, 05:46:56 pm by jerseyguy1996 » Logged

Arduino Uno;
Mega328

Offline Offline
Full Member
***
Karma: 2
Posts: 219
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i dont know if it always has been like it, but from programming perspective it seams good.
You see all libraries for various sub parts of TCP/IP setup.

As a programmer you can decide if you really want them.
For example if you use a static IP adress you can omit DHCP by put a mark in front of it //
And most services dont rely on udp, as most connections are tcp
udp is for broadcasting and packets can be missed without problems  (used in voice over ip youtube etc).

DNS well ... you might try to mark it out and see if your code still works.
Not sure if you need it, its a lookup service to get a remote IP, but your connecting clients allready have an ip adres so as long as your solution doesnt have to resolve www.somewhere.com/my.data.jpg  etc.. it might work without it.

And if your solution only has a server role (providing data on request)..a client might not be needed too.

So despite i dont have a network add on, from a programmers look it makes sense, and its perfect
as now you can mark out the code you dont need, and thereby use less memory on the arduino
« Last Edit: September 02, 2012, 05:20:38 pm by PGTBOOS » Logged

0
Offline Offline
Sr. Member
****
Karma: 4
Posts: 289
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i dont know if it always has been like it, but from programming perspective it seams good.
You see all libraries for various sub parts of TCP/IP setup.

As a programmer you can decide if you really want them.
For example if you use a static IP adress you can omit DHCP by put a mark in front of it //
And most services dont rely on udp, as most connections are tcp
udp is for broadcasting and packets can be missed without problems  (used in voice over ip youtube etc).

DNS well ... you might try to mark it out and see if your code still works.
Not sure if you need it, its a lookup service to get a remote IP, but your connecting clients allready have an ip adres so as long as your solution doesnt have to resolve www.somewhere.com/my.data.jpg  etc.. it might work without it.

And if your solution only has a server role (providing data on request)..a client might not be needed too.

So despite i dont have a network add on, from a programmers look it makes sense, and its perfect
as now you can mark out the code you dont need, and thereby use less memory on the arduino

Thanks!  Given that I know very little about what I am doing I suspect that I will just leave it all in and hope that the compiler optimizes all of the unnecessary code away.
Logged

Arduino Uno;
Mega328

South Louisiana
Offline Offline
Full Member
***
Karma: 0
Posts: 178
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks!  Given that I know very little about what I am doing I suspect that I will just leave it all in and hope that the compiler optimizes all of the unnecessary code away.

Setting up a web server that receives commands from android os is a pretty deep task to get involved in IMHO.

If you don't know the basic ethernet stuff your in for lots of learning and many hours of reading. :-)

Should be fun! Good luck.
Logged

Australia
Offline Offline
Sr. Member
****
Karma: 13
Posts: 446
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looking at the library reference on the website and the examples folder in 1.0.1 I cannot see where the

#include <EthernetClient.h>
#include <EthernetServer.h>

are used. In both the client example and the server example they only have:

#include <SPI.h>
#include <Ethernet.h>

Is there somewhere better where this is documented one way or the other?
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 219
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

as i explained earlier you might not need them all. (or perhaps you do)
programmers of librariers often present you everything, that doesnt mean that your code needs everything
but if they didnt provide it, you had to guess the names.. seams a bit harder to me
and now you can delete lines that you dont need (or mark them out).

simply mark out check if the code still works if ok you dont need it, if it stops you needed it.


I cannot tell you if the code examples you refer to are from the same date as this library
programmers can change whats in their code and how it works, and how it is divided accros their binaries.
Logged

Offline Offline
Full Member
***
Karma: 2
Posts: 219
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

<small add on>

oh and note that SPI is a general interface protocol, to talk against a ethernetcar a gps or whatever.
the code for a network card might go trough a SPI (most likely) but there are different hardware network solutions, so there might be different code too to drive those solutions.
Logged

0
Offline Offline
Sr. Member
****
Karma: 4
Posts: 289
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks!  Given that I know very little about what I am doing I suspect that I will just leave it all in and hope that the compiler optimizes all of the unnecessary code away.

Setting up a web server that receives commands from android os is a pretty deep task to get involved in IMHO.

If you don't know the basic ethernet stuff your in for lots of learning and many hours of reading. :-)

Should be fun! Good luck.

I've got the basics of it somewhat figured out....although for some of it I am not 100% sure why it works the way it does.  I currently am able to send a command from my phone that blinks an LED on the arduino.  I was writing a new sketch to be able to send more complex commands to the arduino and I noticed the multiple #include files which I don't remember seeing before.
Logged

Arduino Uno;
Mega328

Pages: [1]   Go Up
Jump to: