Hostmote Protocol

From CSL Wiki

Jump to: navigation, search

Contents

Frame Format


hostmote_header_t:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| frame1 (0x74) | frame2 (0x19) | backup_len (poor man's crc)   | 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| opnum         | subop         | datalen_msb   | datalen_lsb   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| seqnum        | padding       | crc                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| data (up to 2^16 - 1) ...                                     |

All messages have this frame format. The following are types of messages that are encapsulated in the data portion of the hostmote_header:

data_hdr_t:
+-+-+-+-+-+-+-+-+
| seqno         |
+-+-+-+-+-+-+-+-+

data_ack_pkt_t:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| seqno         | errcode       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

senddone_pkt_t:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| seqno         | retval        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

There are configuration headers:

mote_conf_request_t:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| set_flags     | pot           | saddr                         | 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| lpltx         | lplrx         | 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

mote_conf_hdr_t:
+-+-+-+-+-+-+-+-+
| type          |  
+-+-+-+-+-+-+-+-+

options: BMAC_CONF, SMAC_CONF

A large configuration message for bmac:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| version       | mtu           | saddr                         | 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| serialCrcErrors               | pktCrcErrors                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| txBytes                                                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| txPkts                                                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| rxBytes                                                       |      
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| rxPkts                                                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| rxDrops                                                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| pkts_queued                   | txErrors                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| pot           | lpl_tx        | lpl_rx        | max_queue_size|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+



the uart_tx_state is -1 if transmitter is idle; if busy, it holds the byte number of the uart_tx_msg that we are transmitting.

Initializing a connection

PC sends a soft reset (opnum = HOSTMOTE_RST, subop = SOFT_RESET). PC requests status (opnum = HOSTMOTE_CONF, subop = CONF_STAT) and sets a timeout for reply. PC receives a CONF message from the mote

States

  • HM_UART_TX_STATE_IDLE
  • HM_UART_RX_STATE__IDLE
  • HM_UART_RX_STATE_FRAME_1_RCVD
  • HM_UART_RX_STATE_FRAME_2_RCVD
  • HM_UART_RX_STATE_HDR_RCVD
  • HM_UART_RX_STATE_PKT_RCVD

Mote receive state machine

HM_UART_RX_STATE_IDLE:
receive a HOSTMOTE_FRAME_1 byte -> HM_UART_RX_STATE_FRAME_1_RCVD

HM_UART_RX_STATE_FRAME_1_RCVD:
receive a HOSTMOTE_FRAME_2 byte -> HM_UART_RX_STATE_FRAME_2_RCVD
receive a HOSTMOTE_FRAME_1 byte -> HM_UART_RX_STATE_FRAME_1_RCVD
receive any other byte, garbage -> HM_UART_RX_STATE_IDLE

HM_UART_RX_STATE_FRAME_2_RCVD:
received header and length < 0  -> HM_UART_RX_STATE_IDLE
received header and length == 0 -> HM_UART_RX_STATE_PKT_RCVD
received header and length > 0  -> HM_UART_RX_STATE_HDR_RCVD

HM_UART_RX_STATE_HDR_RCVD:
received "length" payload bytes -> HM_UART_RX_STATE_PKT_RCVD 

HM_UART_RX_STATE_PKT_RCVD:
check crc (either way)          -> HM_UART_RX_STATE_IDLE
Personal tools