|
From: Jonathon <j...@co...> - 2006-04-21 23:56:17
|
> One thing you should be aware of is that a read in libftdi may return
> no payload (0 bytes).
Yes, the reason for this is because usb_read_bulk() to an FTDI chip always
returns 2 status bytes in addition to the payload. So usb_read_bulk()
never blocks, always returning 2 status bytes, or 2 status bytes +
payload.
hence, ftdi_read_data never blocks either. (ftdi_read_data obviously
removes the status bytes, leaving you with zero bytes)
I'd already half written my code before I found libftdi, which is how I've
figured out all this stuff.
I was working on making my software 'cope' with the usb being unplugged,
and being plugged in again. (Software says... you've gone offline, then
says you've gone back online)
Rather interestingly, subsequent calls to usb_claim_interface() ... (or
the libftdi equivalent) when claiming it for a second time [after
unplugging and replugging] would always fail. ('The device is busy') ...
but if I set the latency setting (16ms by default [in the chip]) somewhere
in my code (even to 16ms, which it was already set to!), claiming the
interface a second time would succeed.
oh, man, there's way too much magic in these FTDI chips.
> by continually polling ftdi_read_data until the requested number of
> bytes were received or the timeout in milliseconds elapsed.
yeah, did the same thing.
cheers
Jonathon
|