marecki
Newbie level 1
![Newbie level 1](/styles/images/ranks/alevel1.gif)
Hello,
I want to receive and read data from pin RxD in FT232RL device. To get that I connect line TxD and RxD. In that situation on RxD I should get that what I transmitted from TxD. I send a simple frame of 8 bit data. The transmission works because LED-s connected to the CBUS0 and CBUS1 turn on. Turning on the LED connected to the CBUS1 line means that data frame was given to the input but not necessarily received and written in buffer.
And here is my question. How to successfully receive data frame and how buffer in FT232RL works? Is it working independently from executed code and stores the data frame when it is detected on RxD? Perhaps I should start some function from library D2XX to permit reading? Functions that were called: FT_Open, FT_SetBaudRate, FT_SetDataCharacteristics, FT_Write, FT_GetStatus, FT_Read, FT_Close.
My code:
Sorry for my english![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
I want to receive and read data from pin RxD in FT232RL device. To get that I connect line TxD and RxD. In that situation on RxD I should get that what I transmitted from TxD. I send a simple frame of 8 bit data. The transmission works because LED-s connected to the CBUS0 and CBUS1 turn on. Turning on the LED connected to the CBUS1 line means that data frame was given to the input but not necessarily received and written in buffer.
And here is my question. How to successfully receive data frame and how buffer in FT232RL works? Is it working independently from executed code and stores the data frame when it is detected on RxD? Perhaps I should start some function from library D2XX to permit reading? Functions that were called: FT_Open, FT_SetBaudRate, FT_SetDataCharacteristics, FT_Write, FT_GetStatus, FT_Read, FT_Close.
My code:
Code:
void Write (void)
{
FT_STATUS ftStatus = 2;
DWORD BytesWritten;
char TxBuffer[1] = {0}; // Contains data to write to device
int to_send = 16; // Data to send
TxBuffer[0] = (char) to_send;
DWORD EventDWord;
DWORD TxBytes;
DWORD RxBytes;
DWORD BytesReceived;
char RxBuffer[1] = {0};
// Sending data frame
ftStatus = FT_Write(ftHandle, TxBuffer, sizeof(TxBuffer), &BytesWritten);
if (ftStatus == FT_OK)
{
cout << "Data transmitted" << endl;
}
else
{
}
FT_GetStatus(ftHandle,&RxBytes,&TxBytes,&EventDWord);
if (ftStatus == FT_OK)
{
cout << "Status device readed" << endl;
}
//if (RxBytes > 0)
//{
ftStatus = FT_Read(ftHandle,RxBuffer,RxBytes,&BytesReceived);
if (ftStatus == FT_OK)
{
cout << "Data readed" << endl;
for (unsigned int i = 0; i<300; i++)
{
cout << "containing of buffor ==> " << i << " "<< (int) RxBuffer[i] << endl;
}
}
else
{
}
//}
getchar();
getchar();
}