libftdi Archives

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

From: bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 17 Dec 2018 16:56:09 +0100
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   

Current Thread