FT_Read

Supported Operating Systems by FT_Read

Linux
Mac OS X (10.4 and later)
Windows (2000 and later)
Windows CE (4.2 and later)

61620「RULER FOLDING 6FT OUTSIDE READ」
| 月销量0件
优惠价220元
原价¥220

淘口令:

¥8nn4X9DwAG3¥
 

Summary of FT_Read

Read data from the device.

Definition of FT_Read

FT_STATUS FT_Read (FT_HANDLE ftHandle, LPVOID lpBuffer, DWORD dwBytesToRead, LPDWORD lpdwBytesReturned)

Parameters of FT_Read

ftHandle Handle of the device.
lpBuffer Pointer to the buffer that receives the data from the device.
dwBytesToRead Number of bytes to be read from the device.
lpdwBytesReturned Pointer to a variable of type DWORD which receives the number of
bytes read from the device.

Return Value of FT_Read

FT_OK if successful, FT_IO_ERROR otherwise.

Remarks about FT_Read

FT_Read always returns the number of bytes read in lpdwBytesReturned.
This function does not return until dwBytesToRead bytes have been read into the buffer. The number of
bytes in the receive queue can be determined by calling FT_GetStatus or FT_GetQueueStatus, and
passed to FT_Read as dwBytesToRead so that the function reads the device and returns immediately.
When a read timeout value has been specified in a previous call to FT_SetTimeouts, FT_Read returns
when the timer expires or dwBytesToRead have been read, whichever occurs first. If the timeout
occurred, FT_Read reads available data into the buffer and returns FT_OK.
An application should use the function return value and lpdwBytesReturned when processing the buffer.
If the return value is FT_OK, and lpdwBytesReturned is equal to dwBytesToRead then FT_Read has
completed normally. If the return value is FT_OK, and lpdwBytesReturned is less 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 fatal error like a
USB disconnect has occurred.

Examples of FT_Read

1. This sample shows how to read all the data currently available.
FT_HANDLE ftHandle;
FT_STATUS ftStatus;
DWORD EventDWord;
DWORD TxBytes;
DWORD RxBytes;
DWORD BytesReceived;
char RxBuffer[256];
ftStatus = FT_Open(0, &ftHandle);
if(ftStatus != FT_OK) {
// FT_Open failed
return;
}
FT_GetStatus(ftHandle,&RxBytes,&TxBytes,&EventDWord);
if (RxBytes > 0) {
ftStatus = FT_Read(ftHandle,RxBuffer,RxBytes,&BytesReceived);
if (ftStatus == FT_OK) {
// FT_Read OK
}
else {
// FT_Read Failed
}
}
FT_Close(ftHandle);
2. This sample shows how to read with a timeout of 5 seconds.
FT_HANDLE ftHandle;
FT_STATUS ftStatus;
DWORD RxBytes = 10;
DWORD BytesReceived;
char RxBuffer[256];
ftStatus = FT_Open(0, &ftHandle);
if(ftStatus != FT_OK) {
// FT_Open failed
return;
}
FT_SetTimeouts(ftHandle,5000,0);
ftStatus = FT_Read(ftHandle,RxBuffer,RxBytes,&BytesReceived);
if (ftStatus == FT_OK) {
if (BytesReceived == RxBytes) {
// FT_Read OK
}
else {
// FT_Read Timeout
}
}
else {
// FT_Read Failed
}
FT_Close(ftHandle);

© 版权声明
THE END
喜欢就支持一下吧,技术咨询可以联系QQ407933975
点赞0
分享
评论 抢沙发