Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
spbro
OpenXG-RAN
Commits
6d5a0ab4
Commit
6d5a0ab4
authored
May 22, 2024
by
Florian Kaltenberger
Committed by
Robert Schmidt
Jun 05, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
synch the USRP time accross devices using the host clock
parent
8abf975f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
2 deletions
+28
-2
radio/USRP/usrp_lib.cpp
radio/USRP/usrp_lib.cpp
+28
-2
No files found.
radio/USRP/usrp_lib.cpp
View file @
6d5a0ab4
...
...
@@ -1012,6 +1012,28 @@ int trx_usrp_reset_stats(openair0_device *device) {
return
(
0
);
}
/*! \brief synch the USRP time accross devices using the host clock (ideally syched with PTP, but also NTP works) and assuming all
* devices are synched by octoclock */
static
void
usrp_sync_pps
(
usrp_state_t
*
s
)
{
// First, wait for PPS.
uhd
::
time_spec_t
time_last_pps
=
s
->
usrp
->
get_time_last_pps
();
while
(
time_last_pps
==
s
->
usrp
->
get_time_last_pps
())
{
boost
::
this_thread
::
sleep
(
boost
::
posix_time
::
milliseconds
(
1
));
}
// get host time
struct
timespec
tp
;
if
(
clock_gettime
(
CLOCK_TAI
,
&
tp
)
!=
0
)
LOG_W
(
PHY
,
"error getting system time
\n
"
);
double
tai_sec
=
(
double
)
tp
.
tv_sec
;
// set USRP time to host time at next pps
s
->
usrp
->
set_time_next_pps
(
uhd
::
time_spec_t
(
tai_sec
));
LOG_I
(
HW
,
"USRP clock set to %f sec
\n
"
,
tai_sec
);
}
extern
"C"
{
int
device_init
(
openair0_device
*
device
,
openair0_config_t
*
openair0_cfg
)
{
LOG_I
(
HW
,
"openair0_cfg[0].sdr_addrs == '%s'
\n
"
,
openair0_cfg
[
0
].
sdr_addrs
);
...
...
@@ -1188,8 +1210,12 @@ extern "C" {
exit
(
EXIT_FAILURE
);
}
}
else
{
s
->
usrp
->
set_time_next_pps
(
uhd
::
time_spec_t
(
0.0
));
if
(
s
->
usrp
->
get_time_source
(
0
)
==
"external"
)
{
usrp_sync_pps
(
s
);
}
else
{
s
->
usrp
->
set_time_next_pps
(
uhd
::
time_spec_t
(
0.0
));
}
if
(
s
->
usrp
->
get_clock_source
(
0
)
==
"external"
)
{
if
(
check_ref_locked
(
s
,
0
))
{
LOG_I
(
HW
,
"USRP locked to external reference!
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment