natelserl: Telnet Server Example Application

This application demonstrates the Telnet Server API.

BSP Setup

    1. Enable serial driver in ./bsp/platforms/<?platform?>/bsp_serial.h
       Make sure the Serial port is not dedicated for other functionality like SPI
            BSP_SERIAL_PORT_1       BSP_SERIAL_UART_DRIVER
            BSP_SERIAL_PORT_2       BSP_SERIAL_UART_DRIVER

	   if using ns9750 or ns9360:

            BSP_SERIAL_PORT_3       BSP_SERIAL_UART_DRIVER
            BSP_SERIAL_PORT_4       BSP_SERIAL_UART_DRIVER

       if using connectcore9p9215:
            BSP_SERIAL_PORT_2       BSP_SERIAL_UART_DRIVER
            BSP_SERIAL_PORT_4       BSP_SERIAL_UART_DRIVER
        
       if using connectme9210:
            BSP_SERIAL_PORT_1       BSP_SERIAL_UART_DRIVER
            BSP_SERIAL_PORT_3       BSP_SERIAL_UART_DRIVER


    2. Configure serial port[a-d] in ./bsp/platforms/<?platform?>/gpio.h
       This will depend on the number of serial ports on your board
            #define BSP_GPIO_MUX_SERIAL_A       BSP_GPIO_MUX_SERIAL_8_WIRE_UART
            #define BSP_GPIO_MUX_SERIAL_B       BSP_GPIO_MUX_SERIAL_8_WIRE_UART

		if using ns7520:
			#define BSP_GPIO_MUX_SERIAL_B       BSP_GPIO_MUX_SERIAL_4_WIRE_UART

		if using ns9750 or ns9360:

            #define BSP_GPIO_MUX_SERIAL_C       BSP_GPIO_MUX_SERIAL_8_WIRE_UART
            #define BSP_GPIO_MUX_SERIAL_D       BSP_GPIO_MUX_SERIAL_8_WIRE_UART

        if using connectcore9p9215:
            #define BSP_GPIO_MUX_SERIAL_B       BSP_GPIO_MUX_SERIAL_8_WIRE_UART_USE_ALTERNATE_PATH
            #define BSP_GPIO_MUX_SERIAL_D       BSP_GPIO_MUX_SERIAL_8_WIRE_UART_USE_ALTERNATE_PATH

        if using connectme9210:
            #define BSP_GPIO_MUX_SERIAL_A       BSP_GPIO_MUX_SERIAL_8_WIRE_UART
            #define BSP_GPIO_MUX_SERIAL_C       BSP_GPIO_MUX_SERIAL_2_WIRE_UART


	3. Recompile the BSP library and application.



Development Board Setup

    On NS7520 development board, jumper JP6 must be OUT to be able to use the 
	second port.

	On NS9759 and NS9360, verify which ports are configured, then modify  
	step 1 and step 2 above accordingly.


This application does the following:

1.  Initializes the development board, loads the ThreadX kernel,
    the device drivers, and the TCP/IP stack.
2.  Opens the two-four serial ports and starts the Telnet Server by TSOpenPort().
    The telnet port base is 10000.

Then, under DOS, type 

    telnet <IP address> <port>

where IP address is
    board IP address

where port is
    port    port base + port number

    10000   => 10000  + 0
    10001   => 10000  + 1
    10002   => 10000  + 2  (if using ns9750 or ns9360)
    10003   => 10000  + 3  (if using ns9750 or ns9360)

where port base is
    10000   => Telnet socket

where port number depends on the number of ports on board
    0       => port A
    1       => port B
    2       => port C  (if using ns9750 or ns9360)
    3       => port D  (if using ns9750 or ns9360)

This will open a telnet client window.
The login name is "sysadm" and the password is "sysadm" or
the login name is "debug" and the password is "debug".

Then do the following:

1.  Connect the serial port 1 to your PC's COM1, and
    connect the serial port 2 to your PC's COM2.
2.  Using HyperTerminal, open two connections using COM1 and COM2 on
    your PC.
3.  Whatever you typed in the telnet client session port number 10000
    appears in the COM1 HyperTerminal screen, and vice versa.
4.  Whatever you typed in the telnet client session port number 10001
    appears in the COM2 HyperTerminal screen, and vice versa.


The application prints some results in the debugger window by means of
printf(), make sure #define BSP_STDIO_PORT  "/com/0" is commented out
in bsp_sys.h because there is no port for printf.

Note1:
    This example application does not automatically echo characters back to the client. 
    When running Unix telnet client, please put it into the line mode, to see on the 
    client side characters typed on the client side.
    
Note2:
    When the server is in the character mode it receives data in a buffer and
    then parses for the end of the line (so be sure to press <ENTER> after finishing
	input in telnet window). The buffer size is passed to the telnet 
    server by the application. The constant SERL_BUFFER_SIZE is defined to 128 in the 
    file serl_mod.h. If you want to type in more than 128 characters without 
    pressing <ENTER>, please increase the SERL_BUFFER_SIZE and rebuild the application. 

One GNU make file is provided.  Build the target 'image' to
generate an image that can be debugged with gdb, and the file 
image.bin which can be written to flash if the bootloader is used.
Build the target 'rom.bin' to create the file rom.bin which 
can be written to ROM if the bootloader is not used.

The following files are provided with this application:

appconf.h         sets application configuration settings
makefile          Make file for the GNU toolset.
readme            this file
root.c            contains the applicationStart() function, that creates
                  an application thread
telnet.c          contains telnet API functions, an example of Telnet
                  Server session code
serial.c          contains routines to initialize the serial ports and
                  queues and start the tasks
put.c             contains routines of put task, whose purpose is to
                  check if there is any incoming data from the serial
                  port to be processed (if so, the buffer is sent out
                  to the server and the server then sends it to the
                  telnet client)
get.c             contains routines of get task, whose purpose is to
                  check if there is any incoming data from the client
                  through the server (if so, the server then sends it
                  out on the serial port)
mbox.c            contains routines to queue messages

In addition, the following files in the BSP directory are built
as part of this application:

reset.s         contains the reset code
appconf_api.c   contains code used to read settings in appconf.h


The application build file links in the following libraries:

libbsp.a           		contains the BSP code
libtcpip.a         		contains the Net+Works TCP/IP stack
libpppintf.a		    contains the PPP Interface Library
libtx.a            		contains the ThreadX kernel
libfilesys.a       		contains the file system libraries
libposix.a         		contains the POSIX layer libraries
libflash.a         		contains the Flash driver API library
libtelnsvr.a       		contains the Telnet server library
libaddp.a		   		contains the ADDP Library
libssh.a		   		contains the SSH Library
libdnsclnt.a        	contains the DNS Client library

The application uses the following files located in the
netos\src\bsp\platforms\<platform> directory.

bootldr.dat     bootloader configuration file used to generate the
                file image.bin.  It controls the information placed
                in the bootloader header of the image.

image.ldr       GNU linker script used to build an image that can
                be debugged and used with the bootloader.
                
customize.ldr   Customizable GNU linker script


