X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=src%2Fftdi_stream.c;h=b949999951c711e7c62c4808e383205d7097b12f;hp=c3eb4653d4ebcef40ba9a92ee2db334c1b509d91;hb=9956d4289d04f1c67a8738a7b8b32e1345ab0968;hpb=02212d8e84cccd393a95612d4c4a5ec495fa3e2e diff --git a/src/ftdi_stream.c b/src/ftdi_stream.c index c3eb465..b949999 100644 --- a/src/ftdi_stream.c +++ b/src/ftdi_stream.c @@ -152,8 +152,28 @@ ftdi_readstream(struct ftdi_context *ftdi, int bufferSize = packetsPerTransfer * ftdi->max_packet_size; int xferIndex; int err = 0; + + /* Only FT2232H and FT232H know about the synchronous FIFO Mode*/ + if ((ftdi->type != TYPE_2232H) && (ftdi->type != TYPE_232H)) + { + fprintf(stderr,"Device doesn't support synchronous FIFO mode\n"); + return 1; + } - fprintf(stderr, "ftdi_readstream\n"); + /* We don't know in what state we are, switch to reset*/ + if (ftdi_set_bitmode(ftdi, 0xff, BITMODE_RESET) < 0) + { + fprintf(stderr,"Can't reset mode\n"); + return 1; + } + + /* Purge anything remaining in the buffers*/ + if (ftdi_usb_purge_buffers(ftdi) < 0) + { + fprintf(stderr,"Can't Purge\n"); + return 1; + } + /* * Set up all transfers */ @@ -198,7 +218,7 @@ ftdi_readstream(struct ftdi_context *ftdi, */ if (ftdi_set_bitmode(ftdi, 0xff, BITMODE_SYNCFF) < 0) { - fprintf(stderr,"Can't set synchronous fifo mode\n", + fprintf(stderr,"Can't set synchronous fifo mode: %s\n", ftdi_get_error_string(ftdi)); goto cleanup; }