[CSE]  Advanced Operating Systems 
 COMP9242 2008/S2 
UNSW
CRICOS Provider
Number: 00098G

PRINTER Printer-Friendly Version
Administration               
- Notices
- Course Intro
- Consultations
- Survey Results
 
Work
- Lectures
- Selected Papers
- Project Spec
- Exam
 
Forums
- Forums
 
Resources
Project Resources
Slug Lab
L4 Debugging Guide
Developing on a Mac
Developing on Linux
SOS source browser

 
Documentation
OKL4 reference manual
Elfweaver user manual
IXP42X hardware manual 
OKL Wiki
NSLU2-Linux HomePage
Intel IXP400 Software

 
Related Info
IBM OS Prize
OS Hall of Fame
 
History
2007
2006
2005
2004
2003
2002
2000
1999
1998
- 1997
 
Staff
- Gernot Heiser
- Kevin Elphinstone (LiC)
- Guest Lecturers (TBA)
 
Stureps
- Student Reps

 
Valid HTML 4.0!

Serial Library

The serial library provides a very simple device driver that uses UDP/IP to send data, without error correction or packet loss detection, to the AOS06 port (UDP 26706) on your development machine. The port number was chosen to be easy to remember; Imagine you are dialing 'AOS06', the port number is the series of digits you dialled.

serial_init

struct serial * serial_init()

serial_init initalises the state of the serial driver and returns a handle that must be passed to other serial functions.

serial_send

int serial_send(struct serial *serial, char *data, int len);

serial_send will write len bytes of data to the AOS06 port (UDP 26706) on your development machine. This function returns the number of bytes written, which may be less than len. This occurs if the serial driver's internal buffer fills faster than it can actually output data. In this case it is up to the calling code to handle the situation, either by retrying or returning an error to the user.

You can see this output by running netcat: nc -lup 26706 in a terminal window.

serial_register_handler

int serial_register_handler(struct serial *serial, void (*handler)((struct serial *) serial, char c));

To receive input from the netcat terminal you must register a handler function, which will be called by the serial driver when the network makes data available. The provided function simply takes the inputted character as it's only argument. This function will be called during an interrupt context so it should be reasonably light-weight.

What's really happening here

Due to historical reasons we call this driver a serial driver, even though it has nothing to do with serial ports anymore. The serial_send() function, in the driver, takes a block of data, wraps it into a single UDP frame and sends it to 192.168.168.1:26706. You should be aware that LWIP is not particularly smart and it will not break up large buffers for you. Limit your buffer size to 1450 bytes or so.

netcat(nc) is a pretty cool program, once it has received data from a particular machine it will connect() to the machine and send all input data onto your service. However this comes with some pretty serious limitations, as the networking stack on your machine will happilly do break up of IP packets. This is good and to be expected, but LWIP can't deal with the deluge and will just drop everything on the floor. If needed you will have to write your own bulk transfer protocol.


Last modified: 28 Aug 2008.