Author Topic: Help on Telnet  (Read 7722 times)

Offline bert

  • Newbie
  • *
  • Posts: 15
    • View Profile
Help on Telnet
« on: January 02, 2009, 01:54:38 PM »
Hi!
Have some difficulties to activate Telnet :(

In Config.h Telnet is enabled:
  #define USE_TELNET         // enable TELNET support

I can get DebugMsg out of the UART but Telnet is dead, anyone got some good ideas where to look?

Thanks!
/Bert

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3021
    • View Profile
    • uTasker
Re: Help on Telnet
« Reply #1 on: January 02, 2009, 10:58:02 PM »
Hi Bert

The define that you mentioned should be adequate to activate debug output on TELNET in the demo project.

However check also the following:

1) Can you establish contact with the TELNET port? The debug outputs will only be displayed there (rather than on the UART) when there is a TELNET connection.

2) Have you enough RAM memory to allow TELNET to correctly operate? TELNET uses a TCP buffer (TCP_BUFFER in app_hw_xxxx.h). If the buffer can not be obtained when connecting to TELNET (due to lack of free heap) it will not be able to operate correctly).
If you are using a device with very limited SRAM you may like to have a quick try without UART enabled (it also uses quiet a lot of RAM for its UART buffer) and see whether TELNET works alone. Then you would need to optimize the RAM use to allow all to work at the same time...

Good luck

Mark

Offline bert

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Help on Telnet
« Reply #2 on: January 03, 2009, 12:16:48 AM »
Hi Mark!
1. I can not establish contact with the TELNET port.
Not quite sure i'm doing right, I Run TELNET from Start=>Run.
When window opens i type "open 192.168.0.63"... scren goes black, nothing happens.
Have also tested PuTTY, same result. Black scren and after a while i get the message "Connection closed by remote host".

2. Running on M52235EVB.

Regards
/Bert

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3021
    • View Profile
    • uTasker
Re: Help on Telnet
« Reply #3 on: January 03, 2009, 12:52:05 AM »
Hi Bert

With the Coldfire you should have no problem with SRAM.

1) check that there is not a firewall blocking Telnet port access.

2) I open a DOS windows and type in "telnet 192.168.0.3". The board sends the menu when the connection is made.

Regards

Mark

Offline bert

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Help on Telnet
« Reply #4 on: January 03, 2009, 01:44:29 AM »
Hi Mark!

Should'nt you go to bed ;)

1. Have no problem problems to TELNET other equipment in my proximity (NAS, Router, other computers..)

2. Same result as before...

Thanks!
/Bert

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3021
    • View Profile
    • uTasker
Re: Help on Telnet
« Reply #5 on: January 03, 2009, 10:24:09 PM »
Hi Bert

Please verify the TELNET operation as follows:

1) Check that the TELNET server is really being started. The code should perform fnConfigureTelnetServer() in debug.c. This should be called by the debug task (fnDebug()) when it is first scheduled. This means that the define USE_MAINTENANCE should not be removed from config.h otherwise various debug support will also be missing.

2) There is a flag called ACTIVE_TELNET_SERVER which is saved as a user parameter and allows the system to be configured with or without an active TELNET server. Perhaps your parameters have this flag deactivated (?), which would not actually start the server. This can be checked in fnConfigureTelnetServer().

3) When the TELNET server is not running any TELNET request attempts should be reset by the project sending back a TCP RST to the SYN message.

4) When the TELNET server is running any TELNET request attempts should be answered with a TCP SYN and afterwards communication should be possible.

Good luck.

Regards

Mark

Offline bert

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Help on Telnet
« Reply #6 on: January 04, 2009, 03:02:01 PM »
Hi!
1. TELNET is started, verified by single stepping "fnConfigureTelnetServer()" and it is called by the debug task.
4. TCP SYN message verrified with Etheral (see attached log).

The TELNET session is definitely active, however the menu is not appearing in the TELNET window.

After starting the TELNET session I tried to connect the UART.
Response: Command line blocked.

And then after closing the TELNET session I get the following menu prompt from the UART.

     Main menu
===================
1              Configure LAN interface
2              Configure serial interface
3              Go to I/O menu
4              Go to administration menu
5              Go to overview/statistics menu
help           Display menu specific help
quit           Leave command mode

Think I need some more advice…
Thanks!
/Bert

 

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3021
    • View Profile
    • uTasker
Re: Help on Telnet
« Reply #7 on: January 04, 2009, 05:47:47 PM »
Hi Bert

Your connection looks good but I would expect the menu to be sent as soon as the connection is established.
In your recording there is nothing happening although the serial interface is blocked (which is normal when TELNET is active).

Here is the TELNET output that I see when I test:


Serial number: 00-00
Software version V1.3.010
Device identification: uTasker Number 1

     Main menu
===================
1              Configure LAN interface
2              Configure serial interface
3              Go to I/O menu
4              Go to administration menu
5              Go to overview/statistics menu
help           Display menu specific help
quit           Leave command mode



