2 Replies Latest reply on Sep 10, 2010 9:16 AM by a.p
      • 1. Re: Cy7C6013:CyAPI:how to get endpoints after loading .hex file
        a.p

        Hi everyone.

           

        I'm using CyUSB driver and CyAPI library with Visual Studio 2005.

           

        I'm using the example from C:\Program Files\Cypress\Cypress Suite USB 3.4.2\CyAPI\examples\FxEEPROM to load my hex file to eeprom. It is loaded( i see new VID/PID,endpoints in USBview program).The problem is that i can't get updated endpoints info from API lib.device->EndPointCount(); get's the same as before loading the .hex file.

           

        I decided to Close device and Open it again.The code is as follows:

           

        ------------------------------------CODE-------------------------------------------------

           

         device = new CCyUSBDevice();
            int endpointcount = device->EndPointCount();
            cendp = device->ControlEndPt;
            LoadHexFile(L"USB20.hex");
            endpointcount = device->EndPointCount();
            device->Close();
            
            if(device->Open(0)==false)
            {
                MessageBox(0,L"firsterror",L"error",MB_OK);
                device->Reset();
                if(device->Open(0)==false)
                MessageBox(0,L"second open error",L"error",MB_OK);
            }
            
            cendp = device->ControlEndPt;
            if(cendp ==0)
                MessageBox(0,L"invalid endpoint",L"error",MB_OK);
            endpointcount = device->EndPointCount();
            delete device;

           

        -------------------------------------ENDCODE-------------------------------------------

           

        The first time i run this code the errors:

           

        "first open error"

           

        "second open error"

           

        "invalid endpoint"

           

        comes.

           

        The second time (the device is not disconnected) there is only "first open error" error.

           

        What is wrong with this code?Is there anyway to get endpoints after loading hex without close/open commands?

           

        Thanks in advance.

        • 2. Re: Cy7C6013:CyAPI:how to get endpoints after loading .hex file
          a.p

          I also noticed that when i run the code in debug and step over after close/open i see new values of endpoints when put breakpoint on the last :endpointcount = device->EndPointCount(); sometimes i get 1 sometimes 0.