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
|
# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: GPL-3.0
#
# GNU Radio Python Flow Graph
# Title: Sync and create PDU
# 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
from .. import fixedlen_to_pdu
from ..grtypes import byte_t
import numpy
class sync_to_pdu(gr.hier_block2):
def __init__(self, packlen=0,
sync='00011010110011111111110000011101', threshold=4):
gr.hier_block2.__init__(
self,
'Sync and create PDU',
gr.io_signature(1, 1, gr.sizeof_char*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(
byte_t, 'syncword', packlen)
self.digital_correlate_access_code_tag_bb_0_0_0 = (
digital.correlate_access_code_tag_bb(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))
|