summaryrefslogtreecommitdiff
path: root/gr-uhd/grc/gen_uhd_usrp_blocks.py
diff options
context:
space:
mode:
authorLiu, Andrew Z <liu.andrew@vast-inc.com>2021-03-22 14:42:01 -0400
committerMartin Braun <martin@gnuradio.org>2021-04-12 04:51:19 -0700
commit5547665ee92f748a7ee47d64dfbf133db77fcfce (patch)
tree34a1355025ef3f52ad3f5dba33eaa9bb6496c33d /gr-uhd/grc/gen_uhd_usrp_blocks.py
parent222462c77a695c1ba28ee8fc535a43979c0cff2d (diff)
uhd: Add option to sync timestamp to PC Clock or GPS time on next 1PPS
Signed-off-by: Liu, Andrew Z <liu.andrew@vast-inc.com>
Diffstat (limited to 'gr-uhd/grc/gen_uhd_usrp_blocks.py')
-rw-r--r--gr-uhd/grc/gen_uhd_usrp_blocks.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/gr-uhd/grc/gen_uhd_usrp_blocks.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py
index aba1f3a223..8c31038d07 100644
--- a/gr-uhd/grc/gen_uhd_usrp_blocks.py
+++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py
@@ -52,8 +52,8 @@ parameters:
- id: sync
label: Sync
dtype: enum
- options: [sync, pc_clock, none]
- option_labels: [Unknown PPS, PC Clock, No Sync]
+ options: [sync, pc_clock, pc_clock_next_pps, gps_time, none]
+ option_labels: [Unknown PPS, PC Clock, PC Clock on Next PPS, GPS Time on Next PPS, No Sync]
hide: ${'$'}{ 'none' if sync else 'part'}
- id: start_time
label: Start Time (seconds)
@@ -177,6 +177,22 @@ templates:
self.${'$'}{id}.set_time_unknown_pps(uhd.time_spec(0))
${'%'} elif sync == 'pc_clock':
self.${'$'}{id}.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
+ ${'%'} elif sync == 'pc_clock_next_pps':
+ _last_pps_time = self.${'$'}{id}.get_time_last_pps().get_real_secs()
+ # Poll get_time_last_pps() every 50 ms until a change is seen
+ while(self.${'$'}{id}.get_time_last_pps().get_real_secs() == _last_pps_time):
+ time.sleep(0.05)
+ # Set the time to PC time on next PPS
+ self.${'$'}{id}.set_time_next_pps(uhd.time_spec(int(time.time()) + 1.0))
+ # Sleep 1 second to ensure next PPS has come
+ time.sleep(1)
+ ${'%'} elif sync == 'gps_time':
+ # Set the time to GPS time on next PPS
+ # get_mboard_sensor("gps_time") returns just after the PPS edge,
+ # thus add one second and set the time on the next PPS
+ self.${'$'}{id}.set_time_next_pps(uhd.time_spec(self.${'$'}{id}.get_mboard_sensor("gps_time").to_int() + 1.0))
+ # Sleep 1 second to ensure next PPS has come
+ time.sleep(1)
${'%'} else:
# No synchronization enforced.
${'%'} endif