Skip to content

System Architecture

The rpi-seism daemon is built on a producer-consumer pattern. It uses thread-safe queues to connect independent worker threads, ensuring that high-speed data acquisition is never blocked by slower operations like disk I/O or network latency.

  • Parallelism: Each job runs concurrently, utilizing multiple CPU cores.
  • Isolation: A failure in the WebSocket thread won’t stop data from being saved to disk.
  • Backpressure: Queues buffer spikes in data without dropping samples.
  • Clean Shutdown: Coordinated stop sequence ensures zero data loss on exit.

The daemon initializes five specialized threads on startup.

ThreadPriorityCPU %Responsibility
ReaderHigh5-10%Serial I/O, CRC validation, Queue distribution
MSeedWriterMedium2-5%MiniSEED generation, SDS Disk Archival
WSSenderMedium5-8%4x Decimation, JSON broadcasting
TriggerMedium1-3%Real-time STA/LTA event processing
NotifierLow<1%External alerts (Telegram, Email)

The Reader acts as the primary Producer. It pushes 16-byte validated packets into four independent queues:

  1. mseed_queue → MSeedWriter
  2. websocket_queue → WebSocketSender
  3. trigger_queue → TriggerProcessor
  4. notifier_queue → NotifierSender

The protocol uses fixed-length binary packets for efficiency over the RS-422 link.

Sent 100 times per second from the MCU.

OffsetTypeFieldDescription
0-1uint8header0xAA 0xBB marker
2-5int32ch0Channel 0 (Vertical)
6-9int32ch1Channel 1 (North/South)
10-13int32ch2Channel 2 (East/West)
14-17uint32crcCRC-32 Checksum

The daemon is designed to run on low-resource hardware like the Raspberry Pi 4/5.

  • MSeedWriter: Buffers 30 minutes of data (~2.2 MB total for 3 channels).
  • TriggerProcessor: Maintains a 20s rolling window for STA/LTA (~16 KB).
  • Event Buffer: On trigger, the Notifier captures 60s pre-event and 60s post-event (~144 KB).

Data is stored following the SeisComP Data Structure (SDS): archive/YEAR/NET/STA/CHAN.D/NET.STA.LOC.CHAN.D.YEAR.DOY


The daemon broadcasts two types of JSON messages:

  • Type 0 (Waveform): 25 Hz decimated data for live dashboards.
  • Type 1 (SOH): State-of-Health metrics (link quality, checksum errors) sent every 5s.
{
"type": 0,
"payload": {
"channel": "EHZ",
"fs": 25.0,
"data": [120, 135, 142]
}
}