In fact there are also a couple of TELNET commands sent to negotiate the echo mode before the menu is displayed, also these are not being sent in your case.

I have played through some scenarios and the most probably is that you don't have enough HEAP memory for the buffered connection to operate:

Perhaps you could check the following:
In the TELNET listener function fnTELNETListener() in debug.c the successful connection establishment causes the event TCP_EVENT_CONNECTED to arrive:

    case TCP_EVENT_CONNECTED:                                            // TCP connection has been established
        ucTelnetMode = 0;
        // we start negotiation of the telnet session and say that we will perform echo (only when not a binary TCP connection)
        usTelnet_state = ES_STARTING_COMMAND_MODE;                       // connection starts in command mode
        return fnTelnet(Telnet_socket, GOTO_ECHO_MODE);                  // try to set echo mode


I believe that this is taking place because the state is being set to ES_STARTING_COMMAND_MODE, which would cause the UART connection to be blocked (which you have seen).
The function fnTelnet() will then send a TELNET "WILL ECHO" negotiation, which is however not visible in your recording.

In fnTelnet() in telnet.c something must therefore be going wrong.

    TELNET *TELNET_session = fnGetTelnetSession(Telnet_socket);

    if (!TELNET_session) return APP_ACCEPT;                              // not found, simply return accepted by application

    switch (iCommand) {
    case GOTO_ECHO_MODE:
        fnSendNeg(TELNET_session, TELNET_WILL, TELNET_ECHO);
        TELNET_session->usTelnetMode |= TELNET_WILL_ECHO;                // mark that we want to echo
        return APP_SENT_DATA;


Check that the TELNET session is found. I could only really explain it not being found if its internal data structures are somehow getting corrupted during the TCP connection phase; If TELNET_session is zero it would return without doing anything, but I don't expect this to be the case.

fnSendNeg() builds and sends the negotiation telegram via TCP, using fnSendBufTCP().

Coming back to the point about heap memory: TELNET uses buffered TCP (note the use of fnSendBufTCP()) which requires a transmit buffer. This is created on first use, which is in fact when the first negotiation message is send.
Look in fnSendBufTCP() in tcp.c:

    if (!tcp_tx) {                                                       // we get working space from heap only when we actually use it (we assume such sockets are never released)
        if ((tcp_tx = (TCP_TX_BUFFER*)uMalloc(sizeof(TCP_TX_BUFFER))) == 0) {
            return 0;                                                    // couldn't get required memory from heap!
        }


If there is not enough heap memory available to create the buffer the message will not be sent. This seems to be the most probably explanation for your case. If you step through the uMalloc() call it may be returning zero. You can then see how much more heap memory is required to allow it to be successful (OUR_HEAP_SIZE can be increased to allow it to function). The question is then why the heap size has to be increased. This may be due to you adding other code which uses heap and so it is important to always monitor the use of heap (and RAM generally) since it is a precious resource in chips with limited resources.

Good luck

regards

Mark

Offline Nansius

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Help on Telnet
« Reply #8 on: April 21, 2010, 12:48:16 AM »
Hello Mark!

I've got similar problem. The TELNET server is started, I'm able to capture incoming data etc., but TELNET does not tranfer menu or any other massage from uP to PC. Moreover debug massages are still transferred via serial interface.

I'm running it on Olimex SAM7-EX256 board. I've found that when I'm using precompiled binary file (uTaskerV1.4_SAM7X-EX256.bin) TELNET works as it should but when I'm compiling compleately fresh project (with comment removed from #define OLIMEX_EX256 and added to #define SAM7X_EVAL) it works as described before (missing menu, etc., but communications seems to work ok) ... I'm using GCC to compile it.

Are there any code differences between resulting binary file and precompiled uTaskerV1.4_SAM7X-EX256.bin ?
« Last Edit: April 21, 2010, 01:08:26 AM by Nansius »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3021
    • View Profile
    • uTasker
Re: Help on Telnet
« Reply #9 on: April 21, 2010, 07:07:56 PM »
Hi

Make sure that Telnet is enabled (in config.h) USE_TELNET as well as ETH_INTERFACE and USE_IP.
I would expect TELNET to work on all targets but maybe the HEAP is a bit too low on the one that you choose(?)

Beware that the TELNET connection (as USB) is blocked when the menu interface is active on UART. Disconnecting with "quit" will free it again. However, if this is the reason for TELNET being blocked it will result in the TCP connection being refused and not just be a problem with transmission in one direction.

I would disable the UART interface #define SERIAL_INTERFACE since it has quite large buffers and so will probably allow TELNET to operate correctly. Or monitor the memory use over the UART connection (memory command in "stats" menu - see also http://www.utasker.com/forum/index.php?topic=468.0 ) and see whether it has enough heap space for the TELNET tx buffer.

Regards

Mark