gr-sarsat-modern/python/sarsat/biphase_l_decode_bb.py
Ryan Malloy 5867c54de3 feat: port gr-sarsat to GNU Radio 3.10+
Ported from zleffke/gr-sarsat (2018, GNU Radio 3.7):
- Updated Python 2 → Python 3
- Converted XML block definitions to YAML
- Added pyproject.toml for modern packaging
- Preserved original MIT license

Blocks:
- biphase_l_decode_bb: Manchester decoder (decim_block)
- pds_frame_sync: Frame synchronizer with PDU output
- sarp_msg_extract: SARP message splitter/validator
2026-02-11 02:22:28 -07:00

46 lines
1.1 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# MIT License
# Copyright (c) 2018 zleffke
# Ported to GNU Radio 3.10+ by gr-mcp
"""
Biphase-L Decoder for Cospas-Sarsat 406 MHz beacons.
Biphase-L (Manchester) encoding represents:
- Bit 0: Low-to-High transition at bit center
- Bit 1: High-to-Low transition at bit center
This decoder extracts the data bit from each symbol pair.
"""
import numpy as np
from gnuradio import gr
class biphase_l_decode_bb(gr.decim_block):
"""
Biphase-L Decoder.
Input: Unpacked byte stream of Biphase-L encoded symbols (2 samples per bit).
Output: Unpacked byte stream of decoded bits.
Decimation factor: 2 (two input samples produce one output bit)
"""
def __init__(self):
gr.decim_block.__init__(
self,
name="biphase_l_decode_bb",
in_sig=[np.int8],
out_sig=[np.int8],
decim=2,
)
def work(self, input_items, output_items):
in0 = input_items[0]
out = output_items[0]
# Extract first sample of each symbol pair (the data bit value)
out[:] = in0[::2]
return len(output_items[0])