Serial Format
The OpenWSN stack communicates with the OpenVisualizer over a serial connection. This pages describes the format of the serial frames whizzing back-and-forth between the mote and the computer. Note that all motes running the OpenWSN stack can communicate of their serial port, not just the DAGroot in the network.
General Format
Packet are framed using HDLC, defined in RFC1662:
flags | payload | CRC | flag |
---|---|---|---|
1B | arbitrary | 2B | 1B |
0x7e | see below | 0x7e |
A couple of points to note:
- The opening and closing flags are the same (
0x7e
). This is because this character can be used, in the HDLC standard, as "keep-alive" messages. A frame really starts when receiving a byte different from0x7e
. - The CRC used is a 16-bit with generator polynomial:
x^0 + x^5 + x^12 + x^16
. You can see an implementation example in Appendix C of RFC1662.
Frames Sent by Mote
This section covers the format of the frames sent by the mote to the computer.
General Format
The payload of the HDLC frame has the following format:
type | payload |
---|---|
1B | arbitrary |
The type field can take the following values:
name | value | description |
---|---|---|
SERFRAME_MOTE2PC_DATA | 'D' | This frame contains some sensor data, starting with the 6LoWPAN header. |
SERFRAME_MOTE2PC_STATUS | 'S' | This frame contains some status information about the mote. |
SERFRAME_MOTE2PC_INFO | 'I' | This frame contains some event of severity level "info". |
SERFRAME_MOTE2PC_ERROR | 'E' | This frame contains some event of severity level "error". |
SERFRAME_MOTE2PC_CRITICAL | 'C' | This frame contains some event of severity level "critical". |
SERFRAME_MOTE2PC_REQUEST | 'R' | Invites the computer to send data to the mote. See below. |
SERFRAME_MOTE2PC_DATA
Frame
This type of frame is generated by the DAGroot when it receives data from a mote in its network. The payload contains the data itself, prepended by the 6LoWPAN header.
The OpenVisualizer, which receives this frame, hand it off as is to the LBR which de-compacts the 6LoWPAN header and injects it into the IPv6 Internet. The OpenVisualizer does no do any form of checking on this packet, i.e. any payload with the "data" header type is forwarded to the LBR. The LBR ensures that the packet is a value 6LoWPAN packet, but does not do any validation on the payload, which it sends as-is into the IPv6 Internet.
On the mote side, a data frame is generated by calling the openserial_printData()
function.
On the Python side, the data frame is handled by the ParserData
module.
SERFRAME_MOTE2PC_STATUS
Frame
This type of frame is used by the mote to continuously report the status of internal modules. The payload is parsed by the OpenVisualizer, the state of the different modules is stored and displayed in the "mote status" menu of the OpenVisualizer.
The format of a status frame is:
16b address | type | payload |
---|---|---|
2B | 1B | arbitrary |
The type dictates the format of the payload. The format is giving by a (packet) C struct, as per the table below:
name | type value | length/struct format | description |
---|---|---|---|
ISSYNC | 0 | 1 byte | Indicates whether the mote is synchronized to the network (0x01 ) or not (0x00 ). |
ID | 1 | debugIDManagerEntry_t | Contains all the IDs of a mote: 16B, 64B, IPv6, etc. |
DAGRANK | 2 | 1 byte | Indicates the RPL DAGrank of this mote. |
OUTBUFFERINDEXES | 3 | 2 bytes | Indicates the value of the read and write indexes in the serial module. |
ASN | 4 | asn_t | Indicates the current value of IEEE802.15.4e's Absolute Slot Number. |
MACSTATS | 5 | ieee154e_stats_t | Contains the stats gathered by IEEE802.15.4e. |
SCHEDULE | 6 | debugScheduleEntry_t | Contains a row of the schedule used by IEEE802.15.4e. A different row is reported each time. |
BACKOFF | 7 | 2 bytes | Indicates the current value of the backoff and backoff exponent, used for shared slots in IEEE802.15.4e |
QUEUE | 8 | debugOpenQueueEntry_t | Indicates the creator and owner of an entry in the OpenQueue. A different entry is reported each time. |
NEIGHBORS | 9 | debugNeighborEntry_t | Contains a row of the neighbor table of the mote. A different row is reported each time. |
KAPERIOD | 10 | 2 bytes | Indicates the IEEE802.15.4e Keep Alive period. |
On the mote side, a status frame is generated by calling the openserial_printStatus()
function. This is orchestrated by the openserial
module.
On the Python side, status frames are handled by the ParserStatus
module.
SERFRAME_MOTE2PC_INFO
, SERFRAME_MOTE2PC_ERROR
and SERFRAME_MOTE2PC_CRITICAL
Frames
SERFRAME_MOTE2PC_INFO
SERFRAME_MOTE2PC_CRITICAL
These frames are printed by the mote when it encounters some error case. They have the following format:
severity | 16b address | calling component | error code | arg1 | arg2 |
---|---|---|---|---|---|
1B | 2B | 1B | 1B | 2B | 2B |
- The severity indicates the type of frame:
INFO
,ERROR
orCRITICAL
(see table above for value). - The calling component indicates which component in the stack is reporting this error. The value is taken from the
COMPONENT_*
enum in theopenwsn.h
file. - The error code is taken from the
ERR_*
enum in theopenwsn.h
file. - The value of arg1 and arg2 depends on the error code passed. Refer to the comment in the corresponding in
openwsn.h
.
REQUEST
Frame
This frame is used by the mote to indicate to the computer it is ready to receive data. Some hardware platform supported by OpenWSN are too constrained to be able to receive at all time. Instead, some slots in the schedule are of type SERIAL_RX
. At the beginning of those, the mote sends out a request frame, indicating that it can now receive data. It is the responsibility of the computer to answer "fast", i.e. before the end of the (possible multiple) SERIAL_RX
slots.
The request frame has no payload.
Frames Sent by Computer
This section details the format of the frames sent by the computer to the mote. The computer can only do so after receiving a request frame from the mote.
General Format
The payload of the HDLC frame has the following format:
type | payload |
---|---|
1B | arbitrary |
The type field can take the following values:
name | value | description |
---|---|---|
SERFRAME_PC2MOTE_SETROOT | 'R' | Set, clear or toggle whether the mote is DAGroot. |
SERFRAME_PC2MOTE_DATA | 'D' | Inject data. |
SERFRAME_PC2MOTE_TRIGGERSERIALECHO | 'S' | Trigger a serial echo. |
SERFRAME_PC2MOTE_COMMAND_GD | 'G' | Set mote/network parameter. |
SERFRAME_PC2MOTE_SETROOT
Frame
SERFRAME_PC2MOTE_SETROOT
The format of the SETROOT
frame is as follows:
action | prefix |
---|---|
1B | 8B |
The action
field can take the following values:
name | value | description |
---|---|---|
ACTION_YES | 'Y' | Switch the root or bridge mode on. |
ACTION_NO | 'N' | Switch the root or bridge mode off. |
ACTION_TOGGLE | 'T' | Toggle the root or bridge mode. |
the prefix
field contains the IPv6 prefix of the network. The DAGroot will announce this value in its DIOs.
SERFRAME_PC2MOTE_DATA
Frame
SERFRAME_PC2MOTE_DATA
DATA
frame format:
next hop address | 6LoWPAN header and payload |
---|---|
8B | variable |
This frame passes a 6LoWPAN message from a DAGroot mote into the mesh. The openbridge
module performs minimal checking on the message, the sixtop
module prepends the 802.15.4 header, and then the message is transmitted.
On the Python side, the OpenLbr
module does the work of converting an incoming IPv6 message into the required 6LoWPAN format, including any source routing headers from the RPL
module.
SERFRAME_PC2MOTE_TRIGGERSERIALECHO
Frame
SERFRAME_PC2MOTE_TRIGGERSERIALECHO
The format of the TRIGGERSERIALECHO frame is as follows:
info | value | description |
---|---|---|
STACKNAME | 'S' | Echo the name of stack |
VERSION_MAJOR | 'M' | Echo the major version of stack |
VERSION_MINOR | 'm' | Echo the minor version of stack |
VERSION_PATCH | 'P' | Echo the patch version of stack |
When mote receives this frame with info STACKNAME, it sends back the name of stack, which is "OpenWSN".
SERFRAME_PC2MOTE_COMMAND_GD
Frame
SERFRAME_PC2MOTE_COMMAND_GD
TODO Thomas Watteyne