def getPipeInformation(self, interfaceIndex, pipeIndex): """Returns a dictionary describing the pipe infromationfor the specified indexes. """ pipeDesc = _ft.FT_PIPE_INFORMATION() self.status = call_ft(_ft.FT_GetPipeInformation, self.handle, _ft.UCHAR(interfaceIndex), _ft.UCHAR(pipeIndex), c.byref(pipeDesc)) return pipeDesc
def getStringDescriptor(self, index): """Returns a string descriptor. """ strDesc = _ft.FT_STRING_DESCRIPTOR() lenTransferred = _ft.DWORD() self.status = call_ft(_ft.FT_GetDescriptor, self.handle, _ft.UCHAR(FT_STRING_DESCRIPTOR_TYPE), _ft.UCHAR(index), c.pointer(strDesc), c.sizeof(strDesc), c.byref(lenTransferred)) return strDesc
def readPipe(self, channel, data, datalen, timeout=1000): """Recv the data to the device.""" bytesTransferred = _ft.ULONG() self.status = call_ft(_ft.FT_ReadPipeEx, self.handle, _ft.UCHAR(channel), data, _ft.ULONG(datalen), c.byref(bytesTransferred), timeout) return bytesTransferred.value
def readPipe(self, pipe, data, datalen): """Recv the data to the device.""" bytesTransferred = _ft.ULONG() self.status = call_ft(_ft.FT_ReadPipe, self.handle, _ft.UCHAR(pipe), data, _ft.ULONG(datalen), c.byref(bytesTransferred), None) return bytesTransferred.value
def readPipeEx(self, channel, datalen, timeout=1000, raw=False): """Recv the data to the device.""" bytesTransferred = _ft.ULONG() data = c.c_buffer(datalen) self.status = call_ft(_ft.FT_ReadPipeEx, self.handle, _ft.UCHAR(channel), data, _ft.ULONG(datalen), c.byref(bytesTransferred), timeout) return { 'bytesTransferred': bytesTransferred.value, 'bytes': data.value[:bytesTransferred.value] if raw == False else data.raw[:bytesTransferred.value] }
def readPipeEx(self, pipe, datalen, raw=True): """Recv the data to the device.""" bytesTransferred = _ft.ULONG() data = c.c_buffer(datalen) self.status = call_ft(_ft.FT_ReadPipe, self.handle, _ft.UCHAR(pipe), data, _ft.ULONG(datalen), c.byref(bytesTransferred), None) return { 'bytesTransferred': bytesTransferred.value, 'bytes': data.raw[:bytesTransferred.value] if raw == True else data.value[:bytesTransferred.value] }
def abortPipe(self, pipe): """Abort ongoing transfers for the specifed pipe""" self.status = call_ft(_ft.FT_AbortPipe, self.handle, _ft.UCHAR(pipe)) return None
def clearStreamPipe(self, pipe): """Clear stream pipe for continous transfer of fixed size""" self.status = call_ft(_ft.FT_ClearStreamPipe, self.handle, _ft.BOOLEAN(0), _ft.BOOLEAN(0), _ft.UCHAR(pipe)) return None
def setStreamPipe(self, pipe, size): """Set stream pipe for continous transfer of fixed size""" self.status = call_ft(_ft.FT_SetStreamPipe, self.handle, _ft.BOOLEAN(0), _ft.BOOLEAN(0), _ft.UCHAR(pipe), _ft.ULONG(size)) return None
def getPipeTimeout(self, pipeid): """Get pipe timeout""" timeoutMS = _ft.ULONG() self.status = call_ft(_ft.FT_GetPipeTimeout, self.handle, _ft.UCHAR(pipeid), c.byref(timeoutMS)) return timeoutMS.value
def setPipeTimeout(self, pipeid, timeoutMS): """Set pipe timeout""" self.status = call_ft(_ft.FT_SetPipeTimeout, self.handle, _ft.UCHAR(pipeid), _ft.ULONG(timeoutMS)) return None
def getInterfaceDescriptor(self, interfaceIndex): """Returns a dictionary describing the interface descriptor for the specified index. """ ifDesc = _ft.FT_INTERFACE_DESCRIPTOR() self.status = call_ft(_ft.FT_GetInterfaceDescriptor, self.handle, _ft.UCHAR(interfaceIndex), c.byref(ifDesc)) return ifDesc
def flushPipe(self, pipe): """Flush pipe""" self.status = call_ft(_ft.FT_FlushPipe, self.handle, _ft.UCHAR(pipe)) return None