Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sfewfsaf
qtcpp_demo
提交
477c1669
qtcpp_demo
项目概览
sfewfsaf
/
qtcpp_demo
与 Fork 源项目一致
Fork自
colorEagleStdio / qtcpp_demo
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
qtcpp_demo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
477c1669
编写于
2月 07, 2021
作者:
D
dev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
c++ unit ok
上级
dbb467e9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
101 addition
and
26 deletion
+101
-26
uhd_cpp/uhd_spectrum/specwidget.cpp
uhd_cpp/uhd_spectrum/specwidget.cpp
+8
-6
uhd_cpp/uhd_spectrum/specwidget.h
uhd_cpp/uhd_spectrum/specwidget.h
+1
-0
uhd_cpp/uhd_spectrum/specwidget.ui
uhd_cpp/uhd_spectrum/specwidget.ui
+9
-3
uhd_cpp/uhd_spectrum/uhd_device.cpp
uhd_cpp/uhd_spectrum/uhd_device.cpp
+74
-14
uhd_cpp/uhd_spectrum/uhd_device.h
uhd_cpp/uhd_spectrum/uhd_device.h
+7
-1
uhd_cpp/uhd_spectrum/uhd_device_win32.cpp
uhd_cpp/uhd_spectrum/uhd_device_win32.cpp
+2
-2
未找到文件。
uhd_cpp/uhd_spectrum/specwidget.cpp
浏览文件 @
477c1669
...
...
@@ -411,8 +411,9 @@ void specWidget::initRx()
return
;
//保存文件
m_strFolder
=
ui
->
lineEdit_folder
->
text
();
m_rx_points
=
0
;
save_count
=
0
;
m_bSaveToFile
=
ui
->
checkBox_save
->
isChecked
();
double
dfreq
=
ui
->
doubleSpinBox_center
->
value
();
double
spr
=
ui
->
doubleSpinBox_spr
->
value
();
...
...
@@ -490,10 +491,11 @@ void specWidget::initTx()
});
read_count
=
m_rx_bufsz
/
2
;
m_tx_points
=
0
;
//读取文件
m_strFolder
=
ui
->
lineEdit_folder_play
->
text
();
m_strFolder
Play
=
ui
->
lineEdit_folder_play
->
text
();
QDir
cdir
(
m_strFolder
);
QDir
cdir
(
m_strFolder
Play
);
QStringList
lst_filter
;
lst_filter
<<
"*.pcm"
;
QFileInfoList
lstFiles
=
cdir
.
entryInfoList
(
lst_filter
,
QDir
::
Files
|
QDir
::
Readable
,
QDir
::
Name
);
...
...
@@ -537,7 +539,7 @@ void specWidget::initTx()
if
(
new_begin
<
batchread
)
memcpy
(
m_data_iq_tx
,
&
m_data_iq_tx
[
m_tx_bufsz
],
sizeof
(
short
)
*
2
*
new_begin
);
if
(
rea
d_count
<
batchread
)
if
(
rea
l_size
<
batchread
)
{
fIn
.
close
();
++
currfile
;
...
...
@@ -655,7 +657,7 @@ void specWidget::timerEvent(QTimerEvent * e)
}
else
{
size_
t
he
=
m_rx_points
-
save_count
;
in
t
he
=
m_rx_points
-
save_count
;
ui
->
lcdNumber_saveBehind
->
display
((
double
)
he
);
...
...
@@ -766,7 +768,7 @@ void specWidget::on_spinBox_bw_valueChanged(int arg1)
void
specWidget
::
on_toolButton_br_play_clicked
()
{
QString
str
=
QFileDialog
::
getExistingDirectory
(
this
,
tr
(
"Input from"
),
ui
->
lineEdit_folder
->
text
());
QString
str
=
QFileDialog
::
getExistingDirectory
(
this
,
tr
(
"Input from"
),
ui
->
lineEdit_folder
_play
->
text
());
if
(
str
.
length
())
ui
->
lineEdit_folder_play
->
setText
(
str
);
}
...
...
uhd_cpp/uhd_spectrum/specwidget.h
浏览文件 @
477c1669
...
...
@@ -153,6 +153,7 @@ private:
std
::
atomic
<
bool
>
m_bSaveToFile
;
std
::
atomic
<
bool
>
m_bPlayFromFile
;
QString
m_strFolder
;
QString
m_strFolderPlay
;
//stdout reader
stdout_watcher
*
watcher
=
nullptr
;
};
...
...
uhd_cpp/uhd_spectrum/specwidget.ui
浏览文件 @
477c1669
...
...
@@ -242,7 +242,7 @@
<x>
0
</x>
<y>
0
</y>
<width>
320
</width>
<height>
504
</height>
<height>
495
</height>
</rect>
</property>
<attribute
name=
"label"
>
...
...
@@ -267,6 +267,9 @@
<property
name=
"maximum"
>
<double>
102400.000000000000000
</double>
</property>
<property
name=
"singleStep"
>
<double>
0.100000000000000
</double>
</property>
<property
name=
"value"
>
<double>
1200.000000000000000
</double>
</property>
...
...
@@ -397,6 +400,9 @@
<property
name=
"maximum"
>
<double>
102400.000000000000000
</double>
</property>
<property
name=
"singleStep"
>
<double>
0.100000000000000
</double>
</property>
<property
name=
"value"
>
<double>
1200.000000000000000
</double>
</property>
...
...
@@ -498,7 +504,7 @@
<x>
0
</x>
<y>
0
</y>
<width>
320
</width>
<height>
504
</height>
<height>
495
</height>
</rect>
</property>
<attribute
name=
"label"
>
...
...
@@ -662,7 +668,7 @@
<x>
0
</x>
<y>
0
</y>
<width>
320
</width>
<height>
504
</height>
<height>
495
</height>
</rect>
</property>
<attribute
name=
"label"
>
...
...
uhd_cpp/uhd_spectrum/uhd_device.cpp
浏览文件 @
477c1669
...
...
@@ -40,6 +40,7 @@ uhd_device::uhd_device()
,
m_rx_points
(
0
)
{
m_data_iq_rx
=
new
short
[
m_rx_bufsz
+
1024
*
1024
][
2
]{{
0
,
0
}};
m_data_iq_tx
=
new
short
[
m_tx_bufsz
+
1024
*
1024
][
2
]{{
0
,
0
}};
}
uhd_device
::
uhd_device
(
const
std
::
string
&
args
)
...
...
@@ -50,6 +51,7 @@ uhd_device::uhd_device(const std::string &args)
{
m_data_iq_rx
=
new
short
[
m_rx_bufsz
+
1024
*
1024
][
2
]{{
0
,
0
}};
m_data_iq_tx
=
new
short
[
m_tx_bufsz
+
1024
*
1024
][
2
]{{
0
,
0
}};
}
uhd_device
::~
uhd_device
()
{
...
...
@@ -60,7 +62,7 @@ uhd_device::~uhd_device()
}
delete
[]
m_data_iq_rx
;
delete
[]
m_data_iq_tx
;
}
...
...
@@ -136,6 +138,7 @@ void uhd_device::run_RxIO()
stream_args_rx
.
channels
.
push_back
(
m_rx_channel
);
rx_streamer
::
sptr
rx_stream
=
usrp
->
get_rx_stream
(
stream_args_rx
);
memset
(
m_data_iq_rx
,
0
,
m_rx_bufsz
*
sizeof
(
m_data_iq_rx
[
0
]));
m_rx_points
=
0
;
//接收线程
auto
thcall_rx
=
[
&
]()
->
void
{
...
...
@@ -146,7 +149,8 @@ void uhd_device::run_RxIO()
stream_cmd
.
time_spec
=
uhd
::
time_spec_t
();
m_rx_streaming
=
true
;
rx_stream
->
issue_stream_cmd
(
stream_cmd
);
while
(
!
stop_signal_called
)
{
try
{
while
(
!
stop_signal_called
)
{
...
...
@@ -177,11 +181,12 @@ void uhd_device::run_RxIO()
}
}
catch
(...)
{
stop_signal_called
=
true
;
//stop_signal_called = true;
}
}
stream_cmd
.
stream_now
=
false
;
rx_stream
->
issue_stream_cmd
(
stream_cmd
);
m_rx_streaming
=
false
;
stream_cmd
.
stream_now
=
false
;
rx_stream
->
issue_stream_cmd
(
stream_cmd
);
m_rx_streaming
=
false
;
};
//启动线程
uhd_io_thread
*
rx_thread
=
new
uhd_io_thread
(
thcall_rx
,
0
);
...
...
@@ -229,27 +234,79 @@ void uhd_device::set_rx_atn(const std::string & atn)
double
uhd_device
::
set_rx_gain
(
double
gain
)
{
if
(
usrp
)
{
usrp
->
set_rx_gain
(
gain
,
m_rx_channel
);
return
usrp
->
get_rx_gain
(
m_rx_channel
);
return
usrp
->
get_rx_gain
(
m_rx_channel
);
}
return
gain
;
}
double
uhd_device
::
set_rx_bandwidth
(
double
bw
)
{
if
(
usrp
&&
bw
>=
200000
)
if
(
usrp
)
{
double
srate
=
usrp
->
get_rx_rate
(
m_rx_channel
);
fprintf
(
stderr
,
"Current RX Rate: %f...
\n
"
,
srate
);
if
(
bw
<
200000
||
bw
>=
srate
)
bw
=
srate
;
usrp
->
set_rx_bandwidth
(
bw
,
m_rx_channel
);
bw
=
usrp
->
get_rx_bandwidth
(
m_rx_channel
);
}
else
if
(
usrp
)
{
usrp
->
set_rx_bandwidth
(
usrp
->
get_rx_rate
(
m_rx_channel
),
m_rx_channel
);
bw
=
usrp
->
get_rx_bandwidth
(
m_rx_channel
);
}
return
bw
;
}
void
uhd_device
::
run_TxIO
()
{
//创建流对象实例
uhd
::
stream_args_t
stream_args_tx
(
"sc16"
,
"sc16"
);
stream_args_tx
.
channels
.
push_back
(
m_tx_channel
);
tx_streamer
::
sptr
tx_stream
=
usrp
->
get_tx_stream
(
stream_args_tx
);
m_tx_points
=
0
;
memset
(
m_data_iq_tx
,
0
,
m_tx_bufsz
*
sizeof
(
m_data_iq_tx
[
0
]));
//发射线程
auto
thcall_tx
=
[
&
]()
->
void
{
uhd
::
tx_metadata_t
md_tx
;
m_tx_streaming
=
true
;
md_tx
.
has_time_spec
=
false
;
md_tx
.
start_of_burst
=
false
;
md_tx
.
end_of_burst
=
false
;
while
(
!
stop_signal_called
)
{
try
{
while
(
!
stop_signal_called
)
{
const
size_t
off
=
m_tx_points
%
m_tx_bufsz
;
const
size_t
new_begin
=
(
m_tx_points
+
m_txblock_size
)
%
m_tx_bufsz
;
if
(
new_begin
<
m_txblock_size
)
memcpy
(
&
m_data_iq_tx
[
m_tx_bufsz
],
m_data_iq_tx
,
sizeof
(
short
)
*
2
*
new_begin
);
const
void
*
addr
=
(
void
*
)
m_data_iq_tx
[
off
];
size_t
sent
=
tx_stream
->
send
(
addr
,
m_txblock_size
,
md_tx
,
1
);
m_tx_points
+=
sent
;
}
}
catch
(...)
{
//stop_signal_called = true;
}
QThread
::
msleep
(
10
);
}
m_tx_streaming
=
false
;
};
//启动线程
uhd_io_thread
*
tx_thread
=
new
uhd_io_thread
(
thcall_tx
,
0
);
tx_thread
->
start
(
QThread
::
TimeCriticalPriority
);
//主线程不断打印状态
while
(
!
stop_signal_called
)
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
400
));
}
//退出
tx_thread
->
wait
();
tx_thread
->
deleteLater
();
}
quint64
uhd_device
::
set_tx_freq
(
const
quint64
freq_in_hz
)
{
if
(
usrp
)
...
...
@@ -277,8 +334,11 @@ double uhd_device::set_tx_rate(const double sprate)
double
uhd_device
::
set_tx_gain
(
double
gain
)
{
if
(
usrp
)
{
usrp
->
set_tx_gain
(
gain
,
m_tx_channel
);
return
usrp
->
get_tx_gain
(
m_tx_channel
);
return
usrp
->
get_tx_gain
(
m_tx_channel
);
}
return
gain
;
}
double
uhd_device
::
set_tx_bandwidth
(
double
bw
)
...
...
uhd_cpp/uhd_spectrum/uhd_device.h
浏览文件 @
477c1669
...
...
@@ -38,20 +38,26 @@ public:
bool
open_device
();
bool
close_device
();
void
run_RxIO
();
void
run_TxIO
();
protected:
std
::
atomic
<
bool
>
stop_signal_called
;
std
::
atomic
<
bool
>
m_rx_streaming
;
std
::
atomic
<
bool
>
m_tx_streaming
;
std
::
string
m_dev_args
;
size_t
m_rxblock_size
=
10000
;
size_t
m_txblock_size
=
10000
;
uhd
::
usrp
::
multi_usrp
::
sptr
usrp
;
size_t
m_rx_channel
=
0
;
size_t
m_tx_channel
=
0
;
protected:
//初始化队列
short
(
*
m_data_iq_rx
)[
2
]
=
nullptr
;
size_t
m_rx_bufsz
=
1024
*
1024
*
16
;
short
(
*
m_data_iq_tx
)[
2
]
=
nullptr
;
size_t
m_rx_bufsz
=
1024
*
1024
*
4
;
size_t
m_tx_bufsz
=
1024
*
1024
*
4
;
//收发计数
unsigned
long
long
m_rx_points
=
0
;
unsigned
long
long
m_tx_points
=
0
;
public:
quint64
set_rx_freq
(
const
quint64
freq_in_hz
);
double
set_rx_rate
(
const
double
sprate
);
...
...
uhd_cpp/uhd_spectrum/uhd_device_win32.cpp
浏览文件 @
477c1669
...
...
@@ -160,7 +160,7 @@ void uhd_device::run_RxIO()
uhd_rx_streamer_handle
rx_streamer
=
0
;
uhd_rx_metadata_handle
rx_meta
=
0
;
memset
(
m_data_iq_rx
,
0
,
m_rx_bufsz
*
sizeof
(
m_data_iq_rx
[
0
]));
m_rx_points
=
0
;
//接收线程
auto
thcall_rx
=
[
&
]()
->
void
{
...
...
@@ -345,7 +345,7 @@ void uhd_device::run_TxIO()
uhd_tx_streamer_handle
tx_streamer
=
0
;
uhd_tx_metadata_handle
tx_meta
=
0
;
memset
(
m_data_iq_tx
,
0
,
m_tx_bufsz
*
sizeof
(
m_data_iq_tx
[
0
]));
m_tx_points
=
0
;
//发射线程
auto
thcall_tx
=
[
&
]()
->
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录