TinyOS 2 Serial Communication Mechanism port on contiki

From Cyber-Physical Systems Laboratory
Revision as of 17:48, 14 September 2017 by Bowen (talk | contribs) (Created page with "The source files for the TinyOS 2 serial communication mechanism on contiki: '''core/dev/CPSL-tinyos-2x-serial.h''' '''core/dev/CPSL-tinyos-2x-serial.c''' '''core/dev/CPSL-ti...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The source files for the TinyOS 2 serial communication mechanism on contiki:

core/dev/CPSL-tinyos-2x-serial.h core/dev/CPSL-tinyos-2x-serial.c core/dev/CPSL-tinyos2x-serial-header.h

My principle when implement this feature is try not to touch the original contiki source code.

To add the TinyOS 2 serial communication mechanism:

Step 1:

In core/dev/serial-line.h, add the following definition:

  1. ifdef TINYOS_2X_SERIAL_PACKET
  2. include "CPSL-tinyos-2x-serial.h"
  3. endif

Step 2: In core/dev/serial-line.c, modify the function serial_line_input_byte,

this function is invoked every time a character come in through the serial port.

In the function, add the following statements:

  1. ifdef TINYOS_2X_SERIAL_PACKET
 tinyos2x_serial_dispatcher(c);
  1. endif

Some note about the implementation:

There are 2 processes in this implementation:

tinyos2x_serial_unescape_process, this process is invoked every time a packet has been

taken out from the byte stream. It will unescape the byte array received.

tinyos2x_serial_ack_send_process, this process is invoked every time unescaping of the

byte array has been done, it will send ack packet to the server.

Send data to the server:

Suppose you have a data array called payload, its length is len. Just pass the data array and its

length to function send_data_to_server in CPSL-tinyos-2x-serial.c. Remember that the data

array only need to contain the payload, all other stuff in the packet will be automatically set

by this function.