Skip to content
Snippets Groups Projects
Commit 65b35193 authored by Sergey Musikhin's avatar Sergey Musikhin
Browse files

python bindings for ctor

parent 2d1a6982
Branches
No related tags found
No related merge requests found
......@@ -120,7 +120,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [568, 124.0]
coordinate: [576, 140.0]
rotation: 0
state: true
- name: audio_sink_0
......@@ -137,7 +137,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [1088, 300.0]
coordinate: [944, 204.0]
rotation: 0
state: true
- name: bladeRF_source_0
......@@ -145,7 +145,6 @@ blocks:
parameters:
affinity: ''
alias: ''
args: '""'
bb_gain0: '20'
bb_gain1: '20'
bias_tee0: 'False'
......@@ -158,7 +157,8 @@ blocks:
dac: '10000'
dc_offset_mode0: '0'
dc_offset_mode1: '0'
fpga_image: ''
device_id: '0'
fpga_image: test
freq0: freq
freq1: 1e8
gain0: '10'
......@@ -175,16 +175,16 @@ blocks:
nchan: '1'
out_clk: 'False'
power_monitoring: 'False'
ref_clk: ''
ref_clk: '1000000'
sample_rate: samp_rate
type: fc32
xb_2000: 222M
xb_2001: auto
verbosity: silent
xb200: auto3db
states:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [16, 92.0]
coordinate: [48, 92.0]
rotation: 0
state: true
- name: blocks_multiply_const_vxx_0
......@@ -202,7 +202,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [896, 348.0]
coordinate: [776, 300.0]
rotation: 0
state: true
- name: rational_resampler_xxx_0
......@@ -222,7 +222,7 @@ blocks:
bus_sink: false
bus_source: false
bus_structure: null
coordinate: [336, 108.0]
coordinate: [368, 124.0]
rotation: 0
state: true
......
......@@ -34,11 +34,11 @@ parameters:
type: [fc32]
hide: part
- id: args
- id: device_id
label: 'Device'
dtype: string
default: '""'
hide: ${'$'}{ 'none' if args else 'part'}
default: '0'
hide: ${'$'}{ 'none' if device_id else 'part'}
- id: nchan
label: 'Number Channels'
......@@ -88,6 +88,13 @@ parameters:
dtype: real
default: 10000
- id: xb200
label: 'XB-200'
dtype: enum
default: auto
options: ['auto', 'auto3db', '50M', '144M', '222M', 'custom']
option_labels: ['auto', 'auto3db', '50M', '144M', '222M', 'custom']
${params}
......@@ -116,9 +123,17 @@ templates:
import time
make: |
bladeRF.${sourk}(
args="numchan=" + str(${'$'}{nchan}) + ","
+ "verbosity=" + '${'$'}{verbosity}'
+ ${'$'}{args}
args="numchan=" + str(${'$'}{nchan})
+ ",type=" + '${'$'}{type}'
+ ",bladerf=" + str(${'$'}{device_id})
+ ",verbosity=" + '${'$'}{verbosity}'
+ ",fpga=" + str(${'$'}{fpga_image})
+ ",power_monitoring=" + str(${'$'}{power_monitoring})
+ ",ref_clk=" + str(${'$'}{ref_clk})
+ ",in_clk=" + '${'$'}{in_clk}'
+ ",out_clk=" + str(${'$'}{out_clk})
+ ",dac=" + str(${'$'}{dac})
+ ",xb200=" + '${'$'}{xb200}'
)
self.${'$'}{id}.set_sample_rate(${'$'}{sample_rate})
% for n in range(max_nchan):
......@@ -258,14 +273,6 @@ PARAMS_TMPL = """
default: False
hide: ${'$'}{'none' if (nchan > ${n}) else 'all'}
- id: xb_200${n}
label: 'Ch${n}: XB-200'
dtype: enum
default: auto
options: ['auto', 'auto3db', '50M', '144M', '222M', 'custom']
option_labels: [auto, auto3db, 50M, 144M, 222M, custom]
hide: ${'$'}{'none' if (nchan > ${n}) else 'all'}
% if sourk == 'source':
- id: dc_offset_mode${n}
label: 'Ch${n}: DC Offset Mode'
......
......@@ -122,46 +122,24 @@ struct is_nchan_argument
inline gr::io_signature::sptr args_to_io_signature( const std::string &args )
{
size_t max_nchan = 0;
std::cout << "Args: " << args << std::endl;
size_t dev_nchan = 0;
std::vector< std::string > arg_list = params_to_vector( args );
for (std::string arg : arg_list)
{
if ( arg.find( "numchan=" ) == 0 ) // try to parse global nchan value
{
pair_t pair = param_to_pair( arg );
max_nchan = boost::lexical_cast<size_t>( pair.second );
}
}
arg_list.erase( std::remove_if( // remove any global nchan tokens
arg_list.begin(),
arg_list.end(),
is_nchan_argument() ),
arg_list.end() );
// try to parse device specific nchan values, assume 1 channel if none given
for (std::string arg : arg_list)
{
dict_t dict = params_to_dict(arg);
if (dict.count("nchan"))
{
dev_nchan += boost::lexical_cast<size_t>( dict["nchan"] );
}
else // no channels given via args
{
dev_nchan++; // assume one channel
dev_nchan = boost::lexical_cast<size_t>( pair.second );
break;
}
}
// if at least one nchan was given, perform a sanity check
if ( max_nchan && dev_nchan && max_nchan != dev_nchan )
if ( !dev_nchan )
throw std::runtime_error("Wrong device arguments specified. Missing nchan?");
const size_t nchan = std::max<size_t>(dev_nchan, 1); // assume at least one
return gr::io_signature::make(nchan, nchan, sizeof(gr_complex));
return gr::io_signature::make(dev_nchan, dev_nchan, sizeof(gr_complex));
}
#endif // OSMOSDR_ARG_HELPERS_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment