libftdi Archives

Subject: Re: Any exported way to set read timeout or query receive buffer?

From: Berni Joss <berni.joss@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 18 Dec 2018 14:36:28 +0100
>> is there is something pending in the read buffer
I check the readbuffer_remaining field of the ftdi_context struct [1] returned by ftdi_new() [2].

>> a way to set the read timeout via libftdi.
The same ftdi_context struct also has a field usb_read_timeout [3] .. but I have not used that one so far.
There is also a timeout inside the ftdi IC, which is called latency timer, which you set with ftdi_set_latency_timer() [4]

I am just a libftdi user of libftdi 1.4, not a developer nor maintainer, so I hope above is still useful.
Berni



On Mon, Dec 17, 2018 at 4:56 PM <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Hello,

For a user programm to determine if a connected FTDI device has the 60
MHz clock option (e.g. FT2232H) or not (e.g. FT2232D), I only see on
way:
- Send the  Disable Clk Divide by 5 command (0x8a)
- Observe if the command is accepted or not.

In the case the command succeeds, nothing will happen. A FT2232D will
not understand the command and so will send "BAD COMMAND" (0xfa)
followed by the command (0x8a). In the case of a FT2232D, a read(2)
would succeed. However on a device that knows the command, no output
is generated. Some read will hang until our 5000 ms timeout is elapsed
and make this approach  user unfriendly.

Two things could help in this situation:
- either have a way to query the device via libftdi is there is
something pending in the read buffer
- or have a way to set the read timeout via libftdi.

I neither see any of those two ways. Do I miss something?

A workaround sees to be:
send DIS_DIV_5
send GET_BITS_LOW
send GET_BITS_LOW
read two byte
 if bytes read are 0xfa  DIS_DIV_5
   device has slwo clock
   read two bytes
 else
   device has 60 MHz clock.

Some BAD_COMMAND definition also misses in out headers.

Bye

--
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 1623569 ------- Fax. 06151 1623305 ---------

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   



libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx


Current Thread