gr-sarsat-modern/src/sarsat/biphase_l_decode_bb.py
Ryan Malloy 66f20af368 refactor: convert to src-layout for Python packaging
Rename python/ to src/ following PEP 517/518 modern packaging
conventions. Also adds .gitignore for docs and build artifacts.
2026-02-17 18:45:27 -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])