Serial Library

The serial library provides a very simple virtual device driver that uses UDP/IP to send data, without error correction or packet loss detection, to a UDP port on the AOS ODroid-C2 cluster server. The port is different for each odroid connected to the server and can only be connected to via 9242 odroid serial in a CSE terminal.

IP addresses

The IP addresses used by SOS are configured using cmake, and referred to as SosIP and SosGateway. See the framework documentation for configuring variables with CMake. However, both IP addresses have been set by default to the IPs expected by U-Boot on the odroid-c2.

Libserial interface


struct serial * serial_init()

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


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

serial_send will write len bytes of data to the UDP port for your serial connection. 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: 9242 odroid serial in a CSE terminal window.


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 its 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. In reality it is a virtual serial driver over ethernet, using UDP. The serial_send() function, in the driver, takes a block of data, and uses the picotcp library to package the message up into UDP frames, which are sent to the SosGateway (your machine).