def __init__(self, id=None, errstream=sys.stderr): self._id = None self._error = errstream # Debugging if DEBUG: hid.hid_set_debug(hid.HID_DEBUG_ALL) hid.hid_set_debug_stream(self._error) hid.hid_set_usb_debug(0) # Initialisation if not hid.hid_is_initialised(): # Doesn't seem to work try: # Belt AND braces, Sir? hid.hid_init() except HIDError: pass self._interface = hid.hid_new_HIDInterface() # Ensure we only use one HIDMatcher class per # type of sensor, with some reflection-fu. #if not 'MATCHER' in self.__class__.__dict__: if not hasattr(self.__class__, 'MATCHER'): self.__class__.MATCHER = HIDMatcher(self.__class__.VID, self.__class__.PID) return
def set_usb_debug(level): '''Set the debug level used by libusb.''' hid.hid_set_usb_debug(level)
def set_usb_debug(level): hid.hid_set_usb_debug(level)