#!/usr/bin/env python3 # -*- coding: utf-8 -*- # TRX Toolkit # Simple TDMA frame clock generator # # (C) 2017-2019 by Vadim Yanitskiy # # All Rights Reserved # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. APP_CR_HOLDERS = [("2017-2019", "Vadim Yanitskiy ")] import logging as log import signal from _clck_gen import CLCKGen from app_common import ApplicationBase from udp_link import UDPLink # Just a wrapper for independent usage class Application(ApplicationBase): def __init__(self): self.stop = False # Print copyright self.app_print_copyright(APP_CR_HOLDERS) # Set up signal handlers signal.signal(signal.SIGINT, self.sig_handler) # Configure logging log.basicConfig(level = log.DEBUG, format = "[%(levelname)s] TID#%(thread)s %(filename)s:%(lineno)d %(message)s") def run(self): self.link = UDPLink("127.0.0.1", 5800, "0.0.0.0", 5700) self.clck = CLCKGen([self.link], ind_period = 51) self.clck.start() while not self.stop: self.clck.tick() self.clck.stop() def sig_handler(self, signum, frame): log.info("Signal %d received" % signum) if signum == signal.SIGINT: self.stop = True if __name__ == '__main__': app = Application() app.run()