trx_toolkit/clck_gen.py: support optional clock handler

Change-Id: I85b2182d9835ed035cf370e45ea039ac6a7e8405
This commit is contained in:
Vadim Yanitskiy 2020-07-10 20:42:03 +07:00
parent 8d19fbef57
commit f262caca79
1 changed files with 6 additions and 0 deletions

View File

@ -54,6 +54,9 @@ class CLCKGen:
self.ctr_interval = self.GSM_FRAME_US - self.LO_DELAY_US
self.ctr_interval /= self.SEC_DELAY_US
# (Optional) clock consumer
self.clck_handler = None
@property
def running(self):
if self._thread is None:
@ -103,6 +106,9 @@ class CLCKGen:
# Debug print
log.debug(payload.rstrip("\0"))
if self.clck_handler is not None:
self.clck_handler(self.clck_src)
# Increase frame count (modular arithmetic)
self.clck_src = (self.clck_src + 1) % GSM_HYPERFRAME