Example #1
0
 def set_report(self,report_data,report_id=0):
     '''
     "set" a report - send the data to the device (which must have been opened previously)
     '''
     HIDDevice.set_report(self,report_data,report_id)
     
     report_buffer=(c_ubyte*(len(report_data)+1))()
     report_buffer[0]=report_id # first byte is report id
     for i,c in enumerate(report_data):
         report_buffer[i+1]=struct.unpack('B',c)[0]
             
     def completion_callback(dwErrorCode,dwNumberOfBytesTransfered,lpOverlapped):
         pass
     
     overlap_completion=LPOVERLAPPED_COMPLETION_ROUTINE(completion_callback)
     
     result=WriteFileEx(
         self._device_handle,
         report_buffer,
         len(report_buffer),
         self._write_overlapped,
         overlap_completion )
     
     if not result:
         raise RuntimeError("WriteFileEx failed")
     
     if Kernel32.SleepEx(100,1) == 0:
         raise RuntimeError("timed out when writing to device")
Example #2
0
    def set_report(self,report_data,report_id=0):
        '''
        "set" a report - send the data to the device (which must have been opened previously)
        '''
        HIDDevice.set_report(self,report_data,report_id)

        # copy data into a ctypes buffer
        report_buffer=(c_ubyte*len(report_data))()
        for i,c in enumerate(report_data):
            report_buffer[i]=struct.unpack('B',c)[0]
        
        ioret=self._devInterface.WritePipe(2, report_buffer, len(report_data))
        if ioret != kIOReturnSuccess:
            logging.info("error writing to device: 0x%x" % long(ioret))
Example #3
0
 def set_report(self,report_data,report_id=0):
     '''
     "set" a report - send the data to the device (which must have been opened previously)
     '''
     HIDDevice.set_report(self,report_data,report_id)
     
     # copy data into a ctypes buffer
     report_buffer=(c_ubyte*len(report_data))()
     for i,c in enumerate(report_data):
         report_buffer[i]=struct.unpack('B',c)[0]
     
     self._hidInterface.setReport(
         kIOHIDReportTypeOutput,
         report_id,
         report_buffer,
         len(report_buffer),
         100, # 100ms
         IOHIDReportCallbackFunction(), None, None # NULL callback
     )
Example #4
0
 def set_report(self,report_data,report_id=0):
     '''
     "set" a report - send the data to the device (which must have been opened previously)
     '''
     HIDDevice.set_report(self,report_data,report_id)
     
     # copy data into a ctypes buffer
     report_buffer=(c_ubyte*len(report_data))()
     for i,c in enumerate(report_data):
         report_buffer[i]=struct.unpack('B',c)[0]
     
     self._hidInterface.setReport(
         kIOHIDReportTypeOutput,
         report_id,
         report_buffer,
         len(report_buffer),
         100, # 100ms
         IOHIDReportCallbackFunction(), None, None # NULL callback
     )