Skip to content

Serial Communication

Serial communication with the ahoi modem uses a simple, self-synchronizing protocol that will be introduced in this document. Along with a basic description and reference implementation (in the C language), the user is referred to the MoSh (Modem Shell) for an easy, Python-based interface to the modem. The actual data format for communication is found in the packet format documentation.

Serial Interface

Hardware Interfacing

The modem communicates via a 3-wire (TX, RX, GND) UART interface. To enable signal decoupling, overvoltage protection, and denoising, an additional supply voltage is required. For interfacing with a computer, we recommend 3.3 volt FTDI (USB/serial) converter solutions. Interfacing with a microcontroller can be done directly; however, a supply is needed. We suggest that only 3.3V and 5V signals and supplies are used. Other configurations may not work or cause permanent damage to the modem.

Serial Line Configuration

The UART connection is configured as follows:

Parameter Value
baud rate 115.2 kbits/s
data bits 8
stop bits 1
parity none
handshake none

Serial Protocol

Serial communication uses a simple, self-synchronizing protocol that

  • prepends a start sequence,
  • appends a stop sequence,
  • requires escaping.

The escape character is 0x10 (DLE). It precedes each start symbol 0x02 (STX) and each end symbol 0x03 (ETX). Each occurrence of the escape character in the data stream (between start and end symbol) must be escaped (by the escape character).

A data packet exchanged between modem and host has the format:

10 02 <packet> 10 03

where each occurrence of the octet 0x10 in the packet must be escaped by 0x10.

Example

Host A sends the four 8-bit unsigned integer values 0, 16, 32, and 64 via attached modem 1 to host B via its connected modem 2. The packet type is 16.

Host A prepares the packet (hex format)

01 02 10 00 00 04 00 10 20 40

and sends it over the serial line (hex format):

10 02 01 02 10 10 00 00 04 00 10 10 20 40 10 03

Please note the (highlighted) start and end sequences plus escaping of the packet octet(s) with value 0x10. Modem 1 transmits the (deserialized) packet that is received by modem 2. Modem 2 prepares the packet (including footer):

01 02 10 00 00 04 00 10 20 40 10 11 00 0A 09 0A

In this example, receive level is 16 (0x10) and RSSI is 17 (0x11), there are zero bit errors, and during reception mean gain was 10 (0x0A), minimum gain 9 (0x09), and maximum gain 10 (0x0A). Please refer to the packet format specification. Finally, modem 2 sends to its connected host B via serial line:

10 02 01 02 10 10 00 00 04 00 10 10 20 40 10 10 11 00 0A 09 0A 10 03

Please note the (highlighted) start and end sequences plus escaping of the packet octet(s) with value 0x10.

Reference Implementations

Reference implementations of the serial encoding are available in

  • as part of the modem firmware (`src/serial_enc.h' in C) and
  • part of the PyLib (in Python).