21.07.2015 Views

Programming Info D2XXPG31.pdf

Programming Info D2XXPG31.pdf

Programming Info D2XXPG31.pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

15 D2XX Programmer's Guide2.7 FT_ReadRead data from the device.FT_STATUS FT_Read (FT_HANDLE ftHandle, LPVOID lpBuffer, DWORD dwBytesToRead,LPDWORD lpdwBytesReturned)ParametersftHandlelpBufferdwBytesToReadlpdwBytesReturnedHandle of the device.Pointer to the buffer that receives the data from the device.Number of bytes to be read from the device.Pointer to a variable of type DWORD which receives thenumber of bytes read from the device.Return ValueFT_OK if successful, FT_IO_ERROR otherwise.RemarksFT_Read always returns the number of bytes read in lpdwBytesReturned.This function does not return until dwBytesToRead have been read into the buffer. The number ofbytes in the receive queue can be determined by calling FT_GetStatus 34 orFT_GetQueueStatus 31 , and passed to FT_Read 15 as dwBytesToRead so that the functionreads the device and returns immediately.When a read timeout value has been specified in a previous call to FT_SetTimeouts 30 ,FT_Read 15 returns when the timer expires or dwBytesToRead have been read, whichever occursfirst. If the timeout occurred, FT_Read 15 reads available data into the buffer and returns FT_OK.An application should use the function return value and lpdwBytesReturned when processing thebuffer. If the return value is FT_OK, and lpdwBytesReturned is equal to dwBytesToRead thenFT_Read 15 has completed normally. If the return value is FT_OK, and lpdwBytesReturned isless then dwBytesToRead then a timeout has occurred and the read has been partially completed.Note that if a timeout occurred and no data was read, the return value is still FT_OK.A return value of FT_IO_ERROR suggests an error in the parameters of the function, or a fatalerror like USB disconnect has occurred.ExampleThis sample shows how to read all the data currently available.FT_HANDLE ftHandle;FT_STATUS ftStatus;DWORD EventDWord;DWORD TxBytes;DWORD BytesReceived;char RxBuffer[256];© Future Technology Devices International Ltd. 2005

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!