2 Replies Latest reply on Dec 13, 2011 8:27 AM by prajith.cheerakkoda

    CyUSB.NET with custom GUID


      I'm very new to CyUSB so please bear with me if this is a silly mistake.

      I am currently using a Saxo-Q from KNJN and it uses a FX2 for programming and communicating with the FPGA.

      My question is setting up CyUSB with a custom driver GUID in VC#. I suppose my question is a follow on to this one:




      in C# I have not been able to get the code supplied in Introduction to CuUSB.dll Based Application using C# (https://secure.cypress.com/?rID=12974). I've read the I have looked at the source code for CyControlCentre and see the following lines:




      //Set the customer class GUID(vendor specific) and Driver Guid(vendor specific) 
      //CyConst.SetCustomerGUID("{CDBF8987-75F1-468e-8217-97197F88F773}", "{C955D74D-0430-44f2-B120-276D94492D2D}");


      Looking at the .inf for CyUSB.sys that comes with SuiteUSB, I can see that the relevant GUIDs are:




      Comparing this with .inf that came with the FPGA:




      My reasoning is then that in order to use the sample code, I need to add the line:


      CyConst.SetCustomerGUID("{36FC9E60-C465-11CF-8056-444553540000}", "{0EFA2C93-0C7B-454F-9403-D638F6C37E65}"); 


      However, my program still seems to be detect the FPGA. I know that the driver for the FPGA works, as I can program it over USB using the program supplied with the FPGA. If I set the FPGA to use the default driver that comes with SuiteUSB then my program works fine, however I then cannot program the FPGA using the program supplied by the board manufacturer (presumably as it is looking for a device attached to the driver with a different GUID). There does not seem to be any documentation for CyConst.SetCustomerGUID. I only found it through the CyControlCentre example. Seems like a pretty important function to not be documented!


      Any help would be really appreciated!





      Here is my C# code:




      using CyUSB;
      //FPGA CLASS GUID       {36FC9E60-C465-11CF-8056-444553540000}
      //FPGA DRIVER GUID      {0EFA2C93-0C7B-454F-9403-D638F6C37E65}
      //CYPRESS CLASS GUID    {36FC9E60-C465-11CF-8056-444553540000}
      //CYPRESS DRIVER GUID   {AE18AA60-7F6A-11d4-97DD-00010229B959}


      namespace testCs
          public partial class Form1 : Form
              USBDeviceList usbDevices;
              CyUSBDevice myDevice;


              public Form1()
                  CyConst.SetCustomerGUID("{36FC9E60-C465-11CF-8056-444553540000}", "{0EFA2C93-0C7B-454F-9403-D638F6C37E65}");
                  usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB | CyConst.DEVICES_HID | CyConst.DEVICES_MSC);
                  usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
                  usbDevices.DeviceRemoved += new EventHandler(usbDevices_DeviceRemoved);
                  // Get the first device having VendorID == 0x04B4 and ProductID == 0x8613
                  myDevice = usbDevices[0x04B4, 0x8613] as CyUSBDevice;


              void usbDevices_DeviceAttached(object sender, EventArgs e)
                  //Add code to handle Device arrival 
                  Text = "Device Attached";


              void usbDevices_DeviceRemoved(object sender, EventArgs e)
                  //Add code to handle Device removal
                  Text = "Device Removed";




      I can change the GUID using the C++ lib, using an example supplied with the Saxo-Q, but I would be much more comfortable using C#. Some sample (working) C++ code for a windows form application for changing the GUID is below:




      CCyUSBDevice *USBDevice;



      static GUID test={0x0EFA2C93, 0x0C7B, 0x454F, 0x94, 0x03, 0xD6, 0x38, 0xF6, 0xC3, 0x7E, 0x65};
      USBDevice =new CCyUSBDevice((HANDLE)this->Handle,*GUID_KNJN_FX2,true);
      for(int i=0; i<100; i++) // blink the LEDs for a few seconds
      LONG len = 1;
      USBDevice->EndPoints[3]->XferData((PUCHAR)&i, len); // send one byte (the value of i) to FIFO2