Exemple #1
0
u.set_subdev_spec("A:AB", 0)
u.set_samp_rate(op.samplerate)

u.set_auto_dc_offset(False,0)


tt = time.time()
while tt-math.floor(tt) < 0.2 or tt-math.floor(tt) > 0.3:
    tt = time.time()
    time.sleep(0.01)
print("Latching at "+str(tt))
print(tt)
u.set_time_unknown_pps(uhd.time_spec(math.ceil(tt)+1.0))

op.starttime = math.ceil(time.time())+5
op.starttime = sampler_util.find_next(op.starttime,1)

u.set_start_time(uhd.time_spec(op.starttime))

fg = gr.top_block()
dst = []

win_len = op.window_len
window = numpy.array(numpy.real(scipy.signal.blackmanharris(win_len)),dtype=numpy.float64)
window.tofile("/data/phasecal/coeffs.bin")

# two channel decimating all double precision digital down converter
# with user defined filter coefficients.
# - 100 samples per file.
# - let the block know that the sample rate is 25 MHz also
# - expects real valued samples with channel 0 and 1 as interleaved little endian 16 bit ints.
Exemple #2
0
if op.stop_on_dropped == True:
    op.stop_on_dropped = 1
else:
    op.stop_on_dropped = 0

dst_0 = drf.digital_rf(op.dir0, int(op.filesize), int(3600),
                       2 * gr.sizeof_short, op.samplerate, 0,
                       op.stop_on_dropped)

# find next suitable launch time
if op.starttime is None:
    op.starttime = math.ceil(time.time())
    b = time.strftime("%Y.%m.%d_%H.%M.%S",
                      time.strptime(time.ctime(op.starttime)))

op.starttime = sampler_util.find_next(op.starttime, op.period)
if not op.nosync:
    u.set_start_time(uhd.time_spec(op.starttime))

fg.connect((u, 0), (dst_0, 0))

print "Launch time: ", op.starttime
print "Sample rate: ", op.samplerate
print "Main board: ", op.mboard
print "Frequency: ", op.centerfreq
print "Gains: ", op.gain
print "Starting time: ", op.starttime
print "Dir 0: ", op.dir0

sampler_util.write_metadata_drf(op.dir0,
                                1, [op.centerfreq],
Exemple #3
0

if op.stop_on_dropped == True:
    op.stop_on_dropped = 1
else:
    op.stop_on_dropped = 0

dst_0 = drf.digital_rf(op.dir0, int(op.filesize), int(3600), 2 * gr.sizeof_short, op.samplerate, 0, op.stop_on_dropped)
dst_1 = drf.digital_rf(op.dir1, int(op.filesize), int(3600), 2 * gr.sizeof_short, op.samplerate, 0, op.stop_on_dropped)

# find next suitable launch time
if op.starttime is None:
    op.starttime = math.ceil(time.time())
    b = time.strftime("%Y.%m.%d_%H.%M.%S", time.strptime(time.ctime(op.starttime)))

op.starttime = sampler_util.find_next(op.starttime, op.period)
if not op.nosync:
    u.set_start_time(uhd.time_spec(op.starttime))

fg.connect((u, 0), (dst_0, 0))
fg.connect((u, 1), (dst_1, 0))

print "Launch time: ", op.starttime
print "Sample rate: ", op.samplerate
print "Main board: ", op.mboard
print "Frequencies: ", op.centerfreqs
print "Gains: ", op.gain
print "Starting time: ", op.starttime
print "Dir 0: ", op.dir0
print "Dir 1: ", op.dir1
    def start(self):
        txlog = open("hftx.log", "w")
        tb = gr.top_block()
        sampler_util.real_time_scheduling()
        tstart_tx = time.time()
        tnow = time.time()
        dev_str = "addr=%s,send_buff_size=10000000" % (self.args.ip)
        sink = uhd.usrp_sink(
            device_addr=dev_str,
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                otw_format="sc16",
                channels=range(1),
            ),
        )
        self.print_info(sink.get_usrp_info(0))

        #async_msgq = gr.msg_queue(0)Commented by Alejandro
        #async_src = uhd.amsg_source("", async_msgq)Commented by Alejandro
        #        sink_msgsrc = uhd.amsg_source(uhd.device_addr(self.args.ip),sink_queue)

        sink.set_clock_source(self.args.clocksource, 0)
        sink.set_time_source(self.args.clocksource, 0)
        print(sink.get_mboard_sensor("ref_locked"))

        next_time = sampler_util.find_next(self.args.start_time,
                                           per=self.args.rep)
        print "Starting at ", next_time

        tt = time.time()
        while tt - math.floor(tt) < 0.3 or tt - math.floor(tt) > 0.5:
            tt = time.time()
            time.sleep(0.01)

        sink.set_time_unknown_pps(uhd.time_spec(math.ceil(tt) + 1.0))
        sink.set_start_time(
            uhd.time_spec(next_time + self.args.clockoffset / 1e6))

        sink.set_samp_rate(self.args.sample_rate)
        sink.set_center_freq(self.args.center_freq, 0)
        print "Actual center freq %1.8f Hz" % (sink.get_center_freq(0))
        print "===> self.args.gain: %s" % (self.args.gain)
        sink.set_gain(self.args.gain, 0)
        sink.set_antenna(self.args.txport, 0)
        #code_source = gr.file_source(gr.sizeof_gr_complex*1, self.args.codefile, True)
        code_vector = numpy.fromfile(self.args.codefile, dtype=numpy.complex64)
        code_source = blocks.vector_source_c(code_vector.tolist(), True)
        #multiply = gr.multiply_const_vcc((0.5, ))
        print "===> self.args.amplitude: %s" % (self.args.amplitude)
        multiply = blocks.multiply_const_vcc((self.args.amplitude, ))

        tb.connect(code_source, multiply, sink)
        #        tb.connect((async_src, msg), (sink_queue, 0))
        tb.start()
        self.print_info(sink.get_usrp_info(0))
        print "Starting"
        print "Restart time: " + str(self.args.restart_time)
        while (True):
            print("Cae0")
            tnow = time.time()
            if (tnow - tstart_tx) > self.args.restart_time:
                tb.stop()
                exit(0)
            print(sink.get_mboard_sensor("ref_locked"))
            print("Cae1")
            if self.args.clocksource == "gpsdo":
                txlog.write("%s %s\n" % (sampler_util.time_stamp(),
                                         sink.get_mboard_sensor("gps_locked")))
            print("Cae2")

            # print('Sensors names:\n')
            # print(sink.get_mboard_sensor_names())
            # print('\n')
            txlog.write("%s %s\n" % (sampler_util.time_stamp(),
                                     sink.get_mboard_sensor("ref_locked")))
            #txlog.write("%s %1.2f\n"%(sampler_util.time_stamp(),sink.get_time_now().get_real_secs()))
            txlog.write("%s\n" % (sampler_util.time_stamp()))
            print("Cae3")
            # if async_msgq.count(): The whole block was commented by Alejandro
            # 	print("Have no sense \n")
            # 	md = async_src.msg_to_async_metadata_t(async_msgq.delete_head())
            # 	txlog.write("%s async Channel: %i Time: %f Event: %i" % (sampler_util.time_stamp(),md.channel, md.time_spec.get_real_secs(), md.event_code))
            print("Cae4")
            txlog.flush()
            time.sleep(10.0)
            print("Cae5")
