code: def open(self):
          
  
          self.hwman = HardwareManager(port=self._port)
          self.opened = True
  
          if self._connection_string is not None:
              try:
                  self.hwman.connect_direct(self._connection_string)
              except HardwareError:
                  self.hwman.close()
                  raise
  
          elif self._connect_id is not None:
              try:
                  self.hwman.connect(self._connect_id)
              except HardwareError:
                  self.hwman.close()
                  raise
docs: Open and potentially connect to a device.