parameters: (self, serial_number=None, product=None)
return_statement: return True
docstring: Makes a HID connection to a debugger
  
          :param serial_number: instance serial number to connect to
          :param product: product type to connect to
          :return: True if successfully connected to a tool, False if not
docstring_summary: Makes a HID connection to a debugger
docstring_tokens: Makes a HID connection to a debugger
function: def connect(self, serial_number=None, product=None):
          """
          Makes a HID connection to a debugger
  
          :param serial_number: instance serial number to connect to
          :param product: product type to connect to
          :return: True if successfully connected to a tool, False if not
          """
          if self.connected:
              return True
  
          device_count = len(self.devices)
          self.logger.debug("{:d} devices available".format(device_count))
          if device_count == 0:
              self.logger.error("No CMSIS-DAP devices found.")
              return False
  
          matching_devices = self.get_matching_tools(serial_number_substring=serial_number, product=product)
          number_of_matching_devices = len(matching_devices)
  
          # Did we find exactly 1 tool?
          if number_of_matching_devices != 1:
              log_str = "Found {:d} daps matching the filter serial = \"{}\" and product = \"{}\""
              self.logger.debug(log_str.format(number_of_matching_devices, serial_number, product))
              if number_of_matching_devices > 1:
                  self.logger.error("Too many products found. Please specify one of:")
                  for device in self.devices:
                      self.logger.error(" > {:s} {:s}".format(device.product_string,
                                                              device.serial_number))
              return False
  
          # Everything is peachy, connect to the tool
          self.device = matching_devices[0]
          self.hid_connect(self.device)
          self.logger.debug("Connected OK")
          self.connected = True
          packet_size = toolinfo.get_default_report_size(self.device.product_id)
          self.device.set_packet_size(packet_size)
          self.hid_info()
          return True
function_tokens: def connect ( self , serial_number = None , product = None ) : if self . connected : return True device_count = len ( self . devices ) self . logger . debug ( "{:d} devices available" . format ( device_count ) ) if device_count == 0 : self . logger . error ( "No CMSIS-DAP devices found." ) return False matching_devices = self . get_matching_tools ( serial_number_substring = serial_number , product = product ) number_of_matching_devices = len ( matching_devices ) # Did we find exactly 1 tool? if number_of_matching_devices != 1 : log_str = "Found {:d} daps matching the filter serial = \"{}\" and product = \"{}\"" self . logger . debug ( log_str . format ( number_of_matching_devices , serial_number , product ) ) if number_of_matching_devices > 1 : self . logger . error ( "Too many products found. Please specify one of:" ) for device in self . devices : self . logger . error ( " > {:s} {:s}" . format ( device . product_string , device . serial_number ) ) return False # Everything is peachy, connect to the tool self . device = matching_devices [ 0 ] self . hid_connect ( self . device ) self . logger . debug ( "Connected OK" ) self . connected = True packet_size = toolinfo . get_default_report_size ( self . device . product_id ) self . device . set_packet_size ( packet_size ) self . hid_info ( ) return True