Ethernet shield with Linux Arduino 1.0 IDE

I got a hold of an Ethernet shield and was eager to try it out only to find that there is a bug somewhere in the Linux version of the IDE (I’m using the 32-bit version)…

The code I ended up testing.

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

byte mac[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
IPAddress ip(192, 168, 1, 2);
EthernetServer server(80);

void setup() {
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.begin(9600);
  Serial.println("setup");
}

void loop() {
  EthernetClient client = server.available();
  if (client) {
    Serial.println("new client");
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.print(c);
        if (c == '\n') {
          client.println("Hello!");
          break;
        }
      }
    }
    delay(1);
    client.stop();
    Serial.println("client disconnected");
  }
}

If I upload the code with the 1.0 IDE under Windows 7 32-bit, the serial output is:

setup
new client
GET / HTTP/1.1
client disconnected
new client
GET /favicon.ico HTTP/1.1
client disconnected

Using the 32-bit Linux IDE, I get seemingly random char sequences and this code only prints out the first line…

setup
new client
HjêVCÑ?Ú¢¤PÎ%`*H¿ä¿BÑów?³ç?·Û4?,	¯
*]"?ä?=F]C%Òª§lYQnxü]¸dV?²ÓÅÊ?ØW?rX&&?E?¡n\?1?ºAÐÞî" ´FåË6²ÑÌT[¨cy¥cr×?¹2sM
]R	õüô.dv#ÞǬ..
client disconnected
new client
9%?'t\??}©£}r°»Ot=>º±Ä»¯ì«Ýpví?âÃ?	??%ã¥ÁEak¥Oí3<>Îò·Õ¿>Ö²?N3ª?Hþ·Ie8Ã?úÖcì«êÒíïÇ})ñPG?¯(_Ï8ïVê%8AGRe?h?íѼ/íÊ¥Mp)§%{e@Àê?_?°=ìÑ?x´S&úIÏûRB¼?íbb?Æ7`
client disconnected

I tested it with an Uno R2 and a Duemilanova, it doesn’t matter. I also tried copying the libraries from the Windows IDE folder but this didn’t help either. Any other suggestions?

Thanks in advance!

Raido

What version Linux are you using? I use Ubuntu v11.10, and it is working pretty good.

I downloaded the Arduino IDE V0022 from the Ubuntu repository first, then downloaded IDE V1.0 from the Arduino site.

I am too using Ubuntu 11.10 and the IDE version 0022 from the repoesitory does indeed work but I cannot get the 1.0 working. I don't really know how it should be updated.

Then you are good to go, with one exception.

I use both V0022 and V1.0 on my Ubuntu box. If I use the "dash home" entry, I get V0022. If I use "Home Folder" and navigate to the folder that I downloaded V1.0 into, then select the arduino shell script there, then I get V1.0.

However, there is a bug in V1.0 that caused me some serious grief. Here is the bug and patch. http://code.google.com/p/arduino/issues/detail?id=605 It affected v0022, v0023, and now v1.0. It is patched in the Ubuntu repository v0022 already, but not in the Arduino site v1.0.

Oh wow! This did fix the 1.0 IDE! Thanks! :)