Interface: tos.lib.serial.SerialFrameComm

interface SerialFrameComm

This interface sits between a serial byte encoding component and a framing/packetizing component. It is to be used with framing protocols that place delimiters between frames. This interface separates the tasks of interpreting and coding delimiters and escape bytes from the rest of the wire protocol.

Author:
Philip Levis
Ben Greenstein
Date:
August 7 2005

Commands
command error_t putData(uint8_t data) Used by the upper layer to request that a byte of data be sent over serial.
command error_t putDelimiter() Used by the upper layer to request that an interframe delimiter be sent.
command void resetReceive() Requests that any underlying state associated with receive-side frame or escaping be reset.
command void resetSend() Requests that any underlying state associated with send-side frame delimiting or escaping be reset.

Events
event void dataReceived(uint8_t data) Signals the upper layer that a byte of data has been received from the serial connection.
event void delimiterReceived() Signals the upper layer that an inter-frame delimiter has been received from the serial connection.
event void putDone() Split-phase event to signal when the lower layer has finished writing the last request (either putDelimiter or putData) to serial.

Commands - Details

putData

command error_t putData(uint8_t data)

Used by the upper layer to request that a byte of data be sent over serial.

Parameters:
data - The byte to be sent
Returns:
Returns an error_t code that indicates if the lower layer has accepted the byte for sending (SUCCESS) or not (FAIL).

putDelimiter

command error_t putDelimiter()

Used by the upper layer to request that an interframe delimiter be sent. The lower layer is responsible for the determining the actual byte(s) that must be sent to delimit the frame.

Returns:
Returns a error_t code that indicates if the lower layer was able to put an interframe delimiter to serial (SUCCESS) or not (FAIL).

resetReceive

command void resetReceive()

Requests that any underlying state associated with receive-side frame or escaping be reset. Used to initialize the lower layer's receive path and/or cancel a frame mid-reception when sync is lost.

resetSend

command void resetSend()

Requests that any underlying state associated with send-side frame delimiting or escaping be reset. Used to initialize the lower layer's send path and/or cancel a frame mid-transmission.

Events - Details

dataReceived

event void dataReceived(uint8_t data)

Signals the upper layer that a byte of data has been received from the serial connection. It passes this byte as a function parameter.

Parameters:
data - The byte of data that has been received from the serial connection

delimiterReceived

event void delimiterReceived()

Signals the upper layer that an inter-frame delimiter has been received from the serial connection.

putDone

event void putDone()

Split-phase event to signal when the lower layer has finished writing the last request (either putDelimiter or putData) to serial.