Exemple #5
0
    def start(self):
        txlog = open("hftx.log", "w")
        tb = gr.top_block()
        sampler_util.real_time_scheduling()  # DECLARATION OF SAMPLER_UTIL
        tstart_tx = time.time()
        tnow = time.time()
        dev_str = "addr=%s,send_buff_size=10000000" % (self.args.ip)
        sink = uhd.usrp_sink(
            device_addr=dev_str,
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                otw_format="sc16",
                channels=range(1),
            ),
        )
        self.print_info(sink.get_usrp_info(0))

        sink.set_clock_source(self.args.clocksource, 0)
        sink.set_time_source(self.args.clocksource, 0)
        print(sink.get_mboard_sensor("ref_locked"))

        next_time = sampler_util.find_next(self.args.start_time,
                                           per=self.args.rep)  # LENGTH OF TIME
        print "Starting at ", next_time

        tt = time.time()
        while tt - math.floor(tt) < 0.3 or tt - math.floor(tt) > 0.5:
            tt = time.time()
            time.sleep(0.01)

        sink.set_time_unknown_pps(uhd.time_spec(math.ceil(tt) + 1.0))
        sink.set_start_time(
            uhd.time_spec(next_time + self.args.clockoffset / 1e6))

        sink.set_samp_rate(self.args.sample_rate)
        sink.set_center_freq(self.args.center_freq, 0)
        print "Actual center freq %1.8f Hz" % (sink.get_center_freq(0))
        print "===> self.args.gain: %s" % (self.args.gain)
        sink.set_gain(self.args.gain, 0)
        sink.set_antenna(self.args.txport, 0)
        code_vector = numpy.fromfile(self.args.codefile, dtype=numpy.complex64)
        code_source = blocks.vector_source_c(code_vector.tolist(), True)
        print "===> self.args.amplitude: %s" % (self.args.amplitude)
        multiply = blocks.multiply_const_vcc((self.args.amplitude, ))

        tb.connect(
            code_source, multiply,
            sink)  # CONNECTIO BETWEEN BLOCKS CODIGO, GAIN, USRP i.e.(sink)
        tb.start()
        self.print_info(sink.get_usrp_info(0))
        print "Starting"
        print "Restart time: " + str(self.args.restart_time)
        while (True):
            tnow = time.time()
            if (tnow - tstart_tx) > self.args.restart_time:
                tb.stop()
                exit(0)
            print(sink.get_mboard_sensor("ref_locked"))
            print("Cae1")
            if self.args.clocksource == "gpsdo":
                txlog.write("%s %s\n" % (sampler_util.time_stamp(),
                                         sink.get_mboard_sensor("gps_locked")))
            txlog.write("%s %s\n" % (sampler_util.time_stamp(),
                                     sink.get_mboard_sensor("ref_locked")))
            txlog.write("%s\n" % (sampler_util.time_stamp()))
            txlog.flush()
            time.sleep(10.0)
Exemple #6
0
u.set_subdev_spec("A:AB", 0)
u.set_samp_rate(op.samplerate)

u.set_auto_dc_offset(False, 0)

tt = time.time()
while tt - math.floor(tt) < 0.2 or tt - math.floor(tt) > 0.3:
    tt = time.time()
    time.sleep(0.01)
print("Latching at " + str(tt))
print(tt)
u.set_time_unknown_pps(uhd.time_spec(math.ceil(tt) + 1.0))

op.starttime = math.ceil(time.time()) + 5
op.starttime = sampler_util.find_next(op.starttime, 1)

u.set_start_time(uhd.time_spec(op.starttime))

fg = gr.top_block()
dst = []

win_len = op.window_len
window = numpy.array(numpy.real(scipy.signal.blackmanharris(win_len)),
                     dtype=numpy.float64)
window.tofile("/data/phasecal/coeffs.bin")

# two channel decimating all double precision digital down converter
# with user defined filter coefficients.
# - 100 samples per file.
# - let the block know that the sample rate is 25 MHz also