Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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]
     }
Пример #4
0
 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]
     }
Пример #5
0
        def getUnsentBuffer(self, channel):
            """Get the current bytes not yet sent to device."""
            # get size only
            bytesTransferred = _ft.ULONG()
            self.status = call_ft(_ft.FT_GetUnsentBuffer, self.handle, None,
                                  c.byref(bytesTransferred))
            if (bytesTransferred == 0):
                return {'bytesTransferred': 0, 'bytes': None}

            # get and buffer
            data = c.c_buffer(bytesTransferred)
            bytesTransferred = 0
            self.status = call_ft(_ft.FT_GetUnsentBuffer, self.handle, data,
                                  c.byref(bytesTransferred))
            return {
                'bytesTransferred':
                bytesTransferred.value,
                'bytes':
                data.raw[:bytesTransferred.value]
                if raw == True else data.value[:bytesTransferred.value]
            }
Пример #6
0
 def getWriteQueueStatus(self, channel):
     """Get the current bytes in the write queue."""
     bytesInQueue = _ft.ULONG()
     self.status = call_ft(_ft.FT_GetWriteQueueStatus, self.handle,
                           channel, c.byref(bytesInQueue))
     return bytesInQueue
Пример #7
0
 def getSuspendTimeout(self):
     """Get suspend timeout"""
     timeout = _ft.ULONG()
     self.status = call_ft(_ft.FT_GetSuspendTimeout, self.handle,
                           c.byref(timeout))
     return timeout.value
Пример #8
0
 def setSuspendTimeout(self, timeout):
     """Set suspend timeout"""
     self.status = call_ft(_ft.FT_SetSuspendTimeout, self.handle,
                           _ft.ULONG(timeout))
     return None
Пример #9
0
 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
Пример #10
0
 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
Пример #11
0
 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
Пример #12
0
 def setGPIOPull(self, mask, pull):
     """Set GPIO pull"""
     self.status = call_ft(_ft.FT_SetGPIOPull, self.handle, _ft.ULONG(mask),
                           _ft.ULONG(pull))
     return None
Пример #13
0
 def readGPIO(self):
     """Read GPIO"""
     gpio = _ft.ULONG()
     self.status = call_ft(_ft.FT_ReadGPIO, self.handle, c.byref(gpio))
     return gpio.value
Пример #14
0
 def writeGPIO(self, mask, data):
     """Write GPIO"""
     self.status = call_ft(_ft.FT_WriteGPIO, self.handle, _ft.ULONG(mask),
                           _ft.ULONG(data))
     return None
Пример #15
0
 def enableGPIO(self, mask, direction):
     """Enable GPIO"""
     self.status = call_ft(_ft.FT_EnableGPIO, self.handle, _ft.ULONG(mask),
                           _ft.ULONG(direction))
     return None