1 Reply Latest reply on Sep 17, 2018 7:35 AM by abga

    Why don't add BeginDataXfer(ref byte[] singleXfer, ref byte[] buffer, ref int len, ref OVERLAPPED ov) overload in CyUSB.dll ?

    user_193279881

      Hello,

       

      time ago I 've posted a discussion Why BeginDataXfer and FinishDataXfer accept Byte array instead of OVERLAPPED struct like WaitForXfer ?

      and I check answer as correct ...

       

      But I believe that if CyUSB.dll has a BeginDataXfer and FinishDataXfer that accept OVERALAPPED structure reference as last parameter instead of byte array reference

      user program will be less complex because of using unsafe/fixed keywords or Marshall class ... this complexity arise because WaitForXfer accept hEvent member of

      OVERALAPPED struct.

       

      Yesterday I downloaded CyAPI from site (http://www.cypress.com/documentation/software-and-drivers/ez-usb-fx3-software-development-kit)

      then I analyze CyUSBEndPoint::BeginDataXfer method and CyUSBEndPoint::FinishDataXfer respectively at line 295 and 374 ...

       

      I believe that if you add this two overloads (in the snippet below) in CyUSBEndPoint class ... you can implement (for all endpoint types except isochronous) what I discuss in Why BeginDataXfer and FinishDataXfer accept Byte array instead of OVERLAPPED struct like WaitForXfer ?

       

       

      public unsafe bool BeginDataXfer(ref byte[] singleXfer, ref byte[] buffer, ref int len, ref OVERLAPPED ov)

      {

       

           fixed(OVERLAPPED* pov = &ov)

           {

       

                byte[] barray = new byte[sizeof(OVERLAPPED)];

       

                Marshal.Copy((IntPtr)pov, barray,0,sizeof(OVERLAPPED));

       

                return BeginDataXfer(ref singleXfer, ref buffer, ref len, ref barray);

           }

      }

       

       

      public unsafe bool FinishDataXfer(ref byte[] singleXfer, ref byte[] buffer, ref int len, ref OVERLAPPED ov)

       

      {

           fixed (OVERLAPPED* pov = &ov)

           {

       

                byte[] barray = new byte[sizeof(OVERLAPPED)];

       

                Marshal.Copy((IntPtr)pov, barray, 0, sizeof(OVERLAPPED));

       

                return FinishDataXfer(ref singleXfer, ref buffer, ref len, ref barray);

           }

      }

       

       

       

       

      Please give me feedback ...