File "C:\program files (x86)\gnuradio\ieee802_examples\uhd_cc1k_txtest.py", line 165, in <module>
File "C:\program files (x86)\gnuradio\ieee802_examples\uhd_cc1k_txtest.py", line 146, in main
File "c:\program files (x86)\gnuradio\lib\site-packages\gnuradio\gr\top_block.py", line 97, in start
File "c:\program files (x86)\gnuradio\lib\site-packages\gnuradio\gr\gnuradio_core_runtime.py", line 1476, in start
RuntimeError: In hierarchical block cc1k_mod_pkts, input 0 is not connected internally
I want to use python to understand how all this USRP and GnuRadio thing works until I will make everything in C (interface and function calls).
from gnuradio import gr, eng_notation
from gnuradio import uhd
from gnuradio import audio
from gnuradio import ucla
from gnuradio.ucla_blks import cc1k_sos_pkt
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import math
import struct, time
##from gnuradio.wxgui import stdgui, fftsink, scopesink
##import wx
##def pick_subdevice(u):
## """
## The user didn't specify a subdevice on the command line.
## If there's a daughterboard on A, select A.
## If there's a daughterboard on B, select B.
## Otherwise, select A.
## """
## if u.db[0][0].dbid() >= 0: # dbid is < 0 if there's no d'board or a problem
## return (0, 0)
## if u.db[1][0].dbid() >= 0:
## return (1, 0)
## return (0, 0)
class transmit_path(gr.top_block):
def __init__(self, options):
gr.top_block.__init__(self)
self.normal_gain = 8000
self.data_rate = options.data_rate
self.samples_per_symbol = 8
self.fs = self.data_rate * self.samples_per_symbol
payload_size = 128 # bytes
print "data_rate = ", eng_notation.num_to_str(self.data_rate)
print "samples_per_symbol = ", self.samples_per_symbol
print "fs = ", eng_notation.num_to_str(self.fs)
self.u = uhd.usrp_sink('type=usrp1',
io_type=uhd.io_type.COMPLEX_FLOAT32,
num_channels=1)
## self.u.set_clock_config(uhd.clock_config.internal(), uhd.ALL_MBOARDS)
u = self.u
# Set and print sampling rate
self._samp_rate = 200000
self.u.set_samp_rate(self._samp_rate)
input_rate = self.u.get_samp_rate()
print "Sampling rate: %d" %(input_rate)
# Set and print center frequency
self.u.set_center_freq(options.cordic_freq)
frekva = self.u.get_center_freq()
print "Center frequency: %d" %(frekva)
# transmitter
self.packet_transmitter = cc1k_sos_pkt.cc1k_mod_pkts(self, spb=self.samples_per_symbol, msgq_limit=2)
self.amp = gr.multiply_const_cc (self.normal_gain)
self.filesink = gr.file_sink(gr.sizeof_gr_complex, 'tx_test.dat')
self.connect(self.amp, self.filesink)
self.connect(self.packet_transmitter, self.amp, self.u)
## self.set_gain(self.subdev.gain_range()[1])
# set max Tx gain
## self.set_auto_tr(True) # enable Auto Transmit/Receive switching
def set_gain(self, gain):
self.gain = gain
self.subdev.set_gain(gain)
def set_auto_tr(self, enable):
return
self.subdev.set_auto_tr(enable)
def send_pkt(self, payload='', eof=False):
return self.packet_transmitter.send_pkt(am_group=1, module_src=128, module_dst=128, dst_addr=65535, src_addr=2, msg_type=32, payload=payload, eof=eof)
def bitrate(self):
return self._bitrate
def spb(self):
return self.spb
def main ():
parser = OptionParser (option_class=eng_option)
parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
help="select USRP Tx side A or B (default=first one with a daughterboard)")
parser.add_option ("-c", "--cordic-freq", type="eng_float", default=434845200,
help="set Tx cordic frequency to FREQ", metavar="FREQ")
parser.add_option ("-r", "--data-rate", type="eng_float", default=38400)
parser.add_option ("-f", "--filename", type="string",
default="rx.dat", help="write data to FILENAME")
parser.add_option ("-g", "--gain", type="eng_float", default=0,
help="set Rx PGA gain in dB
[0,20]")
parser.add_option ("-N", "--no-gui", action="", default=False)
(options, args) = parser.parse_args ()
print "cordic_freq = %s" % (eng_notation.num_to_str(options.cordic_freq))
tb = transmit_path(options)
tb.start()
for i in range(100):
print "send message %d:"%(i+1,)
tb.send_pkt(payload=struct.pack('9B', 0x1, 0x80, 0x80, 0xff, 0xff, 0x10, 0x0, 0x20, 0x0))
time.sleep(0.1)
if __name__ == '__main__':
main ()