1 2 3 4 Previous Next 46 Replies Latest reply on Jun 19, 2019 1:13 AM by KandlaguntaR_36 Go to original post
      • 30. Re: CyU3PUsbSendEP0 Timeout issue
        leda_289486

        Hi,

        have you checked the code ?

        with it we can confirm that the timeout comes from the CY_U3P_UIB_EEPM_EP_READY part. It is set at 0 when this timeout condition triggers and cannot be resetted after.

        Best Regards.

        • 31. Re: CyU3PUsbSendEP0 Timeout issue
          KandlaguntaR_36

          I checked the code.

          Thank you for the confirmation that the timeout comes from CY_U3P_UIB_EEPM_EP_READY.

           

           

          • 32. Re: CyU3PUsbSendEP0 Timeout issue
            leda_289486

            Hi,

            have you a solution to try ? Even if this is not completly functionnal, I can test it.

            This bit is telling us that hardware is not ready to send data on EP0. Is there a way to check that the endpoint 0 is still considered connected (functionnal) ? I've tried to use CyU3PUsbStart and CyU3PUsbStop to "force" a kind of connection when sendEP0 tmo error arrises but these functions don't work that way. If this exists (check working connection on EP) can I use it for all endpoints for debugging purposes ?

            Best Regards

            • 33. Re: CyU3PUsbSendEP0 Timeout issue
              leda_289486

              Hi,

              have you some solution to be tested for resetting the hardware bit preventing the EP0 in to work correctly ?

              This is quite important, we must have a reliable EP0 feature, if not, we cannot control cameras correctly with CX3.

              Thank you for your help,

              Best Regards.

              • 34. Re: CyU3PUsbSendEP0 Timeout issue
                leda_289486

                Hi,

                Have you some solution for this issue ? I would like to test some workarounds if possible. It has been near 14 days since previous answer.

                Thank you for your help,

                Best Regards

                • 35. Re: CyU3PUsbSendEP0 Timeout issue
                  KandlaguntaR_36

                  Hello,

                   

                  I can see the following in your code.

                  Please replace this part with the code below line (-----).

                   

                  txApiRetStatus = VendorInterpreter(); // processing the command here. no EP0 handling in it

                   

                   

                  if (txApiRetStatus == CY_U3P_SUCCESS)

                  {

                  if ((setupReqType & 0x80) == 0x80)

                  {

                  txApiRetStatus = CyU3PUsbSendEP0Data(RequestedReturnSize, AnswerToPC); // direct answer

                  CyU3PUsbAckSetup(); // useful or not ???

                  }

                  else

                  {

                  CyU3PUsbAckSetup();

                  }

                  }

                  else

                  {

                  CyU3PUsbAckSetup();

                  if (ValidDebugMessage) CyU3PDebugPrint(4, "Bad return 0x%x\r\n", txApiRetStatus);

                  }

                   

                  if (txApiRetStatus != CY_U3P_SUCCESS)

                  {

                  uint8_t ret2; //ret2,ret3,ret4;

                  CyU3PUsbSetEpNak(DEFINITION_OF_ZERO_EP, CyTrue);

                   

                   

                  CyU3PUsbResetEp(DEFINITION_OF_ZERO_EP);

                  CyU3PUsbFlushEp(DEFINITION_OF_ZERO_EP);

                  CyU3PBusyWait(100);

                  CyU3PUsbSetEpNak(CY_FX_EP_BULK_VIDEO, CyFalse);

                   

                   

                  ret2 = CyU3PUsbStall(DEFINITION_OF_ZERO_EP, CyTrue, CyTrue);

                  /* Error handling from EP0Send at this level. */

                  if (ValidDebugMessage) CyU3PDebugPrint(4, "\r\nError EP0 (0x%x - 0x%x) %d size = %d ret = %d ",

                  CopySetupDat0, CopySetupDat1, txApiRetStatus, RequestedReturnSize, ret2);

                   

                   

                  CyU3PTimerStart(&UvcTimer); // launch timer -> ClearFeaturefunction(0,0)

                  }

                   

                  -------------------------------------------------------------------------------------------------------------------------

                   

                   

                  txApiRetStatus = VendorInterpreter(); // processing the command here. no EP0 handling in it

                   

                   

                  if (txApiRetStatus == CY_U3P_SUCCESS)

                  {

                  if ((setupReqType & 0x80) == 0x80)

                       {

                            txApiRetStatus = CyU3PUsbSendEP0Data(RequestedReturnSize, AnswerToPC); // direct answer

                            if(txApiRetStatus != CY_U3P_SUCCESS)

                                {

                                 /* There was some error. We should try stalling EP0. */

                                  CyU3PUsbStall(0, CyTrue, CyFalse);

                   

                                 }

                       }

                  else

                       {

                                CyU3PUsbAckSetup();

                       }

                  }

                  else

                  {

                       CyU3PUsbAckSetup();

                       if (ValidDebugMessage) CyU3PDebugPrint(4, "Bad return 0x%x\r\n", txApiRetStatus);

                  }

                   

                  if (txApiRetStatus != CY_U3P_SUCCESS)

                  {

                  uint8_t ret2; //ret2,ret3,ret4;

                  CyU3PUsbSetEpNak(DEFINITION_OF_ZERO_EP, CyTrue);

                   

                   

                  CyU3PUsbResetEp(DEFINITION_OF_ZERO_EP);

                  CyU3PUsbFlushEp(DEFINITION_OF_ZERO_EP);

                  CyU3PBusyWait(100);

                  CyU3PUsbSetEpNak(CY_FX_EP_BULK_VIDEO, CyFalse);

                   

                   

                  ret2 = CyU3PUsbStall(DEFINITION_OF_ZERO_EP, CyTrue, CyTrue);

                  /* Error handling from EP0Send at this level. */

                  if (ValidDebugMessage) CyU3PDebugPrint(4, "\r\nError EP0 (0x%x - 0x%x) %d size = %d ret = %d ",

                  CopySetupDat0, CopySetupDat1, txApiRetStatus, RequestedReturnSize, ret2);

                   

                   

                  CyU3PTimerStart(&UvcTimer); // launch timer -> ClearFeaturefunction(0,0)

                  }

                  • 36. Re: CyU3PUsbSendEP0 Timeout issue
                    leda_289486

                    Hi

                    thank you for your feedback. I'll try the modification asap and I'll tell you the result.

                    Thank you for your help,

                    Best Regards.

                    • 37. Re: CyU3PUsbSendEP0 Timeout issue
                      leda_289486

                      Hi,

                      as said, i've implemented your code.

                      However, there are still cases where the hardware error condition is triggered and when this happens, there is no way to retrieve correct behavior.

                      Can you propose a solution to clear this condition please ?

                      Thank you for your help,

                      Best Regards.

                      • 38. Re: CyU3PUsbSendEP0 Timeout issue
                        KandlaguntaR_36

                        We cannot clear the hardware error condition in the firmware.

                        It looks like you are not handling a few things in the firmware properly. Hence, it is hitting the error condition.


                        Do not call CyU3PUsbAckSetup(); after CyU3PUsbSendEP0Data API in all the cases in the firmware.

                        • 39. Re: CyU3PUsbSendEP0 Timeout issue
                          leda_289486

                          Hi,

                          thank you for you answer. So when do we call CyU3PUsbAckSetup exactly ? our api framework is retrieved from cypress examples.

                          So you are telling me that when error is triggered, there is nothing we can do ? is there a way to reset hardware in this case : camera is supposed to be always active.

                          Best Regards,

                          • 40. Re: CyU3PUsbSendEP0 Timeout issue
                            leda_289486

                            Hi,

                            I've checked out some code examples from cypress with SendEP0Data in it. For example, in cyfxlowpowertest, after the SendEP0Data, firmware calls a CyU3PUsbAckSetup procedure when ok and CyU3PUsbStall when a problem has arisen. So I'm quite confused with your sentence "Do not call CyU3PUsbAckSetup(); after CyU3PUsbSendEP0Data API in all the cases in the firmware". What does it mean precisely ?

                            What are the cases to be processed with a CyU3PUsbAckSetup exactly ?

                            Thank you for your help,

                            Best Regards

                            • 41. Re: CyU3PUsbSendEP0 Timeout issue
                              leda_289486

                              Hi,

                              What can we do when the error condition from hardware is triggered ?

                              Could you indicate us a framework example preventing this error to happen in any case and where vendor commands are correctly post-processed ?

                              Last possibility : is it possible to restart cx3 device without being disconnected ?

                              Thank you for your help,

                              Best Regards.

                              • 42. Re: CyU3PUsbSendEP0 Timeout issue
                                KandlaguntaR_36

                                Hello,

                                 

                                The return value of CyFxUVCApplnUSBSetupCB is not updating properly. We defined "uvcHandleReq" as return value for USBSetupCB. This value is updated only once in the SetupCB: That is only for UVC Class Requests.

                                 

                                If the SetupCB is for Vendor class request, the SetupCB is returning CyFalse in this case, even though you have handled.

                                It is supposed to return CyTrue when you have handled the Vendor Request.

                                Please modify the snippet as below and check.

                                 

                                 

                                txApiRetStatus = VendorInterpreter(); // processing the command here. no EP0 handling in it

                                 

                                 

                                if (txApiRetStatus == CY_U3P_SUCCESS)

                                {

                                if ((setupReqType & 0x80) == 0x80)

                                     {

                                              uvcHandleReq = CyTrue;

                                          txApiRetStatus = CyU3PUsbSendEP0Data(RequestedReturnSize, AnswerToPC); // direct answer

                                          if(txApiRetStatus != CY_U3P_SUCCESS)

                                              {

                                               /* There was some error. We should try stalling EP0. */

                                                CyU3PUsbStall(0, CyTrue, CyFalse);

                                 

                                               }

                                     }

                                else

                                     {

                                               uvcHandleReq = CyTrue;

                                              CyU3PUsbAckSetup();

                                     }

                                }

                                else

                                {

                                               uvcHandleReq = CyTrue;

                                     CyU3PUsbAckSetup();

                                     if (ValidDebugMessage) CyU3PDebugPrint(4, "Bad return 0x%x\r\n", txApiRetStatus);

                                }

                                 

                                -----------------------------------------------------------------

                                Note that CyU3PUsbAckSetup function is used to complete the status handshake of a USB control request that does not involve any data transfer.

                                If there is a need for OUT or IN data transfers to process the control request, the CyU3PUsbGetEP0Data and CyU3PUsbSendEP0Data calls should be used instead.

                                This function should only be used if a positive ACK is to be sent to the USB host. To indicate an error condition, the CyU3PUsbStall call should be used to stall the endpoint EP0-OUT or EP0-IN.

                                ----------------------------------------------------

                                 

                                I can see that lowpower test example is sending CyU3PUsbAckSetup eventhough CyU3PUsbSendEP0Data is success. In failure or isHandled CyFalse case, the zero endpoint is stalled.

                                 

                                This is contradicting the above note. I will check on this and update you. Meanwhile, you go with above snippet implementation: CyU3PUsbSendEP0Data or CyU3PUsbAckSetup at a time and returning the SetupCB with CyTrue when the command is handled in firmware.

                                • 43. Re: CyU3PUsbSendEP0 Timeout issue
                                  leda_289486

                                  Hi,

                                  thank you for this feedback. I implement the modifications immediatly. This is good news !

                                  I'll wait for your update about the example you talked in your answer.

                                  Thank you for your help,

                                  Best Regards,

                                  • 44. Re: CyU3PUsbSendEP0 Timeout issue
                                    KandlaguntaR_36

                                    Hello,

                                     

                                    CyU3PUsbAckSetup should not be called if CyU3PUsbSendEP0Data success.

                                    We will correct the lowpowertest example firmware in the next revision.

                                     

                                    Is the issue solved after the code modification?

                                     

                                    Regards,

                                    Sridhar