µTasker Forum
June 19, 2013, 07:54:04 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: March 2012: uTasker KINETIS and STM32 release versions available.
Follow uTasker updates at www.twitter.com/uTasker !!

Online Forum registration has now been disabled. Please send an email to an address at the bottom of the home page with your preferred user name and email address if you would like an account.
 
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Telnet Connection  (Read 639 times)
abhimanyum
Newbie
*
Offline Offline

Posts: 24


View Profile WWW
« on: August 29, 2011, 06:41:41 PM »

Hi Mark,

I'm running a long loop, which actually prints the the loop variable. Using Telnet connection as my Output Screen the telnet stops displaying anything after a while when loop reaches somewhere at 548 (Starting at 0), but I'm able to interact with telnet GUI Commands.


Thanks,
Ab
« Last Edit: August 29, 2011, 07:19:46 PM by abhimanyum » Logged
mark
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2479



View Profile WWW
« Reply #1 on: August 29, 2011, 07:28:27 PM »

Hi

This is presumably because the loop is putting so much data into the output buffer that the buffer overflow (then the data is simply dropped).
To avoid this it is possible to first check the space in the TELNET output buffer (actually the buffered TCP's output buffer) and quit the loop when the buffer becomes full. Then, using the TX_FREE event the loop can continue once the output buffer has space again.

See the way that debug.c does this - it allows large command line menus to be sent to TELNET (or serial interfaces) which only have quite small buffer sizes.

    while (iEntries--) {
        if (!fnWrite(DebugHandle, 0, MAX_MENU_LINE)) {                   // the transmit buffer cannot accept more data so we will pause until it can
            fnDriver(DebugHandle, MODIFY_WAKEUP, (MODIFY_TX | OWN_TASK));// we want to be woken when the queue is free again
            iMenuLocation = (iEntries + 1);                              // save the position we stopped at
            return 1;
        }
        iDisplayLen = fnDebugMsg(ptrCom->strCommand);
        if (iDisplayLen >= ucTab) {
            fnWrite(DebugHandle, ucTabs, 1);
        }
        else {
            fnWrite(DebugHandle, ucTabs, (QUEUE_TRANSFER)(ucTab - iDisplayLen));
        }
        iDisplayLen = fnDebugMsg(ptrCom->strText);
        fnDebugMsg("\n\r");
        ptrCom++;
    }


Here, each time a new command line item is to be sent there is first a check of the remaining buffer size (the write with zero buffer pointer). Once the space is no longer adequate the loop is quit (the loop variable is remembered so that the lpp can later continue from where it was) and the TX_FREE event is used (not shown in thsi code) to kick-off the next block.

Regards

Mark
Logged
abhimanyum
Newbie
*
Offline Offline

Posts: 24


View Profile WWW
« Reply #2 on: August 29, 2011, 08:06:30 PM »

Hi Mark,

I'm not quite sure how can I use TX_FREE and above code snipnet to free the Buffer. If you can please help me understand how to use it.


Thanks,
Ab
Logged
mark
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2479



View Profile WWW
« Reply #3 on: August 29, 2011, 11:02:13 PM »

Ab

The use of TX_FREE and control of output buffers is described in chapter 6 of http://www.utasker.com/docs/uTasker/uTaskerUART.PDF (UART document, whereby the principel is the same for any buffered output, including TELNET).

Regards

Mark
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Copyright © 2013 utasker.com. Webdesign and Hosting by e-future.ch 2013
Valid XHTML 1.0! Valid CSS!
Page created in 0.04 seconds with 18 queries.