public
Last active

Testcase for timed commands. That fails.

  • Download Gist
continous_frequency_hopper
Python
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2013 Marcus Müller.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
 
from gnuradio import gr, blocks, uhd
class continous_frequency_hopper:
def __init__(self):
### Create blocks
self._tb = gr.top_block()
self.src = uhd.usrp_source(
"",
uhd.stream_args(
cpu_format="fc32",
channels=range(1) )
)
self.head = blocks.head(gr.sizeof_gr_complex, int(100e6))
self.sink = blocks.null_sink(gr.sizeof_gr_complex)
self.tag_debug = blocks.tag_debug(gr.sizeof_gr_complex, "src")
###setup USRP source
self.src.set_gain(30)
self.src.set_samp_rate(5e6)
self.src.set_center_freq(2e9)
###start flowgraph
self._tb.connect(self.src, self.head, self.sink)
self._tb.connect(self.src, self.tag_debug)
self._tb.start()
###get current timestamp
time_now = self.src.get_time_now().get_real_secs()
print("time: {:f} freq: {:f} MHz".format(time_now, self.src.get_center_freq()/1e6))
time_next = time_now + 1.0
next_spec = uhd.time_spec(time_next)
print("next time: {:f}".format(next_spec.get_real_secs()))
##issue timed command
self.src.set_command_time(next_spec)
self.src.set_center_freq(1e9)
print "called set_center_freq"
self.src.clear_command_time()
print "called clear_command_time"
###get current time again
time_now = self.src.get_time_now().get_real_secs()
print("time: {:f} freq: {:f} MHz".format(time_now, self.src.get_center_freq()/1e6))
 
if __name__ == "__main__":
continous_frequency_hopper()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.