def send_output_report(self, data):
        assert( self.is_opened() )
        #make sure we have c_ubyte array storage
        if not ( isinstance(data, ctypes.Array) and \
                issubclass(data._type_, c_ubyte) ):
            raw_data_type = c_ubyte * len(data)
            raw_data = raw_data_type()
            for index in range( len(data) ):
                raw_data[index] = data[index]
        else:
            raw_data = data
        #
        # Adding a lock when writing (overlapped writes)
        over_write = winapi.OVERLAPPED()
        over_write.h_event = winapi.CreateEvent(None, 0, 0, None)
        if over_write.h_event:
            try:
                overlapped_write = over_write
                winapi.WriteFile(int(self.hid_handle), byref(raw_data), len(raw_data),
                    None, byref(overlapped_write)) #none overlapped
                error = ctypes.GetLastError()
                if error == winapi.ERROR_IO_PENDING:
                    # overlapped operation in progress
                    result = error
                elif error == 1167:
                    raise HIDError("Error device disconnected before write")
                else:
                    raise HIDError("Error %d when trying to write to HID "\
                        "device: %s"%(error, ctypes.FormatError(error)) )
                result = winapi.WaitForSingleObject(overlapped_write.h_event, 10000 )
                if result != winapi.WAIT_OBJECT_0:
                    # If the write times out make sure to
                    # cancel it, otherwise memory could
                    # get corrupted if the async write
                    # completes after this functions returns
                    winapi.CancelIo( int(self.hid_handle) )
                    raise HIDError("Write timed out")
            finally:
                # Make sure the event is closed so resources aren't leaked
                winapi.CloseHandle(over_write.h_event)
        else:
            return winapi.WriteFile(int(self.hid_handle), byref(raw_data),
                len(raw_data),
                None, None) #none overlapped
        return True #completed
Send input/output/feature report ID = report_id, data should be a
dataset/ETHPy150Open rene-aguirre/pywinusb/pywinusb/hid/core.py/HidDevice.send_output_report