Ok, I think I understand more about
what is going on. In the ftdi_read_data() function:
if (ret > 2) {
// skip FTDI status bytes.
// Maybe stored in the future to enable modem use
num_of_chunks = ret / 64;
chunk_remains = ret % 64;
//printf("ret = %X, num_of_chunks = %X, chunk_remains = %X,
readbuffer_offset = %X\n", ret, num_of_chunks, chunk_remains,
ftdi->readbuffer_offset);
ftdi->readbuffer_offset += 2;
ret -= 2;
if (ret > 62) {
for (i = 1; i < num_of_chunks; i++)
memmove (ftdi->readbuffer+ftdi->readbuffer_offset+62*i,
ftdi->readbuffer+ftdi->readbuffer_offset+64*i,
62);
if (chunk_remains > 2) {
memmove (ftdi->readbuffer+ftdi->readbuffer_offset+62*i,
ftdi->readbuffer+ftdi->readbuffer_offset+64*i,
chunk_remains-2);
ret -= 2*num_of_chunks;
} else
ret -= 2*(num_of_chunks-1)+chunk_remains;
}
} else if (ret <= 2) {
// no more data to read?
return offset;
}
The code assumes that there will
be a modem status byte pair for every 64 bytes returned by the ftdi chip.
For the ft245BL, this is true. For the ft2232H, it appears that the modem
status bytes are returned only once per usb_bulk_read call. Setting a break at “if
(ret > 2)”, I examine the results of the bulk_read. There are
106 bytes total. The first two bytes are the modem status bytes as
expected. The remaining 104 bytes are the data sent from my device, with
no additional modem status bytes embedded in the stream. Thus, as the
code stands now, it will delete bytes 65 and 66, thinking that they are modem
status bytes, when in fact they are not.
Could this be the issue?
Is there anything else I can do on my end to prove this out? What would
be the suggested fix?
Thanks,
Dave Challis