[SOLVED] Establishing telnet connection (using UIPEthernet library)

i am finally jumping in to use the UIPEthernet library, but rather than add this waay too elementary problem into that ongoing thread, though i'd just make a separate one.

i'm trying out this Example code; TcpServer.ino;

/*
 * UIPEthernet EchoServer example.
 *
 * UIPEthernet is a TCP/IP stack that can be used with a enc28j60 based
 * Ethernet-shield.
 *
 * UIPEthernet uses the fine uIP stack by Adam Dunkels <adam@sics.se>
 *
 *      -----------------
 *
 * This Hello World example sets up a server at 192.168.1.6 on port 1000.
 * Telnet here to access the service.  The uIP stack will also respond to
 * pings to test if you have successfully established a TCP connection to
 * the Arduino.
 *
 * This example was based upon uIP hello-world by Adam Dunkels <adam@sics.se>
 * Ported to the Arduino IDE by Adam Nielsen <malvineous@shikadi.net>
 * Adaption to Enc28J60 by Norbert Truchsess <norbert.truchsess@t-online.de>
 */

#include <UIPEthernet.h>

EthernetServer server = EthernetServer(23);  // was '1000'

void setup()
{
  Serial.begin(9600);

  uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
  IPAddress myIP(192,168,6,5);  // was 192,168,1,6
Serial.println("starting Ethernet...");
  Ethernet.begin(mac,myIP);

  server.begin();
}

void loop()
{
  // Serial.println("begin loop");
  size_t size;

  if (EthernetClient client = server.available())
    {
      while((size = client.available()) > 0)
        {
          uint8_t* msg = (uint8_t*)malloc(size);
          size = client.read(msg,size);
          Serial.write(msg,size);
          free(msg);
        }
      client.println("DATA from Server!");
      client.stop();
    }
}

so, it seems straightforward, run the sketch and simply connect to that IP via telnet, perhaps type a character to trigger a response ?; but it doesn't even connect.

is there some fundamental connection i have failed to see ?

i actually tried HyperTerminal first because that's what i'd been using to test Serial communication, then after searching 'telnet' found there was a command line utility.

this was using HyperTerminal (which should also work, right ?)

and then i used telnet;

i changed some parameters thinking it had to be default settings;

it just hangs... but if i unplugged the connection, then i get a response !

i tried Google just to confirm i CAN telnet to somewhere;

and eventually found a confirmed site one CAN telnet to;

could anyone help troubleshoot where the connection to the Arduino fails ?

EDIT:
changed subject to be more useful for future searches

Your code-changes (port and local ip-address) look fine.
Do you have any chance to install wireshark and capture the traffic? You can upload the log to http://www.cloudshark.org/ for us to see.

  • Norbert

Hello again !

Thanks so much for your assistance, i've finally got WireShark running and tried it out.

re: Arduino not responding to the "ARP" should it look more like this ?

this was using my previous sketch that works - but using EtherCard.

infact the DHCP protocol showed up first in the Capture even before an ARP "who has...?" was broadcast.

that means the DHCP connection worked immediately, right ?

will keep reading the capture streams and try to make sense of them.

Thanks, as always !

P.S.
i will try out the debugging feature in UIPEthernet.h as you suggested.

am not getting much progress.

