Go Down

Topic: Arduino Ethernet board and Telnet (Read 815 times) previous topic - next topic

cwrose

Apr 03, 2012, 07:01 pm Last Edit: Apr 03, 2012, 11:02 pm by cwrose Reason: 1
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

Code: [Select]

// 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

robtillaart

please modify your post, select the code and press the # butto to get it proper tagged , makes it easier to read.

seen this thread on the old forum - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1278686415 - ?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up