Web platform: uIP TCP/IP stack port

From DP

Jump to: navigation , search



In March 2010 a port of the uIP TCP/IP stack for the dsPIC33-based web platform was started. Tony picked up the source and now has it working. The current version can accept 10 simultaneous telnet connections, and has ping times of 0.68ms.

The code runs 3 "tasks" that it multitasks between:

  • One for the IP stack;
  • one for the serial port (debugging help);
  • and another for a handler for telnet (port 23).

The point of the multitasker is to make it simpler to code without worrying about blocking other things that need to happen (particularly, the network stack, or other tasks).

Note: The IP address is fixed in the code as You may need to change this to something more appropriate for your network setup. Debug messages are still being printed to the serial port at 115200 (8/1/none).

Telnet server

The telnet server task is pretty easily extended (just add the name of the command, and a pointer to the function that implements it to telnettask.c. For those interested in implementing commands for telnet, the signature of the function you would need to implement is void telnet_command( file_handle_t handle, char** argv, unsigned int argc ) which is almost exactly like a standard 'c' main(), except the return type is void, and the file handle for the tcp connection is passed in for your command to read and write from. The parameters to the command are already parsed and presented in the char* array argv, with argc items. argv[0] is the command name and argv[1] is the first parameter.


cat [filename]

reads the specified filename from the SD card.

echo [string]

echoes the string.


displays the commands the telnet server currently supports.

ls [directory]

lists the specified directory from the SD card. If no directory is specified, then it lists the current directory.

memdump [address] [count]

dumps the memory from [address] for [count] bytes to the telnet client.


disconnect from the telnet server.

rm [filename]

delete the specified filename from the SD card.

sddump [sector] [count]

dumps sectors from the SD card from [sector] for [count] sectors in the same way that memdump dumps memory.


displays the time (the start time is currently hardcoded until SNTP is implemented).

touch [filename] [data]

create a file on the SD card with the specified filename and write the specified data to it.

Sample telnet session

Here's a sample session:

tony@barellan:~$ telnet
Connected to
Escape character is '^]'.

Web platform telnet. Enter help for commands.
Configured commands:
RTCC Date/Time: 2010-05-16 23:16:12
>memdump 0x1400 64
1400    ce de 42 9d 6f 64 f8 f5 ..B.od..
1408    d0 a6 6b f7 a3 e1 4a ad ..k...J.
1410    44 3c 4c d4 9f 07 9c 0b D<L.....
1418    72 78 95 ba a9 bc 26 fa rx....&.
1420    4e fe e7 7a 56 65 7a 83 N..zVez.
1428    0b 75 a7 39 a6 0e f4 f9 .u.9....
1430    f0 c5 d3 27 74 a9 b1 7f ...'t...
1438    30 5a 90 03 1c 47 0a 6d 0Z...G.m
>quitConnection closed by foreign host.

Web server

It should be reasonably easy to write a web server task now.

Further development and feedback

Further development details may be found in the forum thread. Feedback, particularly on how the code works with your SD card, would be appreciated.

The latest source for the port is available in the Dangerous Prototypes SVN. Details on using the SVN may be found on the Using SVN page.