Skip to content

Serial Protocol

The rpi-seism daemon communicates with the MCU via a high-speed, fixed-length binary protocol over RS-422 differential signaling.

Electrical Specs

  • Baud Rate: 250,000 (Fixed)
  • Data/Parity/Stop: 8-N-1
  • Voltage: ±2V (RS-422 Standard)
  • Flow Control: None (Heartbeat-based)

Hardware

  • MCU Transceiver: MAX490E
  • Cabling: Cat5/6 Twisted Pair
SignalCat5/6 ColorFunction
TXOrange/Orange-WhiteTransmit Positive
RXBlue/Blue-WhiteReceive Negative
GNDBrown/Brown-WhiteCommon Ground
VCCGreen/Green-White+12V power

Frequency: 100 Hz | Length: 16 Bytes

This packet carries the raw 24-bit triaxial seismic data.

OffsetSizeTypeFieldDescription
01uint8header_1Fixed marker 0xAA
11uint8header_2Fixed marker 0xBB
24int32_lech0Channel 0 (Vertical)
64int32_lech1Channel 1 (North/South)
104int32_lech2Channel 2 (East/West)
144uint32_lecrcCRC-32 (Bytes 0-13)

The ADS1256 returns signed 24-bit values, sign-extended to 32-bit integers for transmission:

  • Max Positive: 0x007FFFFF (+8,388,607)
  • Zero: 0x00000000
  • Max Negative: 0xFF800000 (-8,388,608)

Frequency: Once on startup | Length: 6 Bytes

On daemon initialization, settings are pushed to the MCU to sync sampling rates and analog gain.

  1. Daemon → MCU: Sends configuration packet [0xCC, 0xDD, RATE_L, RATE_H, GAIN, DRATE].
  2. MCU → Daemon: Echoes the exact same 6 bytes back.
  3. Daemon: Verifies the echo. If it matches, streaming begins. If no echo within 10s, it raises MCUNoResponse.
FieldDescriptionExample (100Hz, Gain 64)
sampling_speedOutput rate in Hz (uint16_le)0x64 0x00
adc_gainPGA enum (0-6)0x06
adc_data_rateADS1256 DRATE enum0x0B (2000 SPS)

We use the standard Ethernet/PKZip polynomial (0x04C11DB7). If a checksum fails, the daemon discards the packet and re-aligns the buffer to the next 0xAA 0xBB header.

from binascii import crc32
import struct
# Validate incoming buffer
payload = data[:-4]
calc_crc = crc32(payload) & 0xFFFFFFFF
rx_crc = struct.unpack("<I", data[-4:])[0]
if calc_crc == rx_crc:
# Packet is valid

To prevent the MCU from flooding the serial buffer if the daemon crashes, the MCU pauses streaming if it doesn’t receive a heartbeat for > 1 second.

  • Heartbeat: Single byte 0x01.
  • Interval: Sent by daemon every 500ms.

At 250kbps, the transmission overhead is minimal, leaving significant headroom for OS processing.

StageTime (ms)
Packet TX (128 bits)0.512 ms
USB-Serial Latency~0.200 ms
Daemon Processing~0.100 ms
Total Latency~0.812 ms
Available Headroom9.188 ms