FT232RL, FT_Read, reading buffer broken

Please discuss general Delphi programming topics here.

FT232RL, FT_Read, reading buffer broken

Postby croudfreak » February 15th, 2011, 10:02 am

I would like information about reading of the FT232RL buffer, I'm having some problems, when I read the buffer it is broken.
Like this
Ex:

’01 02 03 04 05 06 07 08’
‘09 0A 0B 0C 0D 0E 0F’

I need to read two times to get the whole frame, when the read should come like this:

’01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F’

When I have to read the buffer two times, I don’t no why, I can’t join those frames..

Seems like the buffer is not getting the entire data. In some tests i could get the entire data but takes over 500ms,

I using the Delphi XE to develop my software and I set the USB device like this:

____________________________________________________________________

procedure ConectUSB;
var
i: Integer;
begin
i := Open_USB_Device;
if (i = 0) or (i = 1 ) then
begin
Set_USB_Device_TimeOuts(20, 20);
Clr_USB_Device_RTS;
Get_USB_Device_QueueStatus;
Set_USB_Device_LatencyTimer(1);
FT_Current_Baud := 92000;
Set_USB_Device_BaudRate;
Set_USB_Device_RTS;
end;
end;

____________________________________________________________________

And my reading procedure is like this:

____________________________________________________________________


function Tfrm1.Rx3(bytes : Integer) : string; //when “bytes” receives the number of bytes that I need
var
i, cont : integer;
resp: string;

begin
frm1.vresp := '';
resp := '';
cont := 0;

while cont < bytes do
begin
cont := cont + Read_USB_Device_Buffer(bytes);
end;

for i := 0 to bytes - 1 do
begin
Get_USB_Device_QueueStatus;
resp := resp + Chr(FT_In_Buffer[i]);
end;

if resp <> '' then
Result := AsciiToHex(resp);
end;

____________________________________________________________________


thaks for the help
croudfreak
Member
Member
 
Posts: 1
Joined: February 15th, 2011, 9:58 am

Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 3 guests

cron