I've been trying to talk to an Arduino Ethernet board (not shield)
with telnet, and have go nowhere; thanks to this forum I've got
ping running, but the telnet or udp or web stuff I want to add
simply hangs. Below is the sketch I've been trying - it runs ok
(without handling telnet) until the EthernetClient line is added,
and then it hangs - no response to ping, nothing on the serial port.
I'm using arduino-1.0.1 and avr-gcc-4.5.3 (on Linux). It looks as
if the Ethernet library is blocking somewhere, but following through
a maze of C++ class initialisations isn't easy. Can anyone see
where I might be going wrong, or suggest a working library?
Thanks - Will
// Test of Arduino Telnet.
#include <SPI.h>
#include <Ethernet.h>
// Undefine this to get a working program.
#undef TELNET
// the media access control (ethernet hardware) address for the Arduino:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x92, 0x34 };
// the IP address for the Arduino:
byte ip[] = { 192, 168, 1, 20 };
// telnet defaults to port 23
EthernetServer server(23);
void setup()
{
// Initialise the serial device.
Serial.begin(9600);
delay(2000);
Serial.println("setup()");
// Initialize the ethernet device
Ethernet.begin(mac, ip);
// start listening for clients
server.begin();
}
void loop()
{
Serial.println("loop()");
// Uncommenting this statement hangs the sketch.
// The response from ICMP is "Destination Host Unreachable"
EthernetClient client = server.available();
// Read bytes from the incoming client and write them back
// to any clients connected to the server.
#ifdef TELNET
if (client) {
char c = client.read();
server.write(c);
}
#endif
}
// eof