提交 9fb00fee 编写于 作者: M manjaro

Channels Setup Ok

上级 5987151e
......@@ -31,28 +31,38 @@ void sigint_handler(int code){
}
typedef short SPTYPE;
int main(int /*argc*/, char * /*argv*/[])
int main(int /*argc*/, char * /*argv*/[])
{
int return_code = EXIT_SUCCESS;
char dev_args[] = "";
char error_string[512];
//Sample rate in Hz
double sprate = 61.44e6/2 ;
//通道,B210左侧为A:A,右侧为A:B
const char subdev_rx[] = "A:A";
uhd_subdev_spec_handle subdev_hrx;
UHD_DO(uhd_subdev_spec_make(&subdev_hrx,subdev_rx))
//Sample rate in Hz
double sprate = 61.44e6/2 ;
//接收频率
double rx_freq = 107.7e6;
double rx_sprate = sprate;
double rx_gain = 55.0;
bool rx_agc = false;
double rx_bw = 400000;
//模组,左侧=0 右侧=1
size_t rx_channel = 0;
//接收信号。MIMO时,可以指定0,1
size_t rx_channel[] = {0};
//转发频率
double tx_freq = 89.0e6;
const char subdev_tx[] = "A:B";
uhd_subdev_spec_handle subdev_htx;
UHD_DO(uhd_subdev_spec_make(&subdev_htx,subdev_tx))
double tx_freq = 89.0e6;
double tx_sprate = sprate;
double tx_gain = 70;
double tx_bw = 400000;
//模组,左侧=0 右侧=1
size_t tx_channel = 0;
//发射信号。MIMO时,可以指定0,1
size_t tx_channel[] = {0};
//设备句柄
uhd_usrp_handle usrp = 0;
......@@ -77,6 +87,15 @@ int main(int /*argc*/, char * /*argv*/[])
getchar();
//设置接收通道,母板号为0(multi-usrp支持级联)
UHD_DO(uhd_usrp_set_rx_subdev_spec(usrp,subdev_hrx,0));
//设置发射通道,子板号为0(multi-usrp支持级联)
UHD_DO(uhd_usrp_set_tx_subdev_spec(usrp,subdev_htx,0));
//设置天线,子板号为0(multi-usrp支持级联)
UHD_DO(uhd_usrp_set_rx_antenna(usrp,"RX2",0));
UHD_DO(uhd_usrp_set_tx_antenna(usrp,"TX/RX",0));
// Create RX streamer
UHD_DO(uhd_rx_streamer_make(&rx_streamer));
......@@ -104,12 +123,13 @@ int main(int /*argc*/, char * /*argv*/[])
char rx_cpu_format[] = "sc16";
char rx_otw_format[] = "sc16";
char rx_args[] = "";
const size_t rx_channel_count = sizeof(rx_channel)/sizeof(rx_channel[0]);
uhd_stream_args_t rx_stream_args = {
.cpu_format = rx_cpu_format,
.otw_format = rx_otw_format,
.args = rx_args,
.channel_list = &rx_channel,
.n_channels = 1
.channel_list = rx_channel,
.n_channels = rx_channel_count
};
uhd_stream_cmd_t rx_stream_cmd = {
......@@ -134,59 +154,61 @@ int main(int /*argc*/, char * /*argv*/[])
char tx_cpu_format[] = "sc16";
char tx_otw_format[] = "sc16";
char tx_args[] = "";
const size_t tx_channel_count = sizeof(tx_channel)/sizeof(tx_channel[0]);
uhd_stream_args_t tx_stream_args = {
.cpu_format = tx_cpu_format,
.otw_format = tx_otw_format,
.args = tx_args,
.channel_list = &tx_channel,
.n_channels = 1
.channel_list = tx_channel,
.n_channels = tx_channel_count
};
size_t rx_sps_buff = 0;
size_t tx_sps_buff = 0;
// Set rate
fprintf(stderr, "Setting RX Rate: %f...\n", rx_sprate);
UHD_DO(uhd_usrp_set_rx_rate(usrp, rx_sprate, rx_channel));
UHD_DO(uhd_usrp_set_rx_rate(usrp, rx_sprate, rx_channel[0]));
// See what rate actually is
UHD_DO(uhd_usrp_get_rx_rate(usrp, rx_channel, &rx_sprate));
UHD_DO(uhd_usrp_get_rx_rate(usrp, rx_channel[0], &rx_sprate));
fprintf(stderr, "Actual RX Rate: %f...\n", rx_sprate);
// Set gain
fprintf(stderr, "Setting RX Gain: %f dB...\n", rx_gain);
UHD_DO(uhd_usrp_set_rx_gain(usrp, rx_gain, rx_channel, ""));
UHD_DO(uhd_usrp_set_rx_gain(usrp, rx_gain, rx_channel[0], ""));
// See what gain actually is
UHD_DO(uhd_usrp_get_rx_gain(usrp, rx_channel, "", &rx_gain));
UHD_DO(uhd_usrp_get_rx_gain(usrp, rx_channel[0], "", &rx_gain));
fprintf(stderr, "Actual RX Gain: %f...\n", rx_gain);
if (rx_agc)
{
uhd_usrp_set_rx_agc(usrp,true,rx_channel);
uhd_usrp_set_rx_dc_offset_enabled(usrp,true,rx_channel);
uhd_usrp_set_rx_agc(usrp,true,rx_channel[0]);
uhd_usrp_set_rx_dc_offset_enabled(usrp,true,rx_channel[0]);
}
// Set frequency
fprintf(stderr, "Setting RX frequency: %f MHz...\n", rx_freq/1e6);
UHD_DO(uhd_usrp_set_rx_freq(usrp, &rx_tune_request, rx_channel, &rx_tune_result));
UHD_DO(uhd_usrp_set_rx_freq(usrp, &rx_tune_request, rx_channel[0], &rx_tune_result));
// See what frequency actually is
UHD_DO(uhd_usrp_get_rx_freq(usrp, rx_channel, &rx_freq));
UHD_DO(uhd_usrp_get_rx_freq(usrp, rx_channel[0], &rx_freq));
fprintf(stderr, "Actual RX frequency: %f MHz...\n", rx_freq / 1e6);
fprintf(stderr, "Setting RX Bandwidth: %f MHz...\n", rx_bw/1e6);
UHD_DO(uhd_usrp_set_rx_bandwidth(usrp, rx_bw, rx_channel));
UHD_DO(uhd_usrp_set_rx_bandwidth(usrp, rx_bw, rx_channel[0]));
//Band
UHD_DO(uhd_usrp_get_rx_bandwidth(usrp, rx_channel, &rx_bw));
UHD_DO(uhd_usrp_get_rx_bandwidth(usrp, rx_channel[0], &rx_bw));
fprintf(stderr, "Actual RX Bandwidth: %f MHz...\n", rx_bw / 1e6);
// Set rate
fprintf(stderr, "Setting TX Rate: %f...\n", tx_sprate);
UHD_DO(uhd_usrp_set_tx_rate(usrp, tx_sprate, tx_channel));
UHD_DO(uhd_usrp_set_tx_rate(usrp, tx_sprate, tx_channel[0]));
// See what rate actually is
UHD_DO(uhd_usrp_get_tx_rate(usrp, tx_channel, &tx_sprate));
UHD_DO(uhd_usrp_get_tx_rate(usrp, tx_channel[0], &tx_sprate));
fprintf(stderr, "Actual TX Rate: %f...\n\n", tx_sprate);
// Set gain
......@@ -194,26 +216,26 @@ int main(int /*argc*/, char * /*argv*/[])
UHD_DO(uhd_usrp_set_tx_gain(usrp, tx_gain, 0, ""));
// See what gain actually is
UHD_DO(uhd_usrp_get_tx_gain(usrp, tx_channel, "", &tx_gain));
UHD_DO(uhd_usrp_get_tx_gain(usrp, tx_channel[0], "", &tx_gain));
fprintf(stderr, "Actual TX Gain: %f...\n", tx_gain);
// Set frequency
fprintf(stderr, "Setting TX frequency: %f MHz...\n", tx_freq / 1e6);
UHD_DO(uhd_usrp_set_tx_freq(usrp, &tx_tune_request, tx_channel, &tx_tune_result));
UHD_DO(uhd_usrp_set_tx_freq(usrp, &tx_tune_request, tx_channel[0], &tx_tune_result));
// See what frequency actually is
UHD_DO(uhd_usrp_get_tx_freq(usrp, tx_channel, &tx_freq));
UHD_DO(uhd_usrp_get_tx_freq(usrp, tx_channel[0], &tx_freq));
fprintf(stderr, "Actual TX frequency: %f MHz...\n", tx_freq / 1e6);
//Band
fprintf(stderr, "Setting TX Bandwidth: %f MHz...\n", tx_bw/1e6);
UHD_DO(uhd_usrp_set_tx_bandwidth(usrp, tx_bw,tx_channel));
UHD_DO(uhd_usrp_set_tx_bandwidth(usrp, tx_bw,tx_channel[0]));
UHD_DO(uhd_usrp_get_tx_bandwidth(usrp, tx_channel, &tx_bw));
UHD_DO(uhd_usrp_get_tx_bandwidth(usrp, tx_channel[0], &tx_bw));
fprintf(stderr, "Actual TX Bandwidth: %f MHz...\n", tx_bw / 1e6);
// Set up streamer
rx_stream_args.channel_list = &rx_channel;
rx_stream_args.channel_list = rx_channel;
UHD_DO(uhd_usrp_get_rx_stream(usrp, &rx_stream_args, rx_streamer));
// Set up buffer
......@@ -221,7 +243,7 @@ int main(int /*argc*/, char * /*argv*/[])
fprintf(stderr, "Buffer size in samples: %zu\n", rx_sps_buff);
// Set up streamer
tx_stream_args.channel_list = &tx_channel;
tx_stream_args.channel_list = tx_channel;
UHD_DO(uhd_usrp_get_tx_stream(usrp, &tx_stream_args, tx_streamer));
// Set up buffer
......@@ -230,7 +252,7 @@ int main(int /*argc*/, char * /*argv*/[])
if (rx_sps_buff!=tx_sps_buff)
throw ("RX buffer assumed equal to TX buffer. Stopped.");
for (int i=0;i<sz_buffer;++i)
for (size_t i=0;i<sz_buffer;++i)
io_buff[i] = (SPTYPE *) malloc(rx_sps_buff * 2 * sizeof(SPTYPE));
// Issue stream command
......@@ -243,23 +265,23 @@ int main(int /*argc*/, char * /*argv*/[])
std::thread th_send([&]()->void
{
try{
while (!stop_signal_called) {
if (rx_pos<5)
continue;
SPTYPE * tx_buff = io_buff[tx_pos % sz_buffer];
const void ** tx_buff_ptr = (const void **) &tx_buff;
UHD_DO(uhd_tx_streamer_send(tx_streamer, tx_buff_ptr, tx_sps_buff, &tx_meta, 1, &num_samps_sent));
if (tx_pos<rx_pos)
++tx_pos;
}
}
catch(std::string er)
{
fputs(er.c_str(),stderr);
}
}
);
try{
while (!stop_signal_called) {
if (rx_pos<5)
continue;
SPTYPE * tx_buff = io_buff[tx_pos % sz_buffer];
const void ** tx_buff_ptr = (const void **) &tx_buff;
UHD_DO(uhd_tx_streamer_send(tx_streamer, tx_buff_ptr, tx_sps_buff, &tx_meta, 1, &num_samps_sent));
if (tx_pos<rx_pos)
++tx_pos;
}
}
catch(std::string er)
{
fputs(er.c_str(),stderr);
}
}
);
//Read, RX in Main Thread
const int spn = (int(sprate)/rx_sps_buff)<1?1:(int(sprate)/rx_sps_buff);
while (!stop_signal_called) {
......
......@@ -24,6 +24,9 @@ using uhd::rx_streamer;
using std::thread;
using std::cerr;
using std::endl;
using std::string;
using std::vector;
using std::shared_ptr;
static bool stop_signal_called = false;
void sigint_handler(int code){
......@@ -35,11 +38,11 @@ void sigint_handler(int code){
* 通道配置参数
*/
struct tag_channelOptions{
std::string type = "sc16"; //样点类型,为上位机上类型: fc64, fc32, or sc16
std::string ant = "TX/RX"; //天线选取,B210 有 TX/RX 或者 RX2两个
std::string subdev="A:B"; //子设备,本例子默认第一块子板 A:A, A:B是第二块
std::string wirefmt; //内部类型 (sc8 or sc16),是片上处理的类型
size_t channel = 0; //通道
string type = "sc16"; //样点类型,为上位机上类型: fc64, fc32, or sc16
string subdev=""; //通道,A:A, A:B两个通道,对应B210左侧、右侧接口.一般默认配置,用信道号channels选取接口。
string ant = "TX/RX"; //天线选取,B210 有 TX/RX 或者 RX2两个
string wirefmt; //内部类型 (sc8 or sc16),是片上处理的类型
vector<size_t> channels {0};//通道号,可以设置0,1之类的。默认subdev时,0=A:A,1=A:B,subdev被修改,则采取修改后的编
size_t spb = 10000; //缓冲大小,太小会丢包,太大会超时
double rate = 61.44e6/2; //采样率,单位Hz
double freq = 1.0e9; //射频频率,单位Hz
......@@ -51,8 +54,8 @@ struct tag_channelOptions{
double setup_time = 1.0; //rx配置检查时间,可选。
};
//通道检查函数
bool check_tx_status(const std::string & ref, multi_usrp::sptr usrp);
bool check_rx_status(const std::string & ref, multi_usrp::sptr usrp,const tag_channelOptions & op);
bool check_tx_status(const string & ref, multi_usrp::sptr usrp,const tag_channelOptions & op);
bool check_rx_status(const string & ref, multi_usrp::sptr usrp,const tag_channelOptions & op);
/*!
* 范例吞吐函数,使用环形队列保持跟随收发
......@@ -64,13 +67,18 @@ void do_io(
rx_streamer::sptr rx,
tx_streamer::sptr tx)
{
if (oprx.channels.size()>1 || optx.channels.size()>1)
{
cerr << "multi channels IO is not suitable for this simple demo."<<endl;
return;
}
//初始化队列
std::vector< std::shared_ptr< FMT > > vec_buffer;
std::vector< int > vec_buffersz;
vector< shared_ptr< FMT > > vec_buffer;
vector< int > vec_buffersz;
const int bufsz = 65536;
for (int i=0;i<bufsz;++i)
{
vec_buffer.push_back(std::shared_ptr< FMT > (new FMT[oprx.spb * 2]));
vec_buffer.push_back(shared_ptr< FMT > (new FMT[oprx.spb * 2]));
vec_buffersz.push_back(0);
}
//收发计数
......@@ -86,6 +94,8 @@ void do_io(
while (!stop_signal_called)
{
vec_buffersz[rx_count % bufsz] = rx->recv((void *)(vec_buffer[rx_count % bufsz].get()),oprx.spb,md_rx,0.1,false);
//md_rx可以读取时戳
//auto tm_first = md_rx.time_spec;
++rx_count;
if (md_rx.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT)
fputs("Time out.",stderr);
......@@ -118,9 +128,9 @@ void do_io(
};
//启动线程
thread rx_thread(thcall_rx);
thread rx_thread(thcall_rx);
thread tx_thread(thcall_tx);
std::cout<<"Press ^C to Stop."<<endl;
cerr<<"Press ^C to Stop."<<endl;
//主线程不断打印状态
while (!stop_signal_called)
{
......@@ -137,45 +147,46 @@ void do_io(
int UHD_SAFE_MAIN(int /*argc*/, char* /*argv*/[])
{
//1.创建一个设备,可以不填写,则使用第一台设备。
std::string args ("");
string args ("");
//2.设置时钟参考 (internal, external, mimo)
std::string ref = "internal";
string ref = "internal";
cerr << "Creating the usrp device with: " << args <<"..."<< endl;
multi_usrp::sptr usrp = multi_usrp::make(args);
usrp->set_clock_source(ref);
usrp->set_clock_source(ref,multi_usrp::ALL_MBOARDS);
//3.配置发射
tag_channelOptions tx_op;
tx_op.freq = 89e6;
tx_op.bw = 400e3;
tx_op.gain=70;
//3.1子设备配置(默认)
tx_op.channels[0] = 1;
//3.1子设备配置(默认),一般不动它。
if (tx_op.subdev.size())
usrp->set_tx_subdev_spec(tx_op.subdev);
usrp->set_tx_subdev_spec(tx_op.subdev, multi_usrp::ALL_MBOARDS);
cerr << "TX Using Device: " << usrp->get_pp_string() << endl;
//3.2速率配置
cerr << "Setting TX Rate: " << (tx_op.rate / 1e6) << "Msps..." << endl;
usrp->set_tx_rate(tx_op.rate);
cerr << "Actual TX Rate: " << usrp->get_tx_rate() / 1e6 << "Msps..." << endl;
usrp->set_tx_rate(tx_op.rate, multi_usrp::ALL_CHANS);
cerr << "Actual TX Rate: " << usrp->get_tx_rate(tx_op.channels[0]) / 1e6 << "Msps..." << endl;
//3.3中心频率配置
cerr << "Setting TX Freq: " << (tx_op.freq / 1e6) <<"MHz..." << endl;
cerr << "Setting TX LO Offset: " << (tx_op.lo_offset / 1e6) << "MHz..." <<endl;
tune_request_t tune_request_tx = tune_request_t(tx_op.freq, tx_op.lo_offset);
if (tx_op.int_n_mod)
tune_request_tx.args = uhd::device_addr_t("mode_n=integer");
usrp->set_tx_freq(tune_request_tx);
cerr << "Actual TX Freq: " << (usrp->get_tx_freq() / 1e6) << "MHz..." << endl;
usrp->set_tx_freq(tune_request_tx,tx_op.channels[0]);
cerr << "Actual TX Freq: " << (usrp->get_tx_freq(tx_op.channels[0]) / 1e6) << "MHz..." << endl;
//3.4增益配置
cerr << "Setting TX Gain: " << tx_op.gain <<" dB..." << endl;
usrp->set_tx_gain(tx_op.gain);
cerr << "Actual TX Gain: " << usrp->get_tx_gain() << " dB..." << endl;
usrp->set_tx_gain(tx_op.gain,tx_op.channels[0]);
cerr << "Actual TX Gain: " << usrp->get_tx_gain(tx_op.channels[0]) << " dB..." << endl;
//3.5模拟前端滤波器带宽配置
cerr << "Setting TX Bandwidth: " << (tx_op.bw / 1e6) << "MHz..." << endl;
usrp->set_tx_bandwidth(tx_op.bw);
cerr << "Actual TX Bandwidth: " << usrp->get_tx_bandwidth() / 1e6 << "MHz..." << endl;
usrp->set_tx_bandwidth(tx_op.bw,tx_op.channels[0]);
cerr << "Actual TX Bandwidth: " << usrp->get_tx_bandwidth(tx_op.channels[0]) / 1e6 << "MHz..." << endl;
//3.6指定天线
if (tx_op.ant.size())
usrp->set_tx_antenna(tx_op.ant);
usrp->set_tx_antenna(tx_op.ant,tx_op.channels[0]);
//4.配置接收
tag_channelOptions rx_op;
......@@ -183,50 +194,47 @@ int UHD_SAFE_MAIN(int /*argc*/, char* /*argv*/[])
rx_op.bw = 400e3;
rx_op.freq = 107.7e6;
rx_op.gain = 50;
rx_op.channels[0] = 0;
//4.1 子设备
if (rx_op.subdev.size())
usrp->set_rx_subdev_spec(rx_op.subdev);
usrp->set_rx_subdev_spec(rx_op.subdev,multi_usrp::ALL_MBOARDS);
cerr << "RX Using Device: " << usrp->get_pp_string() << endl;
//4.2 采样率
cerr << "Setting RX Rate: " << (rx_op.rate / 1e6) << "Msps..." << endl;
usrp->set_rx_rate(rx_op.rate);
cerr << "Actual RX Rate: " << usrp->get_rx_rate() / 1e6 << "Msps..." << endl;
usrp->set_rx_rate(rx_op.rate,multi_usrp::ALL_CHANS);
cerr << "Actual RX Rate: " << usrp->get_rx_rate(rx_op.channels[0]) / 1e6 << "Msps..." << endl;
//4.3 中心频率
cerr << "Setting RX Freq: " << (rx_op.freq / 1e6) <<"MHz..." << endl;
cerr << "Setting RX LO Offset: " << (rx_op.lo_offset / 1e6) << "MHz..." <<endl;
tune_request_t tune_request_rx = tune_request_t(rx_op.freq, rx_op.lo_offset);
if (rx_op.int_n_mod)
tune_request_rx.args = uhd::device_addr_t("mode_n=integer");
usrp->set_rx_freq(tune_request_rx);
cerr << "Actual RX Freq: " << (usrp->get_rx_freq() / 1e6) << "MHz..." << endl;
usrp->set_rx_freq(tune_request_rx,rx_op.channels[0]);
cerr << "Actual RX Freq: " << (usrp->get_rx_freq(rx_op.channels[0]) / 1e6) << "MHz..." << endl;
//4.4 增益
cerr << "Setting RX Gain: " << rx_op.gain <<" dB..." << endl;
usrp->set_rx_gain(rx_op.gain);
cerr << "Actual RX Gain: " << usrp->get_rx_gain() << " dB..." << endl;
usrp->set_rx_gain(rx_op.gain,rx_op.channels[0]);
cerr << "Actual RX Gain: " << usrp->get_rx_gain(rx_op.channels[0]) << " dB..." << endl;
//4.5 前端模拟滤波带宽
cerr << "Setting RX Bandwidth: " << (rx_op.bw / 1e6) << "MHz..." << endl;
usrp->set_rx_bandwidth(rx_op.bw);
cerr << "Actual RX Bandwidth: " << usrp->get_rx_bandwidth() / 1e6 << "MHz..." << endl;
usrp->set_rx_bandwidth(rx_op.bw,rx_op.channels[0]);
cerr << "Actual RX Bandwidth: " << usrp->get_rx_bandwidth(rx_op.channels[0]) / 1e6 << "MHz..." << endl;
//4.6 选择天线
if (rx_op.ant.size())
usrp->set_rx_antenna(rx_op.ant);
usrp->set_rx_antenna(rx_op.ant,rx_op.channels[0]);
//5 检查状态
if (tx_op.docheck) check_tx_status(ref,usrp);
if (tx_op.docheck) check_tx_status(ref,usrp,tx_op);
if (rx_op.docheck) check_rx_status(ref,usrp,rx_op);
//6.创建流对象实例
//6.1 发射
std::vector<size_t> channel_nums_tx;
uhd::stream_args_t stream_args_tx(tx_op.type, tx_op.wirefmt);
channel_nums_tx.push_back(tx_op.channel);
stream_args_tx.channels = channel_nums_tx;
stream_args_tx.channels = tx_op.channels;
tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args_tx);
// 6.2 接收
uhd::stream_args_t stream_args_rx(rx_op.type, rx_op.wirefmt);
std::vector<size_t> channel_nums_rx;
channel_nums_rx.push_back(rx_op.channel);
stream_args_rx.channels = channel_nums_rx;
stream_args_rx.channels = rx_op.channels;
rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args_rx);
//开始收发循环
......@@ -239,22 +247,26 @@ int UHD_SAFE_MAIN(int /*argc*/, char* /*argv*/[])
}
bool check_tx_status(const std::string & ref, multi_usrp::sptr usrp)
bool check_tx_status(const string & ref, multi_usrp::sptr usrp,const tag_channelOptions & op)
{
// Check Ref and LO Lock detect
std::vector<std::string> sensor_names;
sensor_names = usrp->get_tx_sensor_names(0);
if (std::find(sensor_names.begin(), sensor_names.end(), "lo_locked")
!= sensor_names.end()) {
uhd::sensor_value_t lo_locked = usrp->get_tx_sensor("lo_locked", 0);
cerr <<"Checking TX: "<< lo_locked.to_pp_string() << std::endl;
UHD_ASSERT_THROW(lo_locked.to_bool());
vector<string> sensor_names;
for (size_t c :op.channels)
{
sensor_names = usrp->get_tx_sensor_names(c);
if (std::find(sensor_names.begin(), sensor_names.end(), "lo_locked")
!= sensor_names.end()) {
uhd::sensor_value_t lo_locked = usrp->get_tx_sensor("lo_locked",op.channels[0]);
cerr <<"Checking TX: "<< lo_locked.to_pp_string() << std::endl;
UHD_ASSERT_THROW(lo_locked.to_bool());
}
}
sensor_names = usrp->get_mboard_sensor_names(0);
if ((ref == "mimo")
and (std::find(sensor_names.begin(), sensor_names.end(), "mimo_locked")
!= sensor_names.end())) {
uhd::sensor_value_t mimo_locked = usrp->get_mboard_sensor("mimo_locked", 0);
uhd::sensor_value_t mimo_locked = usrp->get_mboard_sensor("mimo_locked",0);
std::cerr << "Checking TX: "<< mimo_locked.to_pp_string() << std::endl;
UHD_ASSERT_THROW(mimo_locked.to_bool());
}
......@@ -267,18 +279,18 @@ bool check_tx_status(const std::string & ref, multi_usrp::sptr usrp)
}
return true;
}
typedef std::function<uhd::sensor_value_t(const std::string&)> get_sensor_fn_t;
bool check_locked_sensor(std::vector<std::string> sensor_names,
const char* sensor_name,
get_sensor_fn_t get_sensor_fn,
double setup_time)
typedef std::function<uhd::sensor_value_t(const string&)> get_sensor_fn_t;
bool check_locked_sensor(vector<string> sensor_names,
const char* sensor_name,
get_sensor_fn_t get_sensor_fn,
double setup_time)
{
if (std::find(sensor_names.begin(), sensor_names.end(), sensor_name)
== sensor_names.end())
== sensor_names.end())
return false;
auto setup_timeout = std::chrono::steady_clock::now()
+ std::chrono::milliseconds(int64_t(setup_time * 1000));
+ std::chrono::milliseconds(int64_t(setup_time * 1000));
bool lock_detected = false;
std::cerr << "Checking RX Waiting for: " << sensor_name;
......@@ -307,19 +319,22 @@ bool check_locked_sensor(std::vector<std::string> sensor_names,
return true;
}
bool check_rx_status(const std::string & ref, multi_usrp::sptr usrp,const tag_channelOptions & op)
bool check_rx_status(const string & ref, multi_usrp::sptr usrp,const tag_channelOptions & op)
{
// check Ref and LO Lock detect
check_locked_sensor(usrp->get_rx_sensor_names(op.channel),
"lo_locked",
[usrp, op](const std::string& sensor_name) {
return usrp->get_rx_sensor(sensor_name, op.channel);
},
op.setup_time);
for (size_t c :op.channels)
{
check_locked_sensor(usrp->get_rx_sensor_names(c),
"lo_locked",
[usrp, op, c](const string& sensor_name) {
return usrp->get_rx_sensor(sensor_name, c);
},
op.setup_time);
}
if (ref == "mimo") {
check_locked_sensor(usrp->get_mboard_sensor_names(0),
"mimo_locked",
[usrp](const std::string& sensor_name) {
[usrp](const string& sensor_name) {
return usrp->get_mboard_sensor(sensor_name);
},
op.setup_time);
......@@ -327,7 +342,7 @@ bool check_rx_status(const std::string & ref, multi_usrp::sptr usrp,const tag_ch
if (ref == "external") {
check_locked_sensor(usrp->get_mboard_sensor_names(0),
"ref_locked",
[usrp](const std::string& sensor_name) {
[usrp](const string& sensor_name) {
return usrp->get_mboard_sensor(sensor_name);
},
op.setup_time);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册