Hi Rui,
On Wednesday, 30. May 2012 17:09:04 Rui Barreiros wrote:
> while(!exitRequested) {
> ftdi_poll_modem_status(ftdi, &status);
>
> if(status & 0x1000) { // BREAK_INTERRUPT
> f = ftdi_read_data(ftdi, buff, sizeof(buff));
> if(f < 0)
> sleep(1);
> else if(f > 0) {
> ftdi_usb_purge_rx_buffer(ftdi);
> fprintf(stdout, "Read %d bytes\n", f);
> for(i = 0; i < sizeof(buff); i++) {
> fprintf(stdout, "%02X ", ((unsigned char *) buff)[i] );
> }
I'm not sure if the ftdi_usb_purge_rx_buffer() is a good idea:
ftdi_read_data() reads data in "readbuffer_chunksize" blocks,
usually 4096 bytes. If the "sizeof(buff)" (=513) is smaller than that
and the chip returns more data, it will be buffered internally.
Next time you call ftdi_read_data(), it might return data
from the internal read buffer. The problem is that
ftdi_usb_purge_rx_buffer() clears the internal read buffer,
so you will experience data loss.
Do you really need ftdi_usb_purge_rx_buffer()?
Thomas
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|