-
Notifications
You must be signed in to change notification settings - Fork 33
/
secplus_tx.py
executable file
·152 lines (116 loc) · 4.85 KB
/
secplus_tx.py
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: GPL-3.0
#
# GNU Radio Python Flow Graph
# Title: Secplus Tx
# GNU Radio version: 3.10.9.2
from gnuradio import analog
from gnuradio import blocks
from gnuradio import filter
from gnuradio import gr
from gnuradio.filter import firdes
from gnuradio.fft import window
import sys
import signal
from argparse import ArgumentParser
from gnuradio.eng_arg import eng_float, intx
from gnuradio import eng_notation
import osmosdr
import time
import secplus_tx_secplus as secplus # embedded python module
class secplus_tx(gr.top_block):
def __init__(self, fixed=1234567890, freq=315150000, rolling=1234567890):
gr.top_block.__init__(self, "Secplus Tx", catch_exceptions=True)
##################################################
# Parameters
##################################################
self.fixed = fixed
self.freq = freq
self.rolling = rolling
##################################################
# Variables
##################################################
self.seq = seq = [0]*100 + secplus.encode_ook(rolling, fixed, fast=False)*4 + [0]*100
self.samp_rate = samp_rate = 2e6
##################################################
# Blocks
##################################################
self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_cc(0.1, 1)
self.osmosdr_sink_0 = osmosdr.sink(
args="numchan=" + str(1) + " " + ''
)
self.osmosdr_sink_0.set_time_unknown_pps(osmosdr.time_spec_t())
self.osmosdr_sink_0.set_sample_rate(samp_rate)
self.osmosdr_sink_0.set_center_freq((freq - 300e3), 0)
self.osmosdr_sink_0.set_freq_corr(0, 0)
self.osmosdr_sink_0.set_gain(0, 0)
self.osmosdr_sink_0.set_if_gain(47, 0)
self.osmosdr_sink_0.set_bb_gain(0, 0)
self.osmosdr_sink_0.set_antenna('', 0)
self.osmosdr_sink_0.set_bandwidth(0, 0)
self.blocks_vector_source_x_0 = blocks.vector_source_c(seq, False, 1, [])
self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, 1000)
self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 300e3, 0.9, 0, 0)
##################################################
# Connections
##################################################
self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
self.connect((self.blocks_multiply_xx_0, 0), (self.osmosdr_sink_0, 0))
self.connect((self.blocks_repeat_0, 0), (self.single_pole_iir_filter_xx_0, 0))
self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_repeat_0, 0))
self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_multiply_xx_0, 0))
def get_fixed(self):
return self.fixed
def set_fixed(self, fixed):
self.fixed = fixed
self.set_seq([0]*100 + secplus.encode_ook(self.rolling, self.fixed, fast=False)*4 + [0]*100)
def get_freq(self):
return self.freq
def set_freq(self, freq):
self.freq = freq
self.osmosdr_sink_0.set_center_freq((self.freq - 300e3), 0)
def get_rolling(self):
return self.rolling
def set_rolling(self, rolling):
self.rolling = rolling
self.set_seq([0]*100 + secplus.encode_ook(self.rolling, self.fixed, fast=False)*4 + [0]*100)
def get_seq(self):
return self.seq
def set_seq(self, seq):
self.seq = seq
self.blocks_vector_source_x_0.set_data(self.seq, [])
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
self.osmosdr_sink_0.set_sample_rate(self.samp_rate)
def argument_parser():
parser = ArgumentParser()
parser.add_argument(
"--fixed", dest="fixed", type=intx, default=1234567890,
help="Set Fixed code [default=%(default)r]")
parser.add_argument(
"-f", "--freq", dest="freq", type=intx, default=315150000,
help="Set Frequency [default=%(default)r]")
parser.add_argument(
"--rolling", dest="rolling", type=intx, default=1234567890,
help="Set Rolling code [default=%(default)r]")
return parser
def main(top_block_cls=secplus_tx, options=None):
if options is None:
options = argument_parser().parse_args()
tb = top_block_cls(fixed=options.fixed, freq=options.freq, rolling=options.rolling)
def sig_handler(sig=None, frame=None):
tb.stop()
tb.wait()
sys.exit(0)
signal.signal(signal.SIGINT, sig_handler)
signal.signal(signal.SIGTERM, sig_handler)
tb.start()
tb.wait()
if __name__ == '__main__':
main()