From what I can see the Arduino does not even respond to the ARP-requests. Could it be the connection to the arduino-board is faulty? You can enable some debug in UIPEthernet.h and check the output via Serial monitor. (uncomment the #define UIPETHERNET_DEBUG is sufficient to see whether the Arduino is able to receive packets)

i've tried enabling the DEBUG option in but get nothing on the Serial Monitor when running EchoServer.ino or TcpServer.ino.
when i run TcpClient.ino i get this;

i don't have a server to give it a response though.

does that early section in the SerialMonitor 'printout' (from setup() ?) mean the DHCP is not working ?
could it be a router compatibility issue ? (please excuse the ignorant musings, i probably don't know what i'm saying !) i'm using a D-Link Model: DIR-600 if that's of any significance.

as in my previous post, DHCP does work with the EtherCard sketch - although have since discovered it might not be quite right, i can view the 'served page' via local LAN IP address, as well as via a DDNS service, but when i browse to it from outside the router, it fails, there is a "black packet" in WireShark ;

963	98.284038000	192.168.6.6	192.168.6.5	IGMP	[b]423[/b]	Unknown Type:0xef

that pops up when the page is being refreshed(??), those 423 bytes(?) are the webpage data.
browsing to the page or refreshing it shows a normal "green" TCP packet though.

i was also wondering whether free RAM was an issue, the UIPEthernet sketches compile to 16KB plus, whereas the EtherCard ones are in the range of 10-12KB.

i already tried switching off the #define UIP_CONF_UDP 1 in the uipethernet-conf.h file but that didn't seem to change anything.

does anybody have any pointers on what i should try next ?

Best guess: if EtherCard works and UIPEthernet does not send any packets you didn't connect CS to pin 10 (hardware SS on Uno as specifiec in SPI-doc, Mega2560 would be 53) but pin 8, did you?

SUPER D'OH !!

it had to be something so fundamental ??!! - ARGH !

will get back to it again tomorrow....

it totally slipped my mind that UIPEthernet translates the stock Ethernet library, which i was aware (probably not very) uses a different CS pin !!
incidentally, using the SPI hardware doesn't need explicit #include <SPI.h> does it ? must be why it went under my radar.

also; i noticed this line in UIPEthernet.cpp;

#if(defined UIPETHERNET_DEBUG || defined UIPETHERNET_DEBUG_CHKSUM)
#include "HardwareSerial.h"
#endif

i actually don't have that file in my Arduino directory - how come an error didn't mention that when i switched DEBUG mode on ?

okay, Norbert - thanks again - for something SO basic ! :smiley:
must remember - if the software doesn't work, make sure the hardware is - i must've been focussing so much on the ENC28J60 i forgot all about the Arduino side !!

i hope to report a blazing success tomorrow ! :slight_smile:

retronet_RIMBA1ZO:
incidentally, using the SPI hardware doesn't need explicit #include <SPI.h> does it ?

SPI.h not required unless you are using a Due (or when you explicitly set ENC28J60_USE_SPILIB to 1 in Arduino_1.5.5-branch Enc28J60Network.h, Line 38)

retronet_RIMBA1ZO:

#include "HardwareSerial.h"

HardwareSerial.h is part of arduino core

ntruchsess:

retronet_RIMBA1ZO:

#include "HardwareSerial.h"

HardwareSerial.h is part of arduino core

oh, okay - good to know - thanks :slight_smile:

was wondering, i thought that should then be using #include [b][color=blue]<[/color][/b]HardwareSerial.h[b][color=blue]>[/color][/b] as opposed to #include [b][color=blue]"[/color][/b]HardwareSerial.h[b][color=blue]"[/color][/b] - which means to look in the library folder 'only' ?

ntruchsess:

retronet_RIMBA1ZO:
incidentally, using the SPI hardware doesn't need explicit #include <SPI.h> does it ?

SPI.h not required unless you are using a Due (or when you explicitly set ENC28J60_USE_SPILIB to 1 in Arduino_1.5.5-branch Enc28J60Network.h, Line 38)

but none of your example codes have the line #include <SPI.h> - am i missing something here ?

retronet_RIMBA1ZO:
but none of your example codes have the line #include <SPI.h> - am i missing something here ?

They have - but only in the Arduino_1.5.5-branch , as Arduino 1.0.x-library-format is not intendet to run on Due anyway.

retronet_RIMBA1ZO:
...
...

ntruchsess:

retronet_RIMBA1ZO:
incidentally, using the SPI hardware doesn't need explicit #include <SPI.h> does it ?

SPI.h not required unless you are using a Due (or when you explicitly set ENC28J60_USE_SPILIB to 1 in Arduino_1.5.5-branch Enc28J60Network.h, Line 38)

but none of your example codes have the line #include <SPI.h> - am i missing something here ?

duhh - was missing understanding "NOT required" !!


anyway - here's my progress report - not exactly a blazing success, but quite fiery enough ! ]:smiley:
(i also found out that MS-Telnet wasn't working, but HyperTerminal did.)

here's EchoServer working;

and also TcpServer;

for TcpClient, i had an error :

[glow=red,2,300][color=white]Error compiling:[/color][/glow]
TcpClient.cpp.o: In function `setup':
C:\arduino-1.0.5-windows\arduino-1.0.5/TcpClient.ino:29: undefined reference to `UIPEthernetClass::begin(unsigned char const*)

but that was solved after i downloaded the latest library code (previous version was 20-Feb-2014, now i have 2-Mar-2014)

there's still an outstanding issue, but that's because the DNS that got assigned was invalid - i'm also having problems with this "cheap" router... :~

is there a way to assign the DNS server info manually in the UIPEthernet library ?
would it become a problem if i use the DHCP for IP addressing but tried to override the DNS information ?
(ideally i fix it at the router end itself, but was wondering if i could also "fix" it at the ENC28J60 end)

regarding manual assignment of dns: see documentation of Ethernet.begin

ntruchsess:
regarding manual assignment of dns: see documentation of Ethernet.begin

okay, that's great - thanks as always !
that means i'll have to lock the IP as well.

Hey,
I have a small problem and I found this topic.
I have the same problem as you had. I connect the Arduino to the ENC28J60 (with proper wiring). i upload the code and then use putty or cmd to connect to telnet. it connects, but as soon as i press a button it dc and dies.
Or sometimes it doesn't even connect. I tried different libraries, different commands, tried to comment the disconnection part, still no positive feedback from the server.
Any idea?
Do you have something more to share?
I understood there may be some buffer problems, but how you resolve this?