(self,
                          max_connection_attempts=MAX_CONNECTION_ATTEMPTS)
Open a connection to the named serial port, or auto-detect the first
        port matching the BLED device. This will wait until data can actually be
        read from the connection, so it will not return until the device is
        fully booted.

        max_connection_attempts -- Max number of times to retry
            detecting and connecting to a device.

        Raises a NotConnectedError if the device cannot connect after 10
        attempts, with a short pause in between each attempt.
Open a connection to the named serial port, or auto-detect the first
        port matching the BLED device. This will wait until data can actually be
        read from the connection, so it will not return until the device is
        fully booted.
Open a connection to the named serial port or auto - detect the first port matching the BLED device . This will wait until data can actually be read from the connection so it will not return until the device is fully booted .
def _open_serial_port(self,
                          max_connection_attempts=MAX_CONNECTION_ATTEMPTS):
        """
        Open a connection to the named serial port, or auto-detect the first
        port matching the BLED device. This will wait until data can actually be
        read from the connection, so it will not return until the device is
        fully booted.

        max_connection_attempts -- Max number of times to retry
            detecting and connecting to a device.

        Raises a NotConnectedError if the device cannot connect after 10
        attempts, with a short pause in between each attempt.
        """
        for attempt in range(max_connection_attempts):
            log.debug("Opening connection to serial port (attempt %d)",
                      attempt + 1)
            try:
                serial_port = self._serial_port or self._detect_device_port()
                self._ser = None

                self._ser = serial.Serial(serial_port, baudrate=115200,
                                          timeout=0.25)
                # Wait until we can actually read from the device
                self._ser.read()
                break
            except serial_exceptions:
                log.debug("Failed to open serial port", exc_info=True)
                if self._ser:
                    self._ser.close()
                elif attempt == (max_connection_attempts - 1):
                    raise NotConnectedError(
                        "No BGAPI compatible device detected")
                self._ser = None
                time.sleep(0.25)
        else:
            raise NotConnectedError("Unable to reconnect with USB "
                                    "device after rebooting")
def _open_serial_port ( self , max_connection_attempts = MAX_CONNECTION_ATTEMPTS ) : for attempt in range ( max_connection_attempts ) : log . debug ( "Opening connection to serial port (attempt %d)" , attempt + 1 ) try : serial_port = self . _serial_port or self . _detect_device_port ( ) self . _ser = None self . _ser = serial . Serial ( serial_port , baudrate = 115200 , timeout = 0.25 ) # Wait until we can actually read from the device self . _ser . read ( ) break except serial_exceptions : log . debug ( "Failed to open serial port" , exc_info = True ) if self . _ser : self . _ser . close ( ) elif attempt == ( max_connection_attempts - 1 ) : raise NotConnectedError ( "No BGAPI compatible device detected" ) self . _ser = None time . sleep ( 0.25 ) else : raise NotConnectedError ( "Unable to reconnect with USB " "device after rebooting" )