Explain the index/value format baudrate setting
[libftdi] / src / ftdi_stream.c
index 6c40327..b949999 100644 (file)
@@ -152,7 +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;
+    }
     
+    /* 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
      */