code: def _connect(self):
          
          while self.protocol:
              _LOGGER.info('Trying to connect to %s', self.port)
              try:
                  ser = serial.serial_for_url(
                      self.port, self.baud, timeout=self.timeout)
              except serial.SerialException:
                  _LOGGER.error('Unable to connect to %s', self.port)
                  _LOGGER.info(
                      'Waiting %s secs before trying to connect again',
                      self.reconnect_timeout)
                  time.sleep(self.reconnect_timeout)
              else:
                  transport = serial.threaded.ReaderThread(
                      ser, lambda: self.protocol)
                  transport.daemon = False
                  poll_thread = threading.Thread(target=self._poll_queue)
                  self._stop_event.clear()
                  poll_thread.start()
                  transport.start()
                  transport.connect()
                  return
docs: Connect to the serial port. This should be run in a new thread.