class PololuController:
    __metaclass__ = abc.ABCMeta

    def __init__(self, uart_driver):
        self._channel = PololuChannel(uart_driver, owner=self)
        self._out_command_queue = queue.Queue(0)
        self._last_command = None
        self._command_sent_recently = 0
        self._init_pololu_controller_threads()

    def _init_pololu_controller_threads(self):
        out_command_process_thread = threading.Thread(group=None, target=self._out_command_process_thread, name='out_command_process_thread', daemon=True)
        out_command_process_thread.start()

    def send_message(self, command):
        self._out_command_queue.put(command)

    def _out_command_process_thread(self):
        while True:
            if not self._out_command_queue.empty():
                self._last_command = self._out_command_queue.get(True, timeout=None)
                self._channel.send_message(self._last_command)
            time.sleep(Constants.THREAD_SLEEP_DELAY)
 def __init__(self, uart_driver):
     self._channel = PololuChannel(uart_driver, owner=self)
     self._out_command_queue = queue.Queue(0)
     self._last_command = None
     self._command_sent_recently = 0
     self._init_pololu_controller_threads()