Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#689325: arduino: Ethernet Library Dns getHostByName doesn't work

314 views
Skip to first unread message

Pietrofrancesco Apollonio

unread,
Oct 1, 2012, 12:00:02 PM10/1/12
to
Package: arduino
Version: 1:1.0.1+dfsg-6
Severity: important

Dear Maintainer,
I was tring to compile a simple code to make a translation from the hostname to
an IP address using the Arduino IDE (and libraries) included in debian sid:
#include <SPI.h>
#include <Ethernet.h>
#include <Dns.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

EthernetClient client;

char server[] = "www.arduino.cc";
int serverport = 80;

void setup() {
// start serial port:
Serial.begin(115200);
// give the ethernet module time to boot up:
delay(1000);
// start the Ethernet connection using a fixed IP address and DNS server:
//Ethernet.begin(mac, ip, ipdns, ipgw, mask);
Ethernet.begin(mac);
// print the Ethernet board/shield's IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
}
void loop() {

DNSClient dns;
// OPENDNS
IPAddress dns_ip(208, 67, 222, 222);
IPAddress out_ip;
dns.begin(dns_ip);

dns.getHostByName(server, out_ip);

Serial.println(out_ip);

delay(5000);

}

It doesn't make the dns lookup due to a problem with the IPAddress class.
Tring to understand more I noticed that it isn't a problem with the Ethernet
library but a problem that is only present in the debian packaged.
In fact I asked on the arduino forum (
http://arduino.cc/forum/index.php/topic,125140.msg941018.html ) and I found
that using the Arduino Ide from the official web site there isn't any problem.
After I looked into the libraries code and I noticed a lot of differences
between the official 1.0.1 library version and the debian package one.

I found that you have put inside the code a patch so solve a compilation
problem and I guess these code lines led to this code problem.



-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (700, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-3-amd64 (SMP w/8 CPU cores)
Locale: LANG=it_IT.utf8, LC_CTYPE=it_IT.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages arduino depends on:
ii arduino-core 1:1.0.1+dfsg-6
ii default-jre [java6-runtime] 1:1.6-47
ii libjna-java 3.2.7-4
ii librxtx-java 2.2pre2-11
ii openjdk-6-jre [java6-runtime] 6b24-1.11.4-3

Versions of packages arduino recommends:
ii extra-xdg-menus 1.0-4
ii policykit-1 0.105-1

arduino suggests no packages.

-- no debconf information


--
To UNSUBSCRIBE, email to debian-bugs-...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Scott Howard

unread,
Oct 1, 2012, 1:10:02 PM10/1/12
to
On Mon, Oct 1, 2012 at 11:50 AM, Pietrofrancesco Apollonio
<fran...@ldlabs.org> wrote:
> Package: arduino
> Version: 1:1.0.1+dfsg-6
> Severity: important
>
> Dear Maintainer,
> I was tring to compile a simple code to make a translation from the hostname to
> an IP address using the Arduino IDE (and libraries) included in debian sid:


Thanks for the careful debugging. Long story short, the original
Ethernet library has some hacks in it that don't work with the the new
compiler in Debian (gcc 4.7). We patched the code so that the
ipaddress class is the union of address.a8 and address.a32 depending
if you wanted uint8_t or uint32_t returned.


I'd really appreciate it if you could help me out since I don't have
the hardware:

in /usr/share/arduino/libraries/Ethernet/Dns.cpp

find and replace:
aResult[segment]

with

aResult.a8[segment]


There are two occurrences of aResult[segment] that will need to be
replaced with aResult.a8[segment].


Thanks for your help - it's a bit annoying now while Debian and
Arduino's packages have a different toolchain, but hopefully our work
with the new toolchain can pass back patches to Arduino to help them
when they go to port. And in the meantime, Debian package users would
have more optimized binaries on their arduinos (smaller/faster).




[1] andybrown.me.uk/wk/2012/04/28/avr-gcc-4-7-0-and-avr-libc-1-8-0-compiled-for-windows/

Scott Howard

unread,
Oct 1, 2012, 1:40:02 PM10/1/12
to
On Mon, Oct 1, 2012 at 1:06 PM, Scott Howard <showa...@gmail.com> wrote:
> in /usr/share/arduino/libraries/Ethernet/Dns.cpp
>
> find and replace:
> aResult[segment]
>
> with
>
> aResult.a8[segment]
>
>
> There are two occurrences of aResult[segment] that will need to be
> replaced with aResult.a8[segment].

That won't work - somewhere else in the DNS code it is looking for the
uint8_t IP address using the old method. I'll keep hunting for it, if
you get a chance and find it, let me know

Francesco Apollonio

unread,
Oct 1, 2012, 3:20:01 PM10/1/12
to

What are the toolchains that differ from the original arduino package?
I tried to use the original package from the website and it works well.

So I'll be happy to help you to fix this package.

Francesco

Scott Howard

unread,
Oct 1, 2012, 3:40:02 PM10/1/12
to
On Mon, Oct 1, 2012 at 3:11 PM, Francesco Apollonio
<fran...@ldlabs.org> wrote:
> What are the toolchains that differ from the original arduino package?
> I tried to use the original package from the website and it works well.
>
> So I'll be happy to help you to fix this package.
>
> Francesco

Wonderful!

Mainly, Arduino website uses avr-gcc 4.3.2, and Debian's avr-gcc is
4.7.0 [1]. Here is the patch we applied to the arduino libraries:
http://patch-tracker.debian.org/patch/series/view/arduino/1:1.0.1+dfsg-6/gcc47_avr.patch

It might also be good to contact the patch's author, Andy Brown, at
[2]. He could probably help wrap his mind around it.

[1] http://packages.debian.org/sid/gcc-avr
[2] andybrown.me.uk/wk/2012/04/28/avr-gcc-4-7-0-and-avr-libc-1-8-0-compiled-for-windows/

Francesco Apollonio

unread,
Oct 2, 2012, 5:00:01 AM10/2/12
to
Ok, I tried to copy all directories (arduino-1.0.1/libraries and arduino-1.0.1/hardware/arduino) from the archive downloaded from arduino website to the system path (/usr/share/arduino) reverting your modified files.

After that I tried to compile my code with the IDE installed by the debian package and It works and the gethostbyname returns the right address.

Maybe do we need only to revert the modified files?

Scott Howard

unread,
Oct 2, 2012, 8:50:02 AM10/2/12
to
On Tue, Oct 2, 2012 at 4:48 AM, Francesco Apollonio
<fran...@ldlabs.org> wrote:
> Ok, I tried to copy all directories (arduino-1.0.1/libraries and
> arduino-1.0.1/hardware/arduino) from the archive downloaded from arduino
> website to the system path (/usr/share/arduino) reverting your modified
> files.
>
> After that I tried to compile my code with the IDE installed by the debian
> package and It works and the gethostbyname returns the right address.
>
> Maybe do we need only to revert the modified files?

Thanks, can you try to compile the webserver and webclient Ethernet
examples too? A user had trouble with them previously and asked to
apply the patches from the blog posted above. However, I have a
feeling it may be that the patch just takes advantage of some compiler
optimizations and is not essential to the library's compilation. If it
works without the patches, I'll revert the Ethernet library patches.
Thanks again!
0 new messages