Pages: [1]   Go Down
Author Topic: Arduino Ethernet board and Telnet  (Read 803 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 1
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
// 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
« Last Edit: April 03, 2012, 04:02:16 pm by cwrose » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 - ?
Logged

Rob Tillaart

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

Pages: [1]   Go Up
Jump to: