2 Replies Latest reply on Sep 4, 2019 3:37 AM by HemanthR_06

    How to slove bulk transfer problem:URB STATUS -ENOENT

    lixi_2737346

      soft environment:

      ubuntu 16.04  +  cyusb3014

      Problem Description:

      My goal is to get the data uploaded by cyusb3014,but whenever the program runs for 4-5 hours, the reception timeout will suddenly appear.

      With the help of monusb under linux,I caught it at that moment, urb status = -2,and no matter what I call cyusb_reset_device() or cyusb_clear_halt(),it can't afford any effect。

      so, What causes this phenomenon?       How can I perform the operation to let the reception continue?

      I am looking forward to your reply. This problem has been bothering me for a week.

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

      Attach my code about bulk transfer:

      bool USBHandler::USBIn(unsigned char * buffer, size_t bufferSize){

          HANDLENotNULL;

          int r;

          libusb_context *ctx = NULL;

          struct libusb_transfer *transfers = libusb_alloc_transfer (0);

          int transferred = 0;

          int pkg_size=1228800;

       

       

          if (transfers == NULL)

          {

                printf ("Failed to allocate buffers and transfer structures\n");

                free_transfer_buffers (transfers);

                return false;  

          }

       

          libusb_fill_bulk_transfer (transfers, getRealHandler(h1), 0x83,buffer, 1228800, xfer_callback, NULL, 100);

       

          r = libusb_submit_transfer (transfers);

          cout<<"submit status:"<<r<<endl;

          if(r<0)

          {

                // libusb_cancel_transfer(transfers);

                free_transfer_buffers(transfers);

                return false;

          }

       

          SetTransmitPicure(1);

       

          do

          {

                libusb_handle_events (NULL);

          } while ((!get_one_frame)&&(!error_happen)&&(!time_out_happen));

       

       

          if(error_happen)

          {

           Reset();

          }

       

          if(time_out_happen)

          {

           //Reset();

          }

       

       

           cout<<"error_count:"<<error_count<<endl;

           cout<<"transfer timeout_count:"<<time_out_count<<endl;

           if((error_happen)||(time_out_happen))

           {

                error_happen = 0;

                time_out_happen = 0;

                return false;

           }

       

          get_one_frame = 0 ;

       

          return true;

      }

       

      void USBHandler::xfer_callback (

      struct libusb_transfer *transfer)

      {

           int r = 0;

           switch (transfer->status)

           {

            case LIBUSB_TRANSFER_COMPLETED:

                cout<<"transfer complete!"<<endl;

                get_one_frame = 1;

                free_transfer_buffers(transfer);

                break;

       

       

           case  LIBUSB_TRANSFER_ERROR:

                error_happen = 1;

                error_count++;

                cout<<"transfer uncomplete!"<<endl;

                libusb_cancel_transfer(transfer);

                free_transfer_buffers(transfer);

                break;

       

       

           case  LIBUSB_TRANSFER_TIMED_OUT:

                time_out_happen = 1;

                time_out_count++;

                libusb_cancel_transfer(transfer);

                free_transfer_buffers(transfer);

                break;

       

       

           default:

                error_happen = 1;

                error_count++;

                cout<<"other error happen!"<<endl;

                libusb_cancel_transfer(transfer);

                free_transfer_buffers(transfer);

                break;

           }

      }