Project_Detail
All_Projects

FederalMSKDecoder

C++ decoder for the Federal Signal Modem-MSK protocol (audio + complex IQ), with protocol and payload analysis

View on GitHub
README.md

FederalMSKDecoder

A from-scratch C++ decoder for the Federal Signal "Modem-MSK" digital signalling protocol — the 2FSK/MSK link used by Federal Signal sirens, mass-notification appliances, the SS2000+ encoder and the Commander Digital / SFCDware system.

It demodulates directly from audio (WAV/MP3) or from a complex-float IQ capture (gqrx / RTL-SDR / any CF32 baseband), recovers the 8N1 byte stream, assembles BEG … END frames, verifies the CRC and (optionally) decodes the known payload fields.

$ fsmsk --annotate Fsmsk_sample.mp3
input: Fsmsk_sample.mp3 | 48000 Hz | 12.648 s | mark=1200 space=1800 baud=1200 | sps=40.000
Frame #0 t=0.60s @byte 72  len=35  CRC OK (0x7AB0)
  40 40 40 72 60 60 00 40 40 40 60 6c 68 01 71 71 0d 03 ff 04 a4 06 e4 02 a2 1c 36 0b 0b 06 04 01 0b 06 04
  fields: 900 064  [21 data bytes]
Frame #1 t=1.86s @byte 223 len=35  CRC OK (0xBE7E)
  ...

Protocol

Parameter Value
Modulation 2FSK / Minimum-Shift Keying (MSK)
Mode NFM, ~6 kHz bandwidth
Baud rate 1200 baud
Mark (logic 1) 1200 Hz
Space (logic 0) 1800 Hz
Line coding UART-style 8N1, LSB-first
Preamble alternating bits (0x55 bytes)
Framing "BEG" + data + "END\0"
Error check CRC-16/XMODEM (poly 0x1021, init 0x0000), big-endian over the data

Payload numeric fields are 7-bit ASCII stored left-justified in a byte (char = ascii << 1), e.g. 0x40→SPACE, 0x60→'0' … 0x72→'9'.

Frame = "BEG" | 40 40 40 72 60 60 00 | 40 40 40 60 62 66 01 | <telemetry> | CRC16 | "END" 00
                        "   900"               "   013"

See research/ for a full capture decode and a payload write-up.

Build

Requires a C++17 compiler. On Windows, MSYS2 mingw-w64 is expected (a static binary is produced, no DLLs needed):

build.bat
:: or, if MSYS2 is elsewhere:
set MSYS2_ROOT=D:\msys64
build.bat

Or with a Makefile inside the MSYS2 MINGW64 shell:

make

The build vendors the public-domain minimp3 header so MP3 input works with no external dependencies.

Usage

fsmsk [options] <file>

Audio input (WAV / MP3)

fsmsk Fsmsk_sample.mp3
fsmsk recording.wav --annotate
fsmsk --invert recording.wav          # if mark/space are swapped

IQ input (complex-float32 baseband)

IQ files (.raw .iq .cf32 .fc .cfile) are auto-detected, or force with --iq. Specify the channel offset from the centre frequency with --offset:

fsmsk --offset 1770500 capture_154124100_4000000_fc.raw
fsmsk --fs 4000000 --offset 1770500 --start 1000 --dur 120 --audio-rate 24000 capture.raw

Options

  -m, --mark <hz>    mark frequency (logic 1)   [1200]
  -s, --space <hz>   space frequency (logic 0)  [1800]
  -b, --baud <rate>  symbol rate                [1200]
      --invert       swap mark/space polarity
      --raw          print raw decoded byte stream only
      --bits         print raw demodulated bit stream
      --no-crc       list frames even if CRC fails
      --annotate     decode known payload fields
  -q, --quiet        suppress header/info lines

IQ input:
      --iq               force IQ input
      --fs <hz>          IQ sample rate             [4000000]
      --offset <hz>      channel offset from centre [0]
      --audio-rate <hz>  demod audio rate           [25000]
      --start <sec>      skip to this time           [0]
      --dur <sec>        process only this long      [all]

How it works

  1. Channelise (IQ only): mix the selected offset to baseband, then multi-stage FIR decimation to the audio rate, then an FM discriminator → audio containing the 1200/1800 Hz tones.
  2. Symbol timing: a phase-bank search over overlapping windows (src/msk.cpp) picks the best sampling phase per window — robust to intermittent bursts and to clock drift over long captures.
  3. UART 8N1 de-serialisation (src/uart.cpp).
  4. Framing + CRC (src/framing.cpp, src/crc16.cpp).

Repository layout

src/            C++ sources
  main.cpp        CLI + sliding-window frame extraction
  msk.cpp/.h      FSK/MSK demodulator (discriminator, timing recovery)
  iq.cpp/.h       CF32 IQ front-end (mixer + multi-stage decimator)
  audio.cpp/.h    WAV reader + vendored minimp3
  uart.cpp/.h     8N1 de-serialiser
  framing.cpp/.h  BEG/END framing + payload annotator
  crc16.cpp/.h    CRC-16/XMODEM
  vendor/         minimp3.h (public domain)
tools/          Python reference decoder
research/       sample capture decode + payload notes
build.bat       Windows build script
Makefile        MSYS2 / Unix build

Notes

  • The protocol has no public specification. Everything here was derived by analysis of live captures; see research/ for the evidence trail.
  • The application-layer telemetry block (the bytes after the numeric fields) is only partially characterised — its position/layout is known, its meaning is not.
  • Recorded sample Fsmsk_sample.mp3 and the IQ-derived frame dump are provided for testing.

Third-party

  • minimp3 — CC0 1.0 (public domain).

Disclaimer

For research, interoperability and educational use. Ensure you comply with all applicable radio monitoring and privacy regulations in your jurisdiction.