From b7c06541c33486f778fbf133b3ea0f8983dc06b2 Mon Sep 17 00:00:00 2001 From: Dimitri Stolnikov Date: Tue, 12 Jun 2012 21:45:01 +0200 Subject: [PATCH] add virtual rtlsdr source and move both to 'Sources' category in GRC --- grc/CMakeLists.txt | 2 +- grc/gen_osmosdr_blocks.py | 24 ++++++++++++++++++++---- grc/osmosdr_block_tree.xml | 13 ------------- 3 files changed, 21 insertions(+), 18 deletions(-) delete mode 100644 grc/osmosdr_block_tree.xml diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index d30761e..0f253b5 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -32,6 +32,7 @@ macro(GEN_BLOCK_XML _generator _xml_block) ) endmacro(GEN_BLOCK_XML) +GEN_BLOCK_XML(gen_osmosdr_blocks.py rtlsdr_source_c.xml) GEN_BLOCK_XML(gen_osmosdr_blocks.py osmosdr_source_c.xml) #GEN_BLOCK_XML(gen_osmosdr_blocks.py osmosdr_sink_c.xml) @@ -39,7 +40,6 @@ add_custom_target(osmosdr_grc_xml_blocks ALL DEPENDS ${xml_blocks}) install(FILES ${xml_blocks} - osmosdr_block_tree.xml # DESTINATION ${GRC_BLOCKS_DIR} DESTINATION share/gnuradio/grc/blocks ) diff --git a/grc/gen_osmosdr_blocks.py b/grc/gen_osmosdr_blocks.py index ab11ed7..a36cca5 100644 --- a/grc/gen_osmosdr_blocks.py +++ b/grc/gen_osmosdr_blocks.py @@ -21,8 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA MAIN_TMPL = """\ - OsmoSDR $sourk.title() - osmosdr_$(sourk)_c + $(title) $sourk.title() + $(prefix)_$(sourk)_c + Sources 1 import osmosdr osmosdr.$(sourk)_c( args="nchan=" + str(\$nchan) + " " + \$args ) @@ -147,6 +148,7 @@ Otherwise, the user should specify one of the possible antenna choices. See the OsmoSDR project page for more detailed documentation: http://sdr.osmocom.org/trac/ http://sdr.osmocom.org/trac/wiki/GrOsmoSDR +http://sdr.osmocom.org/trac/wiki/rtl-sdr """ @@ -211,13 +213,25 @@ def parse_tmpl(_tmpl, **kwargs): max_num_channels = 5 +import os.path + if __name__ == '__main__': import sys for file in sys.argv[1:]: - if file.endswith ('source_c.xml'): + head, tail = os.path.split(file) + + if tail.startswith('rtlsdr'): + title = 'RTLSDR (official)' + prefix = 'rtlsdr' + elif tail.startswith('osmosdr'): + title = 'OsmoSDR' + prefix = 'osmosdr' + else: raise Exception, 'file %s has wrong syntax!'%tail + + if tail.endswith ('source_c.xml'): sourk = 'source' dir = 'out' - elif file.endswith ('sink_c.xml'): + elif tail.endswith ('sink_c.xml'): sourk = 'sink' dir = 'in' else: raise Exception, 'is %s a source or sink?'%file @@ -226,6 +240,8 @@ if __name__ == '__main__': open(file, 'w').write(parse_tmpl(MAIN_TMPL, max_nchan=max_num_channels, params=params, + title=title, + prefix=prefix, sourk=sourk, dir=dir, )) diff --git a/grc/osmosdr_block_tree.xml b/grc/osmosdr_block_tree.xml deleted file mode 100644 index 056cda1..0000000 --- a/grc/osmosdr_block_tree.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - OsmoSDR - osmosdr_source_c - -