forked from sdr/gr-osmosdr
grc: Convert XML GRC blocks to YML
Conversion done by Mickey Vänskä <mvaenskae@gmail.com> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
parent
982945a477
commit
e9890283ca
|
@ -18,28 +18,27 @@
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Rules for generating the source and sink xml wrappers
|
# Rules for generating the source and sink yml wrappers
|
||||||
########################################################################
|
########################################################################
|
||||||
include(GrPython)
|
include(GrPython)
|
||||||
|
|
||||||
macro(GEN_BLOCK_XML _generator _xml_block)
|
macro(GEN_BLOCK_YAML _generator _yaml_block)
|
||||||
set(generator ${CMAKE_CURRENT_SOURCE_DIR}/${_generator})
|
set(generator ${CMAKE_CURRENT_SOURCE_DIR}/${_generator})
|
||||||
set(xml_block ${CMAKE_CURRENT_BINARY_DIR}/${_xml_block})
|
set(yaml_block ${CMAKE_CURRENT_BINARY_DIR}/${_yaml_block})
|
||||||
list(APPEND xml_blocks ${xml_block})
|
list(APPEND yaml_blocks ${yaml_block})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
DEPENDS ${generator} OUTPUT ${xml_block}
|
DEPENDS ${generator} OUTPUT ${yaml_block}
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${generator} ${xml_block}
|
COMMAND ${PYTHON_EXECUTABLE} ${generator} ${yaml_block}
|
||||||
)
|
)
|
||||||
endmacro(GEN_BLOCK_XML)
|
endmacro(GEN_BLOCK_YAML)
|
||||||
|
|
||||||
GEN_BLOCK_XML(gen_osmosdr_blocks.py rtlsdr_source.xml)
|
GEN_BLOCK_YAML(gen_osmosdr_blocks.py rtlsdr_source.block.yml)
|
||||||
GEN_BLOCK_XML(gen_osmosdr_blocks.py osmosdr_source.xml)
|
GEN_BLOCK_YAML(gen_osmosdr_blocks.py osmosdr_source.block.yml)
|
||||||
GEN_BLOCK_XML(gen_osmosdr_blocks.py osmosdr_sink.xml)
|
GEN_BLOCK_YAML(gen_osmosdr_blocks.py osmosdr_sink.block.yml)
|
||||||
|
|
||||||
add_custom_target(osmosdr_grc_xml_blocks ALL DEPENDS ${xml_blocks})
|
add_custom_target(osmosdr_grc_yaml_blocks ALL DEPENDS ${yaml_blocks})
|
||||||
|
|
||||||
install(FILES
|
install(FILES
|
||||||
${xml_blocks}
|
${yaml_blocks}
|
||||||
# DESTINATION ${GRC_BLOCKS_DIR}
|
|
||||||
DESTINATION share/gnuradio/grc/blocks
|
DESTINATION share/gnuradio/grc/blocks
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,198 +19,144 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
"""
|
"""
|
||||||
|
|
||||||
MAIN_TMPL = """\
|
MAIN_TMPL = """\
|
||||||
<?xml version="1.0"?>
|
id: ${prefix}_${sourk}
|
||||||
<block>
|
label: '${title} ${sourk.title()}'
|
||||||
<name>$(title) $sourk.title()</name>
|
category: '[OsmoSDR]'
|
||||||
<key>$(prefix)_$(sourk)</key>
|
flags: throttle
|
||||||
<category>$($sourk.title())s</category>
|
|
||||||
<throttle>1</throttle>
|
parameters:
|
||||||
<import>import osmosdr</import>
|
- id: type
|
||||||
<import>import time</import>
|
label: '${direction.title()}put Type'
|
||||||
<make>osmosdr.$(sourk)( args="numchan=" + str(\$nchan) + " " + \$args )
|
dtype: enum
|
||||||
#for $m in range($max_mboards)
|
options: [fc32]
|
||||||
########################################################################
|
option_labels: [Complex Float32]
|
||||||
\#if \$num_mboards() > $m and \$clock_source$(m)()
|
option_attributes:
|
||||||
self.\$(id).set_clock_source(\$clock_source$(m), $m)
|
type: [fc32]
|
||||||
\#end if
|
hide: part
|
||||||
########################################################################
|
- id: args
|
||||||
\#if \$num_mboards() > $m and \$time_source$(m)()
|
label: 'Device Arguments'
|
||||||
self.\$(id).set_time_source(\$time_source$(m), $m)
|
dtype: string
|
||||||
\#end if
|
default: '""'
|
||||||
########################################################################
|
hide: ${'$'}{ 'none' if args else 'part'}
|
||||||
#end for
|
- id: sync
|
||||||
\#if \$sync() == 'sync'
|
label: Sync
|
||||||
self.\$(id).set_time_unknown_pps(osmosdr.time_spec_t())
|
dtype: enum
|
||||||
\#elif \$sync() == 'pc_clock'
|
options: [sync, pc_clock, none]
|
||||||
self.\$(id).set_time_now(osmosdr.time_spec_t(time.time()), osmosdr.ALL_MBOARDS)
|
option_labels: [Unknown PPS, PC Clock, Don't Sync]
|
||||||
\#end if
|
hide: ${'$'}{ 'none' if sync else 'part'}
|
||||||
self.\$(id).set_sample_rate(\$sample_rate)
|
- id: num_mboards
|
||||||
#for $n in range($max_nchan)
|
label: 'Number MBoards'
|
||||||
\#if \$nchan() > $n
|
dtype: int
|
||||||
self.\$(id).set_center_freq(\$freq$(n), $n)
|
default: 1
|
||||||
self.\$(id).set_freq_corr(\$corr$(n), $n)
|
options: [ ${", ".join([str(n) for n in range(1, max_mboards+1)])} ]
|
||||||
#if $sourk == 'source':
|
hide: part
|
||||||
self.\$(id).set_dc_offset_mode(\$dc_offset_mode$(n), $n)
|
% for m in range(max_mboards):
|
||||||
self.\$(id).set_iq_balance_mode(\$iq_balance_mode$(n), $n)
|
- id: clock_source${m}
|
||||||
self.\$(id).set_gain_mode(\$gain_mode$(n), $n)
|
label: 'MB${m}: Clock Source'
|
||||||
#end if
|
dtype: string
|
||||||
self.\$(id).set_gain(\$gain$(n), $n)
|
options: ['', internal, external, external_1pps, mimo, gpsdo]
|
||||||
self.\$(id).set_if_gain(\$if_gain$(n), $n)
|
option_labels: [Default, Internal, External, External 1PPS, MIMO Cable, O/B GPSDO]
|
||||||
self.\$(id).set_bb_gain(\$bb_gain$(n), $n)
|
hide: ${'$'}{ 'all' if not (num_mboards > ${m}) else ( 'none' if clock_source${m} else 'part' )}
|
||||||
self.\$(id).set_antenna(\$ant$(n), $n)
|
- id: time_source${m}
|
||||||
self.\$(id).set_bandwidth(\$bw$(n), $n)
|
label: 'MB${m}: Time Source'
|
||||||
\#end if
|
dtype: string
|
||||||
#end for
|
options: ['', external, mimo, gpsdo]
|
||||||
</make>
|
option_labels: [Default, External, MIMO Cable, O/B GPSDO]
|
||||||
<callback>set_sample_rate(\$sample_rate)</callback>
|
hide: ${'$'}{ 'all' if not (num_mboards > ${m}) else ( 'none' if time_source${m} else 'part' )}
|
||||||
#for $n in range($max_nchan)
|
% endfor
|
||||||
<callback>set_center_freq(\$freq$(n), $n)</callback>
|
- id: nchan
|
||||||
<callback>set_freq_corr(\$corr$(n), $n)</callback>
|
label: 'Number Channels'
|
||||||
#if $sourk == 'source':
|
dtype: int
|
||||||
<callback>set_dc_offset_mode(\$dc_offset_mode$(n), $n)</callback>
|
default: 1
|
||||||
<callback>set_iq_balance_mode(\$iq_balance_mode$(n), $n)</callback>
|
options: [ ${", ".join([str(n) for n in range(1, max_nchan+1)])} ]
|
||||||
<callback>set_gain_mode(\$gain_mode$(n), $n)</callback>
|
- id: sample_rate
|
||||||
#end if
|
label: 'Sample Rate (sps)'
|
||||||
<callback>set_gain(\$gain$(n), $n)</callback>
|
dtype: real
|
||||||
<callback>set_if_gain(\$if_gain$(n), $n)</callback>
|
default: samp_rate
|
||||||
<callback>set_bb_gain(\$bb_gain$(n), $n)</callback>
|
${params}
|
||||||
<callback>set_antenna(\$ant$(n), $n)</callback>
|
|
||||||
<callback>set_bandwidth(\$bw$(n), $n)</callback>
|
inputs:
|
||||||
#end for
|
- domain: message
|
||||||
<param>
|
id: command
|
||||||
<name>$(dir.title())put Type</name>
|
optional: true
|
||||||
<key>type</key>
|
% if sourk == 'source':
|
||||||
<type>enum</type>
|
|
||||||
<option>
|
outputs:
|
||||||
<name>Complex float32</name>
|
% endif
|
||||||
<key>fc32</key>
|
- domain: stream
|
||||||
<opt>type:fc32</opt>
|
dtype: ${'$'}{type.type}
|
||||||
</option>
|
multiplicity: ${'$'}{nchan}
|
||||||
</param>
|
% if sourk == 'sink':
|
||||||
<param>
|
|
||||||
<name>Device Arguments</name>
|
outputs:
|
||||||
<key>args</key>
|
- domain: message
|
||||||
<value></value>
|
id: async_msgs
|
||||||
<type>string</type>
|
optional: true
|
||||||
<hide>
|
% endif
|
||||||
\#if \$args()
|
|
||||||
none
|
templates:
|
||||||
\#else
|
imports: |-
|
||||||
part
|
import osmosdr
|
||||||
\#end if
|
import time
|
||||||
</hide>
|
make: |
|
||||||
</param>
|
osmosdr.${sourk}(
|
||||||
<param>
|
args="numchan=" + str(${'$'}{nchan}) + " " + ${'$'}{args}
|
||||||
<name>Sync</name>
|
)
|
||||||
<key>sync</key>
|
% for m in range(max_mboards):
|
||||||
<value></value>
|
${'%'} if context.get('num_mboards')() > ${m}:
|
||||||
<type>enum</type>
|
${'%'} if context.get('clock_source${m}')():
|
||||||
<hide>\#if \$sync() then 'none' else 'part'#</hide>
|
self.${'$'}{id}.set_clock_source(${'$'}{${'clock_source' + str(m)}}, ${m})
|
||||||
<option>
|
${'%'} endif
|
||||||
<name>unknown PPS</name>
|
${'%'} if context.get('time_source${m}')():
|
||||||
<key>sync</key>
|
self.${'$'}{id}.set_time_source(${'$'}{${'time_source' + str(m)}}, ${m})
|
||||||
</option>
|
${'%'} endif
|
||||||
<option>
|
${'%'} endif
|
||||||
<name>PC Clock</name>
|
% endfor
|
||||||
<key>pc_clock</key>
|
${'%'} if sync == 'sync':
|
||||||
</option>
|
self.${'$'}{id}.set_time_unknown_pps(osmosdr.time_spec_t())
|
||||||
<option>
|
${'%'} elif sync == 'pc_clock':
|
||||||
<name>don't sync</name>
|
self.${'$'}{id}.set_time_now(osmosdr.time_spec_t(time.time()), osmosdr.ALL_MBOARDS)
|
||||||
<key></key>
|
${'%'} endif
|
||||||
</option>
|
self.${'$'}{id}.set_sample_rate(${'$'}{sample_rate})
|
||||||
</param>
|
% for n in range(max_nchan):
|
||||||
<param>
|
${'%'} if context.get('nchan')() > ${n}:
|
||||||
<name>Num Mboards</name>
|
self.${'$'}{id}.set_center_freq(${'$'}{${'freq' + str(n)}}, ${n})
|
||||||
<key>num_mboards</key>
|
self.${'$'}{id}.set_freq_corr(${'$'}{${'corr' + str(n)}}, ${n})
|
||||||
<value>1</value>
|
${'%'} if context.get('sourk') == 'source':
|
||||||
<type>int</type>
|
self.${'$'}{id}.set_dc_offset_mode(${'$'}{${'dc_offset_mode' + str(n)}}, ${n})
|
||||||
<hide>part</hide>
|
self.${'$'}{id}.set_iq_balance_mode(${'$'}{${'iq_balance_mode' + str(n)}}, ${n})
|
||||||
#for $m in range(1, $max_mboards+1)
|
self.${'$'}{id}.set_gain_mode(${'$'}{${'gain_mode' + str(n)}}, ${n})
|
||||||
<option>
|
${'%'} endif
|
||||||
<name>$(m)</name>
|
self.${'$'}{id}.set_gain(${'$'}{${'gain' + str(n)}}, ${n})
|
||||||
<key>$m</key>
|
self.${'$'}{id}.set_if_gain(${'$'}{${'if_gain' + str(n)}}, ${n})
|
||||||
</option>
|
self.${'$'}{id}.set_bb_gain(${'$'}{${'bb_gain' + str(n)}}, ${n})
|
||||||
#end for
|
self.${'$'}{id}.set_antenna(${'$'}{${'ant' + str(n)}}, ${n})
|
||||||
</param>
|
self.${'$'}{id}.set_bandwidth(${'$'}{${'bw' + str(n)}}, ${n})
|
||||||
#for $m in range($max_mboards)
|
${'%'} endif
|
||||||
<param>
|
% endfor
|
||||||
<name>Mb$(m): Clock Source</name>
|
callbacks:
|
||||||
<key>clock_source$(m)</key>
|
- set_sample_rate(${'$'}{sample_rate})
|
||||||
<value></value>
|
% for n in range(max_nchan):
|
||||||
<type>string</type>
|
- set_center_freq(${'$'}{${'freq' + str(n)}}, ${n})
|
||||||
<hide>
|
- set_freq_corr(${'$'}{${'corr' + str(n)}}, ${n})
|
||||||
\#if not \$num_mboards() > $m
|
% if sourk == 'source':
|
||||||
all
|
- set_dc_offset_mode(${'$'}{${'dc_offset_mode' + str(n)}}, ${n})
|
||||||
\#elif \$clock_source$(m)()
|
- set_iq_balance_mode(${'$'}{${'iq_balance_mode' + str(n)}}, ${n})
|
||||||
none
|
- set_gain_mode(${'$'}{${'gain_mode' + str(n)}}, ${n})
|
||||||
\#else
|
% endif
|
||||||
part
|
- set_gain(${'$'}{${'gain' + str(n)}}, ${n})
|
||||||
\#end if
|
- set_if_gain(${'$'}{${'if_gain' + str(n)}}, ${n})
|
||||||
</hide>
|
- set_bb_gain(${'$'}{${'bb_gain' + str(n)}}, ${n})
|
||||||
<option><name>Default</name><key></key></option>
|
- set_antenna(${'$'}{${'ant' + str(n)}}, ${n})
|
||||||
<option><name>Internal</name><key>internal</key></option>
|
- set_bandwidth(${'$'}{${'bw' + str(n)}}, ${n})
|
||||||
<option><name>External</name><key>external</key></option>
|
% endfor
|
||||||
<option><name>External 1PPS</name><key>external_1pps</key></option>
|
|
||||||
<option><name>MIMO Cable</name><key>mimo</key></option>
|
documentation: |-
|
||||||
<option><name>O/B GPSDO</name><key>gpsdo</key></option>
|
The osmocom ${sourk} block:
|
||||||
</param>
|
|
||||||
<param>
|
|
||||||
<name>Mb$(m): Time Source</name>
|
|
||||||
<key>time_source$(m)</key>
|
|
||||||
<value></value>
|
|
||||||
<type>string</type>
|
|
||||||
<hide>
|
|
||||||
\#if not \$num_mboards() > $m
|
|
||||||
all
|
|
||||||
\#elif \$time_source$(m)()
|
|
||||||
none
|
|
||||||
\#else
|
|
||||||
part
|
|
||||||
\#end if
|
|
||||||
</hide>
|
|
||||||
<option><name>Default</name><key></key></option>
|
|
||||||
<option><name>External</name><key>external</key></option>
|
|
||||||
<option><name>MIMO Cable</name><key>mimo</key></option>
|
|
||||||
<option><name>O/B GPSDO</name><key>gpsdo</key></option>
|
|
||||||
</param>
|
|
||||||
#end for
|
|
||||||
<param>
|
|
||||||
<name>Num Channels</name>
|
|
||||||
<key>nchan</key>
|
|
||||||
<value>1</value>
|
|
||||||
<type>int</type>
|
|
||||||
#for $n in range(1, $max_nchan+1)
|
|
||||||
<option>
|
|
||||||
<name>$(n)</name>
|
|
||||||
<key>$n</key>
|
|
||||||
</option>
|
|
||||||
#end for
|
|
||||||
</param>
|
|
||||||
<param>
|
|
||||||
<name>Sample Rate (sps)</name>
|
|
||||||
<key>sample_rate</key>
|
|
||||||
<value>samp_rate</value>
|
|
||||||
<type>real</type>
|
|
||||||
</param>
|
|
||||||
$params
|
|
||||||
<check>$max_nchan >= \$nchan</check>
|
|
||||||
<check>\$nchan > 0</check>
|
|
||||||
<check>$max_mboards >= \$num_mboards</check>
|
|
||||||
<check>\$num_mboards > 0</check>
|
|
||||||
<check>\$nchan >= \$num_mboards</check>
|
|
||||||
<$sourk>
|
|
||||||
<name>$dir</name>
|
|
||||||
<type>\$type.type</type>
|
|
||||||
<nports>\$nchan</nports>
|
|
||||||
</$sourk>
|
|
||||||
<doc>
|
|
||||||
The osmocom $sourk block:
|
|
||||||
|
|
||||||
While primarily being developed for the OsmoSDR hardware, this block as well supports:
|
While primarily being developed for the OsmoSDR hardware, this block as well supports:
|
||||||
|
|
||||||
#if $sourk == 'source':
|
% if sourk == 'source':
|
||||||
* FUNcube Dongle through libgnuradio-fcd
|
|
||||||
* FUNcube Dongle Pro+ through gr-fcdproplus
|
|
||||||
* sysmocom OsmoSDR Devices through libosmosdr
|
* sysmocom OsmoSDR Devices through libosmosdr
|
||||||
* RTL2832U based DVB-T dongles through librtlsdr
|
* RTL2832U based DVB-T dongles through librtlsdr
|
||||||
* RTL-TCP spectrum server (see librtlsdr project)
|
* RTL-TCP spectrum server (see librtlsdr project)
|
||||||
|
@ -219,10 +165,10 @@ While primarily being developed for the OsmoSDR hardware, this block as well sup
|
||||||
* gnuradio .cfile input through libgnuradio-blocks
|
* gnuradio .cfile input through libgnuradio-blocks
|
||||||
* RFSPACE SDR-IQ, SDR-IP, NetSDR (incl. X2 option)
|
* RFSPACE SDR-IQ, SDR-IP, NetSDR (incl. X2 option)
|
||||||
* AirSpy Wideband Receiver through libairspy
|
* AirSpy Wideband Receiver through libairspy
|
||||||
#end if
|
% endif
|
||||||
#if $sourk == 'sink':
|
% if sourk == 'sink':
|
||||||
* gnuradio .cfile output through libgnuradio-blocks
|
* gnuradio .cfile output through libgnuradio-blocks
|
||||||
#end if
|
% endif
|
||||||
* CCCamp 2015 rad1o Badge through libhackrf
|
* CCCamp 2015 rad1o Badge through libhackrf
|
||||||
* Great Scott Gadgets HackRF through libhackrf
|
* Great Scott Gadgets HackRF through libhackrf
|
||||||
* Nuand LLC bladeRF through libbladeRF library
|
* Nuand LLC bladeRF through libbladeRF library
|
||||||
|
@ -245,8 +191,7 @@ Examples:
|
||||||
Optional arguments are placed into [] brackets, remove the brackets before using them! Specific variable values are separated with a |, choose one of them. Variable values containing spaces shall be enclosed in '' as demonstrated in examples section below.
|
Optional arguments are placed into [] brackets, remove the brackets before using them! Specific variable values are separated with a |, choose one of them. Variable values containing spaces shall be enclosed in '' as demonstrated in examples section below.
|
||||||
Lines ending with ... mean it's possible to bind devices together by specifying multiple device arguments separated with a space.
|
Lines ending with ... mean it's possible to bind devices together by specifying multiple device arguments separated with a space.
|
||||||
|
|
||||||
#if $sourk == 'source':
|
% if sourk == 'source':
|
||||||
fcd=0[,device=hw:2][,type=2]
|
|
||||||
miri=0[,buffers=32] ...
|
miri=0[,buffers=32] ...
|
||||||
rtl=serial_number ...
|
rtl=serial_number ...
|
||||||
rtl=0[,rtl_xtal=28.8e6][,tuner_xtal=28.8e6] ...
|
rtl=0[,rtl_xtal=28.8e6][,tuner_xtal=28.8e6] ...
|
||||||
|
@ -260,10 +205,10 @@ Lines ending with ... mean it's possible to bind devices together by specifying
|
||||||
cloudiq=127.0.0.1[:50000]
|
cloudiq=127.0.0.1[:50000]
|
||||||
sdr-iq=/dev/ttyUSB0
|
sdr-iq=/dev/ttyUSB0
|
||||||
airspy=0[,bias=0|1][,linearity][,sensitivity]
|
airspy=0[,bias=0|1][,linearity][,sensitivity]
|
||||||
#end if
|
% endif
|
||||||
#if $sourk == 'sink':
|
% if sourk == 'sink':
|
||||||
file='/path/to/your file',rate=1e6[,freq=100e6][,append=true][,throttle=true] ...
|
file='/path/to/your file',rate=1e6[,freq=100e6][,append=true][,throttle=true] ...
|
||||||
#end if
|
% endif
|
||||||
redpitaya=192.168.1.100[:1001]
|
redpitaya=192.168.1.100[:1001]
|
||||||
freesrp=0[,fx3='path/to/fx3.img',fpga='path/to/fpga.bin',loopback]
|
freesrp=0[,fx3='path/to/fx3.img',fpga='path/to/fpga.bin',loopback]
|
||||||
hackrf=0[,buffers=32][,bias=0|1][,bias_tx=0|1]
|
hackrf=0[,buffers=32][,bias=0|1][,bias_tx=0|1]
|
||||||
|
@ -282,7 +227,7 @@ The center frequency is the frequency the RF chain is tuned to.
|
||||||
Freq. Corr.:
|
Freq. Corr.:
|
||||||
The frequency correction factor in parts per million (ppm). Set to 0 if unknown.
|
The frequency correction factor in parts per million (ppm). Set to 0 if unknown.
|
||||||
|
|
||||||
#if $sourk == 'source':
|
% if sourk == 'source':
|
||||||
DC Offset Mode:
|
DC Offset Mode:
|
||||||
Controls the behavior of hardware DC offset corrrection.
|
Controls the behavior of hardware DC offset corrrection.
|
||||||
Off: Disable correction algorithm (pass through).
|
Off: Disable correction algorithm (pass through).
|
||||||
|
@ -304,7 +249,7 @@ Chooses between the manual (default) and automatic gain mode where appropriate.
|
||||||
To allow manual control of RF/IF/BB gain stages, manual gain mode must be configured.
|
To allow manual control of RF/IF/BB gain stages, manual gain mode must be configured.
|
||||||
Currently, only RTL-SDR devices support automatic gain mode.
|
Currently, only RTL-SDR devices support automatic gain mode.
|
||||||
|
|
||||||
#end if
|
% endif
|
||||||
RF Gain:
|
RF Gain:
|
||||||
Overall RF gain of the device.
|
Overall RF gain of the device.
|
||||||
|
|
||||||
|
@ -327,144 +272,100 @@ See the OsmoSDR project page for more detailed documentation:
|
||||||
http://sdr.osmocom.org/trac/wiki/GrOsmoSDR
|
http://sdr.osmocom.org/trac/wiki/GrOsmoSDR
|
||||||
http://sdr.osmocom.org/trac/wiki/rtl-sdr
|
http://sdr.osmocom.org/trac/wiki/rtl-sdr
|
||||||
http://sdr.osmocom.org/trac/
|
http://sdr.osmocom.org/trac/
|
||||||
</doc>
|
|
||||||
</block>
|
file_format: 1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# MAIN_TMPL = """\
|
||||||
|
# <block>
|
||||||
|
# <check>$max_nchan >= \$nchan</check>
|
||||||
|
# <check>\$nchan > 0</check>
|
||||||
|
# <check>$max_mboards >= \$num_mboards</check>
|
||||||
|
# <check>\$num_mboards > 0</check>
|
||||||
|
# <check>\$nchan >= \$num_mboards</check>
|
||||||
|
# </block>
|
||||||
|
# """
|
||||||
|
|
||||||
PARAMS_TMPL = """
|
PARAMS_TMPL = """
|
||||||
<param>
|
- id: freq${n}
|
||||||
<name>Ch$(n): Frequency (Hz)</name>
|
label: 'Ch${n}: Frequency (Hz)'
|
||||||
<key>freq$(n)</key>
|
dtype: real
|
||||||
<value>100e6</value>
|
default: 100e6
|
||||||
<type>real</type>
|
hide: ${'$'}{'none' if (nchan > ${n}) else 'all'}
|
||||||
<hide>\#if \$nchan() > $n then 'none' else 'all'#</hide>
|
- id: corr${n}
|
||||||
</param>
|
label: 'Ch${n}: Frequency Correction (ppm)'
|
||||||
<param>
|
dtype: real
|
||||||
<name>Ch$(n): Freq. Corr. (ppm)</name>
|
default: 0
|
||||||
<key>corr$(n)</key>
|
hide: ${'$'}{'none' if (nchan > ${n}) else 'all'}
|
||||||
<value>0</value>
|
% if sourk == 'source':
|
||||||
<type>real</type>
|
- id: dc_offset_mode${n}
|
||||||
<hide>\#if \$nchan() > $n then 'none' else 'all'#</hide>
|
label: 'Ch${n}: DC Offset Mode'
|
||||||
</param>
|
dtype: int
|
||||||
#if $sourk == 'source':
|
default: 0
|
||||||
<param>
|
options: [0, 1, 2]
|
||||||
<name>Ch$(n): DC Offset Mode</name>
|
option_labels: [Off, Manual, Automatic]
|
||||||
<key>dc_offset_mode$(n)</key>
|
hide: ${'$'}{'none' if (nchan > ${n}) else 'all'}
|
||||||
<value>0</value>
|
- id: iq_balance_mode${n}
|
||||||
<type>int</type>
|
label: 'Ch${n}: IQ Balance Mode'
|
||||||
<hide>\#if \$nchan() > $n then 'none' else 'all'#</hide>
|
dtype: int
|
||||||
<option>
|
default: 0
|
||||||
<name>Off</name>
|
options: [0, 1, 2]
|
||||||
<key>0</key>
|
option_labels: [Off, Manual, Automatic]
|
||||||
</option>
|
hide: ${'$'}{'none' if (nchan > ${n}) else 'all'}
|
||||||
<option>
|
- id: gain_mode${n}
|
||||||
<name>Manual</name>
|
label: 'Ch${n}: Gain Mode'
|
||||||
<key>1</key>
|
dtype: bool
|
||||||
</option>
|
default: False
|
||||||
<option>
|
options: [False, True]
|
||||||
<name>Automatic</name>
|
option_labels: [Manual, Automatic]
|
||||||
<key>2</key>
|
hide: ${'$'}{'none' if (nchan > ${n}) else 'all'}
|
||||||
</option>
|
% endif
|
||||||
</param>
|
- id: gain${n}
|
||||||
<param>
|
label: 'Ch${n}: RF Gain (dB)'
|
||||||
<name>Ch$(n): IQ Balance Mode</name>
|
dtype: real
|
||||||
<key>iq_balance_mode$(n)</key>
|
default: 10
|
||||||
<value>0</value>
|
hide: ${'$'}{'none' if (nchan > ${n}) else 'all'}
|
||||||
<type>int</type>
|
- id: if_gain${n}
|
||||||
<hide>\#if \$nchan() > $n then 'none' else 'all'#</hide>
|
label: 'Ch${n}: IF Gain (dB)'
|
||||||
<option>
|
dtype: real
|
||||||
<name>Off</name>
|
default: 20
|
||||||
<key>0</key>
|
hide: ${'$'}{'none' if (nchan > ${n}) else 'all'}
|
||||||
</option>
|
- id: bb_gain${n}
|
||||||
<option>
|
label: 'Ch${n}: BB Gain (dB)'
|
||||||
<name>Manual</name>
|
dtype: real
|
||||||
<key>1</key>
|
default: 20
|
||||||
</option>
|
hide: ${'$'}{'none' if (nchan > ${n}) else 'all'}
|
||||||
<option>
|
- id: ant${n}
|
||||||
<name>Automatic</name>
|
label: 'Ch${n}: Antenna'
|
||||||
<key>2</key>
|
dtype: string
|
||||||
</option>
|
default: ""
|
||||||
</param>
|
hide: ${'$'}{'all' if not (nchan > ${n}) else ('none' if eval('ant' + str(${n})) else 'part')}
|
||||||
<param>
|
- id: bw${n}
|
||||||
<name>Ch$(n): Gain Mode</name>
|
label: 'Ch${n}: Bandwidth (Hz)'
|
||||||
<key>gain_mode$(n)</key>
|
dtype: real
|
||||||
<value>False</value>
|
default: 0
|
||||||
<type>bool</type>
|
hide: ${'$'}{'all' if not (nchan > ${n}) else ('none' if eval('bw' + str(${n})) else 'part')}
|
||||||
<hide>\#if \$nchan() > $n then 'none' else 'all'#</hide>
|
|
||||||
<option>
|
|
||||||
<name>Manual</name>
|
|
||||||
<key>False</key>
|
|
||||||
</option>
|
|
||||||
<option>
|
|
||||||
<name>Automatic</name>
|
|
||||||
<key>True</key>
|
|
||||||
</option>
|
|
||||||
</param>
|
|
||||||
#end if
|
|
||||||
<param>
|
|
||||||
<name>Ch$(n): RF Gain (dB)</name>
|
|
||||||
<key>gain$(n)</key>
|
|
||||||
<value>10</value>
|
|
||||||
<type>real</type>
|
|
||||||
<hide>\#if \$nchan() > $n then 'none' else 'all'#</hide>
|
|
||||||
</param>
|
|
||||||
<param>
|
|
||||||
<name>Ch$(n): IF Gain (dB)</name>
|
|
||||||
<key>if_gain$(n)</key>
|
|
||||||
<value>20</value>
|
|
||||||
<type>real</type>
|
|
||||||
<hide>\#if \$nchan() > $n then 'none' else 'all'#</hide>
|
|
||||||
</param>
|
|
||||||
<param>
|
|
||||||
<name>Ch$(n): BB Gain (dB)</name>
|
|
||||||
<key>bb_gain$(n)</key>
|
|
||||||
<value>20</value>
|
|
||||||
<type>real</type>
|
|
||||||
<hide>\#if \$nchan() > $n then 'none' else 'all'#</hide>
|
|
||||||
</param>
|
|
||||||
<param>
|
|
||||||
<name>Ch$(n): Antenna</name>
|
|
||||||
<key>ant$(n)</key>
|
|
||||||
<value></value>
|
|
||||||
<type>string</type>
|
|
||||||
<hide>
|
|
||||||
\#if not \$nchan() > $n
|
|
||||||
all
|
|
||||||
\#elif \$ant$(n)()
|
|
||||||
none
|
|
||||||
\#else
|
|
||||||
part
|
|
||||||
\#end if
|
|
||||||
</hide>
|
|
||||||
</param>
|
|
||||||
<param>
|
|
||||||
<name>Ch$(n): Bandwidth (Hz)</name>
|
|
||||||
<key>bw$(n)</key>
|
|
||||||
<value>0</value>
|
|
||||||
<type>real</type>
|
|
||||||
<hide>
|
|
||||||
\#if not \$nchan() > $n
|
|
||||||
all
|
|
||||||
\#elif \$bw$(n)()
|
|
||||||
none
|
|
||||||
\#else
|
|
||||||
part
|
|
||||||
\#end if
|
|
||||||
</hide>
|
|
||||||
</param>
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def parse_tmpl(_tmpl, **kwargs):
|
|
||||||
from Cheetah import Template
|
|
||||||
return str(Template.Template(_tmpl, kwargs))
|
|
||||||
|
|
||||||
max_num_mboards = 8
|
def parse_tmpl(_tmpl, **kwargs):
|
||||||
max_num_channels = max_num_mboards*4
|
from mako.template import Template
|
||||||
|
from mako import exceptions
|
||||||
|
|
||||||
|
try:
|
||||||
|
block_template = Template(_tmpl)
|
||||||
|
return str(block_template.render(**kwargs))
|
||||||
|
except:
|
||||||
|
print(exceptions.text_error_template().render())
|
||||||
|
|
||||||
|
MAX_NUM_MBOARDS = 8
|
||||||
|
MAX_NUM_CHANNELS = MAX_NUM_MBOARDS * 4
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
for file in sys.argv[1:]:
|
for file in sys.argv[1:]:
|
||||||
head, tail = os.path.split(file)
|
head, tail = os.path.split(file)
|
||||||
|
|
||||||
|
@ -474,23 +375,32 @@ if __name__ == '__main__':
|
||||||
elif tail.startswith('osmosdr'):
|
elif tail.startswith('osmosdr'):
|
||||||
title = 'osmocom'
|
title = 'osmocom'
|
||||||
prefix = 'osmosdr'
|
prefix = 'osmosdr'
|
||||||
else: raise Exception, 'file %s has wrong syntax!'%tail
|
else:
|
||||||
|
raise Exception("file {} has wrong syntax!".format(tail))
|
||||||
|
|
||||||
if tail.endswith ('source.xml'):
|
if tail.endswith('source.block.yml'):
|
||||||
sourk = 'source'
|
sourk = 'source'
|
||||||
dir = 'out'
|
direction = 'out'
|
||||||
elif tail.endswith ('sink.xml'):
|
elif tail.endswith('sink.block.yml'):
|
||||||
sourk = 'sink'
|
sourk = 'sink'
|
||||||
dir = 'in'
|
direction = 'in'
|
||||||
else: raise Exception, 'is %s a source or sink?'%file
|
else:
|
||||||
|
raise Exception("is {} a source or sink?".format(file))
|
||||||
|
|
||||||
params = ''.join([parse_tmpl(PARAMS_TMPL, n=n, sourk=sourk) for n in range(max_num_channels)])
|
params = ''.join([
|
||||||
open(file, 'w').write(parse_tmpl(MAIN_TMPL,
|
parse_tmpl(PARAMS_TMPL, n=n, sourk=sourk)
|
||||||
max_nchan=max_num_channels,
|
for n in range(MAX_NUM_CHANNELS)
|
||||||
max_mboards=max_num_mboards,
|
])
|
||||||
|
|
||||||
|
open(file, 'w').write(
|
||||||
|
parse_tmpl(
|
||||||
|
MAIN_TMPL,
|
||||||
|
max_nchan=MAX_NUM_CHANNELS,
|
||||||
|
max_mboards=MAX_NUM_MBOARDS,
|
||||||
params=params,
|
params=params,
|
||||||
title=title,
|
title=title,
|
||||||
prefix=prefix,
|
prefix=prefix,
|
||||||
sourk=sourk,
|
sourk=sourk,
|
||||||
dir=dir,
|
direction=direction,
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue