2 Replies Latest reply on Oct 29, 2011 7:33 AM by gayathri.vasudevan

    Problems with Bulk Transfer using CYIOCTL

    simon.koops

      Hi,

         

      I'm trying to make a bulk transfer using the IOCTL Interface of the cyusb.sys driver with Delphi, but the DeviceIOControl Function always returns 87 (ERROR_INVALID_PARAMETER).

         

      I'm using the following Code :

         

      procedure NonEP0TransferOut(handle:THandle;endPointAddress:Byte; pBuffer:PBuffer; bufferSize:Word);
      const cBufSize = 512;
      var
          singleTransfer:SINGLE_TRANSFER;
        buffer : array[0..cBufSize+SizeOf(SINGLE_TRANSFER)-1] of Byte;
        i : Integer;
        dwBytes: DWORD;
      begin
          ZeroMemory(@singleTransfer, SizeOf(SINGLE_TRANSFER));

        SingleTransfer.SetupPacket.ulTimeOut := 1000;
        singleTransfer.ucEndpointAddress := endPointAddress;
        singleTransfer.IsoPacketLength := 0;
        singleTransfer.BufferOffset := SizeOf(SINGLE_TRANSFER);
        singleTransfer.BufferLength := bufferSize;
        dwBytes := 0;

          Move(SingleTransfer,Buffer,SizeOf(SINGLE_TRANSFER));

        for i := 0 to bufferSize-1 do begin
            buffer[i+SizeOf(TSingleTransfernEP0)] := pBuffer^[i]; // buffer direkt hinter den SINGLE_TRANFER record schreiben
        end;

        if not DeviceIoControl(    handle,IOCTL_ADAPT_SEND_NON_EP0_TRANSFER,
                                @buffer, bufferSize+SizeOf(SINGLE_TRANSFER),
                                @buffer, bufferSize+SizeOf(SINGLE_TRANSFER),
                                dwBytes,nil) then
            raise ECyUSBException.Create('Error #17 during nonEP0 control Transfer : ' + IntToStr(getLastError()));
      end;

         

      The SINGLE_TRANSFER structure seems to be correct. It works fine for EP0 Transfers. I also tried IOCTL_ADAPT_SEND_NON_EP0_DIRECT, which gives the same error. Can someone tell me what I'm doing wrong ?

         

      regards

         

      Simon Koops