-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathReceiveUsrpControlAllSNRs.py
executable file
·161 lines (130 loc) · 6.65 KB
/
ReceiveUsrpControlAllSNRs.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
153
154
155
156
157
158
159
160
161
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: Receivedataautomated
# GNU Radio version: 3.7.13.5
##################################################
from gnuradio import blocks
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import uhd
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from optparse import OptionParser
import time
import sys
class ReceiveDataAutomated(gr.top_block):
def __init__(self):
gr.top_block.__init__(self, "Receivedataautomated")
##################################################
# Variables
##################################################
self.samp_rate = samp_rate = 1250000/5
self.carrier = carrier = 1500000000
Chain1FileName = sys.argv[1]
#Chain2FileName = sys.argv[1]+'_chain2.bin'
#Chain3FileName = sys.argv[1]+'_chain3.bin'
#Chain4FileName = sys.argv[1]+'_chain4.bin'
self.RXGainSlider = RXGainSlider = 18
self.NumSeconds = NumSeconds = int(sys.argv[2])
##################################################
# Blocks
##################################################
self.uhd_usrp_source_0 = uhd.usrp_source(
",".join(("addr=192.168.10.2", "")),
uhd.stream_args(
cpu_format="fc32",
channels=range(4),
),
)
self.uhd_usrp_source_0.set_samp_rate(samp_rate)
self.uhd_usrp_source_0.set_center_freq(carrier, 0)
self.uhd_usrp_source_0.set_gain(RXGainSlider, 0)
self.uhd_usrp_source_0.set_antenna('RX2', 0)
self.uhd_usrp_source_0.set_auto_dc_offset(True, 0)
self.uhd_usrp_source_0.set_auto_iq_balance(True, 0)
self.uhd_usrp_source_0.set_center_freq(carrier, 1)
self.uhd_usrp_source_0.set_gain(RXGainSlider, 1)
self.uhd_usrp_source_0.set_antenna('RX2', 1)
self.uhd_usrp_source_0.set_auto_dc_offset(True, 1)
self.uhd_usrp_source_0.set_auto_iq_balance(True, 1)
self.uhd_usrp_source_0.set_center_freq(carrier, 2)
self.uhd_usrp_source_0.set_gain(RXGainSlider, 2)
self.uhd_usrp_source_0.set_antenna('RX2', 2)
self.uhd_usrp_source_0.set_auto_dc_offset(True, 2)
self.uhd_usrp_source_0.set_auto_iq_balance(True, 2)
self.uhd_usrp_source_0.set_center_freq(carrier, 3)
self.uhd_usrp_source_0.set_gain(RXGainSlider, 3)
self.uhd_usrp_source_0.set_antenna('RX2', 3)
self.uhd_usrp_source_0.set_auto_dc_offset(True, 3)
self.uhd_usrp_source_0.set_auto_iq_balance(True, 3)
#self.blocks_head_0_2 = blocks.head(gr.sizeof_gr_complex*1, NumSeconds*samp_rate)
#self.blocks_head_0_1 = blocks.head(gr.sizeof_gr_complex*1, NumSeconds*samp_rate)
#self.blocks_head_0_0 = blocks.head(gr.sizeof_gr_complex*1, NumSeconds*samp_rate)
self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, NumSeconds*samp_rate)
self.blocks_file_sink_0_0_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, Chain1FileName, False)
self.blocks_file_sink_0_0_0_0.set_unbuffered(False)
#self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, Chain2FileName, False)
#self.blocks_file_sink_0_0_0.set_unbuffered(False)
#self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, Chain3FileName, False)
#self.blocks_file_sink_0_0.set_unbuffered(False)
#self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, Chain4FileName, False)
#self.blocks_file_sink_0.set_unbuffered(False)
self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_gr_complex*1)
self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
self.blocks_null_sink_0_2 = blocks.null_sink(gr.sizeof_gr_complex*1)
##################################################
# Connections
##################################################
self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0_0_0_0, 0))
#self.connect((self.blocks_head_0_0, 0), (self.blocks_file_sink_0_0_0, 0))
#self.connect((self.blocks_head_0_1, 0), (self.blocks_file_sink_0, 0))
#self.connect((self.blocks_head_0_2, 0), (self.blocks_file_sink_0_0, 0))
self.connect((self.uhd_usrp_source_0, 0), (self.blocks_head_0, 0))
#self.connect((self.uhd_usrp_source_0, 0), (self.blocks_null_sink_0_2, 0))
self.connect((self.uhd_usrp_source_0, 1), (self.blocks_null_sink_0_1, 0))
self.connect((self.uhd_usrp_source_0, 2), (self.blocks_null_sink_0_0, 0))
self.connect((self.uhd_usrp_source_0, 3), (self.blocks_null_sink_0, 0))
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.uhd_usrp_source_0.set_samp_rate(self.samp_rate)
#self.blocks_head_0_2.set_length(self.NumSeconds*self.samp_rate)
#self.blocks_head_0_1.set_length(self.NumSeconds*self.samp_rate)
#self.blocks_head_0_0.set_length(self.NumSeconds*self.samp_rate)
self.blocks_head_0.set_length(self.NumSeconds*self.samp_rate)
def get_carrier(self):
return self.carrier
def set_carrier(self, carrier):
self.carrier = carrier
self.uhd_usrp_source_0.set_center_freq(self.carrier, 0)
self.uhd_usrp_source_0.set_center_freq(self.carrier, 1)
self.uhd_usrp_source_0.set_center_freq(self.carrier, 2)
self.uhd_usrp_source_0.set_center_freq(self.carrier, 3)
def get_RXGainSlider(self):
return self.RXGainSlider
def set_RXGainSlider(self, RXGainSlider):
self.RXGainSlider = RXGainSlider
self.uhd_usrp_source_0.set_gain(self.RXGainSlider, 0)
self.uhd_usrp_source_0.set_gain(self.RXGainSlider, 1)
self.uhd_usrp_source_0.set_gain(self.RXGainSlider, 2)
self.uhd_usrp_source_0.set_gain(self.RXGainSlider, 3)
def get_NumSeconds(self):
return self.NumSeconds
def set_NumSeconds(self, NumSeconds):
self.NumSeconds = NumSeconds
#self.blocks_head_0_2.set_length(self.NumSeconds*self.samp_rate)
#self.blocks_head_0_1.set_length(self.NumSeconds*self.samp_rate)
#self.blocks_head_0_0.set_length(self.NumSeconds*self.samp_rate)
self.blocks_head_0.set_length(self.NumSeconds*self.samp_rate)
def main(top_block_cls=ReceiveDataAutomated, options=None):
if gr.enable_realtime_scheduling() != gr.RT_OK:
print "Error: failed to enable real-time scheduling."
tb = top_block_cls()
tb.start()
tb.wait()
if __name__ == '__main__':
main()