7 Replies Latest reply on Feb 22, 2015 9:45 AM by user_1748457

    Failing with Streamer + USBBulkSourceSink error 997

    blake.ramsdell

      This forum text editor is quite broken in Chrome on my machine, by the way.

         

      I uploaded the USBBulkSourceSink firmware to my FX3 dev board. I then ran the C# streamer example, selecting the 0x81 IN endpoint. No matter what combination of other settings in the other comboboxes, after a few seconds it kicks into an error state where every transaction fails. At this point you have to reset the device before any transactions will succeed again (restarting streamer has no effect). As it turns out, LastError was set to 997.

         

      I made a much simpler client application without any Overlapped I/O (just using the XferData method), and I ran into the same thing -- it runs for awhile, and then no XferData calls succeed, and LastError is 997. You will remain in this state even if you re-run your client application, you have to reset the device to clear it.

         

      Plus, if you specify a transfer size that isn't a power of two (I used 4097), it will stop immediately without reading any bytes with error 997.

         

      I am on 64-bit Windows 7 on an 8 core machine.

         

      My code is as follows, but it's readily reproducible with the streamer example:

         

      static void Main(string[] args)
      {
          var usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
          var myDevice = usbDevices[0x04B4, 0x00F1] as CyUSBDevice;

         

          if (myDevice == null)
          {
              System.Console.WriteLine("No device. Try again when you have one.");
              return;
          }

         

          var endpoint = myDevice.EndPointOf(0x81);
          var data = new byte[(args.Length > 0) ? int.Parse(args[1]) : DefaultBufferSize];
          ulong totalBytesRead = 0;
          var stopwatch = new Stopwatch();

         

          System.Console.WriteLine("Using buffer size of {0}", NumberBytesToString((ulong) data.Length));
          System.Console.WriteLine("Timeout is {0}", endpoint.TimeOut);
          stopwatch.Start();

         

          while (true)
          {
              int numberBytesRead = data.Length;
              if (!endpoint.XferData(ref data, ref numberBytesRead))
              {
                  if (endpoint.LastError != 0)
                  {
                      throw new Win32Exception((int) endpoint.LastError);
                  }
                  else
                  {
                      throw new Exception("Unknown XferData error");
                  }
              }
              if (numberBytesRead < data.Length)
              {
                  System.Console.WriteLine("Short read of {0}", numberBytesRead);
              }
              totalBytesRead += (ulong) numberBytesRead;
              System.Console.Write("\r{0}/s", NumberBytesToString(((totalBytesRead * 1000) / (ulong)stopwatch.ElapsedMilliseconds)));
          }
      }

         

      My ultimate goal is to marshal data through the GPIF through a bulk IN endpoint, and I was starting with this example code as a baseline. But as far as I can tell, either a) the firmware is busted, or b) the C# client library is.

         

      Is the streamer example supposed to work better with a different firmware? I just care about IN data, I don't want to loop data OUT and back IN, I just want the FX3 to send data as fast as possible, and then process it as fast as possible on the PC side. Is there an example firmware and client app that can do this?

         

      Thanks in advance.