File: sync_to_pdu_soft.py

package info (click to toggle)
gr-satellites 5.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,836 kB
  • sloc: python: 29,546; cpp: 5,448; ansic: 1,247; sh: 118; makefile: 24
file content (81 lines) | stat: -rw-r--r-- 2,478 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- coding: utf-8 -*-

#
# SPDX-License-Identifier: GPL-3.0
#
# GNU Radio Python Flow Graph
# Title: Sync and create PDU soft
# Author: Daniel Estevez
# Description: Finds syncword and creates a PDU of fixed size
# GNU Radio version: 3.8.0.0

from gnuradio import blocks
from gnuradio import digital
from gnuradio import gr
from gnuradio.filter import firdes
import sys
import signal
from .. import fixedlen_to_pdu
from ..grtypes import float_t
import numpy


class sync_to_pdu_soft(gr.hier_block2):
    def __init__(self, packlen=0,
                 sync='00011010110011111111110000011101', threshold=4):
        gr.hier_block2.__init__(
            self,
            'Sync and create PDU soft',
            gr.io_signature(1, 1, gr.sizeof_float*1),
            gr.io_signature(0, 0, 0),
        )
        self.message_port_register_hier_out('out')

        ##################################################
        # Parameters
        ##################################################
        self.packlen = packlen
        self.sync = sync
        self.threshold = threshold

        ##################################################
        # Blocks
        ##################################################
        self.fixedlen_to_pdu = fixedlen_to_pdu(
                float_t, 'syncword', packlen)
        self.digital_correlate_access_code_tag_bb_0_0_0 = (
            digital.correlate_access_code_tag_ff(sync, threshold, 'syncword'))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect(
            (self.fixedlen_to_pdu, 'pdus'), (self, 'out'))
        self.connect(
            (self.digital_correlate_access_code_tag_bb_0_0_0, 0),
            self.fixedlen_to_pdu)
        self.connect(
            (self, 0),
            (self.digital_correlate_access_code_tag_bb_0_0_0, 0))

    def get_packlen(self):
        return self.packlen

    def set_packlen(self, packlen):
        self.packlen = packlen

    def get_sync(self):
        return self.sync

    def set_sync(self, sync):
        self.sync = sync
        (self.digital_correlate_access_code_tag_bb_0_0_0
             .set_access_code(self.sync))

    def get_threshold(self):
        return self.threshold

    def set_threshold(self, threshold):
        self.threshold = threshold
        (self.digital_correlate_access_code_tag_bb_0_0_0
             .set_threshold(self.threshold))