Created
December 16, 2016 21:25
-
-
Save jbm9/f70dac4ab6d9065a75e487ea63241731 to your computer and use it in GitHub Desktop.
A quick gnuradio sketch that crashes reliably
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# The gist of it is: try to run a trivial spectrum-snarfing spectrum | |
# analyzer kind of thing. It will crash at some point pretty quickly | |
# on my B210. | |
# | |
# Sample run at the bottom | |
import time | |
from gnuradio import gr | |
from gnuradio import uhd | |
from gnuradio import blocks | |
samp_rate = 10000000 | |
gain = 10 | |
f_min = 100000000 # frequencies to scan at | |
f_max = 950000000 | |
f_step = samp_rate/2 | |
N = 32*1024 # grab this many samples at each frequency | |
TUNE_DELAY = 0.005 # if lo_locked is false, wait this long before checking again | |
tb = gr.top_block() | |
usrp_source = uhd.usrp_source(",", uhd.stream_args(cpu_format="fc32", channels=[0])) | |
usrp_source.set_samp_rate(samp_rate) | |
usrp_source.set_gain(gain, 0) | |
head = blocks.head(gr.sizeof_gr_complex, N) | |
agg = blocks.vector_sink_c() | |
tb.connect(usrp_source, head, agg) | |
freq_table = range(f_min, f_max, f_step) | |
while True: | |
print "Starting scan from %d to %d, by %d" % (f_min, f_max, f_step) | |
for f_c in freq_table: | |
tuneres = usrp_source.set_center_freq(f_c, 0) | |
while not usrp_source.get_sensor("lo_locked").to_bool(): | |
time.sleep(TUNE_DELAY) | |
tb.start() | |
time.sleep(1.5 * float(N) / samp_rate) # wait for samples, with padding | |
tb.stop() | |
data = agg.data() # fetch data and reset state | |
agg.reset() | |
head.reset() | |
print "%d: Got %d datapoints." % (f_c, len(data)) | |
############################## | |
# Example run: | |
# jbm@tunability:~$ python projects/uakari/code/crashem.py | |
# linux; GNU C++ version 4.8.4; Boost_105400; UHD_3.11.0.git-96-ga0c5ed6a | |
# -- Detected Device: B210 | |
# -- Operating over USB 3. | |
# ... happy stuff, including some happy printout | |
# ... and then unexpected sid errors, and then: | |
# UHD Error: | |
# recv packet demuxer unexpected sid 0x0 | |
# | |
# UHD Error: | |
# recv packet demuxer unexpected sid 0x0 | |
# | |
# UHD Error: | |
# recv packet demuxer unexpected sid 0x0 | |
# thread[thread-per-block[0]: <block gr uhd usrp source (1)>]: EnvironmentError: IOError: Radio ctrl (0) packet parse error - AssertionError: packet_info.packet_count == (seq_to_ack & 0xfff) | |
# in uint64_t radio_ctrl_core_3000_impl::wait_for_ack(bool) | |
# at /home/jbm/src/uhd/host/lib/usrp/cores/radio_ctrl_core_3000.cpp:264 | |
# | |
# thread[thread-per-block[0]: <block gr uhd usrp source (1)>]: EnvironmentError: IOError: Radio ctrl (0) packet parse error - AssertionError: packet_info.packet_count == (seq_to_ack & 0xfff) | |
# in uint64_t radio_ctrl_core_3000_impl::wait_for_ack(bool) | |
# at /home/jbm/src/uhd/host/lib/usrp/cores/radio_ctrl_core_3000.cpp:264 | |
# | |
# terminate called after throwing an instance of 'uhd::io_error' | |
# what(): EnvironmentError: IOError: Radio ctrl (0) packet parse error - AssertionError: packet_info.packet_count == (seq_to_ack & 0xfff) | |
# in uint64_t radio_ctrl_core_3000_impl::wait_for_ack(bool) | |
# at /home/jbm/src/uhd/host/lib/usrp/cores/radio_ctrl_core_3000.cpp:264 | |
# | |
# Aborted (core dumped) | |
# | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment