def run(self): """ Read lines while keep_reading is True. Calls process_dut for each received line. :return: Nothing """ self.keep_reading = True while self.keep_reading: line = self._readline() if line: self.input_queue.appendleft(line) Dut.process_dut(self)
def open_connection(self): """ Open connection by starting the process. :raises: DutConnectionError """ self.logger.debug("Open CLI Process '%s'", (self.comport), extra={'type': '<->'}) self.cmd = self.comport if isinstance(self.comport, list) else [self.comport] if not self.comport: raise DutConnectionError("Process not defined!") try: self.build = Build.init(self.cmd[0]) except NotImplementedError as error: self.logger.error( "Build initialization failed. Check your build location.") self.logger.debug(error) raise DutConnectionError(error) # Start process&reader thread. Call Dut.process_dut() when new data is coming app = self.config.get("application") if app and app.get("bin_args"): self.cmd = self.cmd + app.get("bin_args") try: self.start_process( self.cmd, processing_callback=lambda: Dut.process_dut(self)) except KeyboardInterrupt: raise except Exception as error: raise DutConnectionError( "Couldn't start DUT target process {}".format(error))