code: def open_connection(self):
          if self.readthread is not None:
              raise DutConnectionError("Trying to open serial port which was already open")
          self.logger.info("Open Connection "
                           "for '%s' using '%s' baudrate: %d" % (self.dut_name,
                                                                 self.comport,
                                                                 self.serial_baudrate),
                           extra={'type': '<->'})
          if self.serial_xonxoff:
              self.logger.debug("Use software flow control for dut: %s" % self.dut_name)
          if self.serial_rtscts:
              self.logger.debug("Use hardware flow control for dut: %s" % self.dut_name)
          try:
              self.port = EnhancedSerial(self.comport)
              self.port.baudrate = self.serial_baudrate
              self.port.timeout = self.serial_timeout
              self.port.xonxoff = self.serial_xonxoff
              self.port.rtscts = self.serial_rtscts
              self.port.flushInput()
              self.port.flushOutput()
          except SerialException as err:
              self.logger.warning(err)
              raise DutConnectionError(str(err))
          except ValueError as err:
              self.logger.warning(err)
              raise ValueError(str(err))
          if self.ch_mode:
              self.logger.info("Use chunk-mode with size %d, delay: %.3f when write data" %
                               (self.ch_mode_chunk_size, self.ch_mode_ch_delay),
                               extra={'type': '<->'})
              time.sleep(self.ch_mode_start_delay)
          else:
              self.logger.info("Use normal serial write mode", extra={'type': '<->'})
          if self.params.reset:
              self.reset()
          self.readthread = Thread(name=self.name, target=self.run)
          self.readthread.start()