Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > difference between begindataxfer and xferdata functions

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



difference between begindataxfer and xferdata functions
Moderator:
RSKV

Post Reply
Follow this topic



difference between begindataxfer and xferdata functions

talha posted on 17 Oct 2011 1:18 AM PST
Senior Member
11 Forum Posts

I am using cyc68013 development kit for my application of data transfer.
I am sending and receiving 8 bytes of buffer means length = 8.
I am using bulk end points.

the coding I am using in vc++ is here

UCHAR *outContext= USBDevice->BulkOutEndPt->BeginDataXfer((unsigned char *)buffer, length,&outOvLap);

UCHAR *inContext = USBDevice->BulkInEndPt->BeginDataXfer(inBuf, length,&inOvLap);
USBDevice->BulkInEndPt->WaitForXfer(&inOvLap,200);


with this coding I get the required speed say, my complete test run in 62 seconds, I have not used waitforxfer in sending data.

but when I used this coding in c#

outEndpoint.XferData(ref outData, ref xferLen);
inEndpoint.XferData(ref inData, ref xferLen);

my test run in 124 seconds. why
what is the difference between them.
and it is very hard to understand begindataxfer in c#.

please also I need virtual com port driver and hex for 68013 128axc.

Thanks in Advance.




Re: difference between begindataxfer and xferdata functions

aasi posted on 17 Oct 2011 05:21 AM PST
Cypress Employee
1090 Forum Posts

Xferdata just calls Begindataxfer, waitforxfer and finishdataxfer in sequence and does error handling accordingly.

Waitforxfer is the one which implements the timeout period for larger transfers your approach most probably won't work.

Regards,

Anand



Re: difference between begindataxfer and xferdata functions

talha posted on 18 Oct 2011 12:00 AM PST
Senior Member
11 Forum Posts

1. please help me know about the code line in red color.

STDMETHODIMP CComb::twopinresult(int firstpin, int secondpin, int *pinsresult)
{
    CCyUSBDevice  *USBDevice = new  CCyUSBDevice(NULL);
    OVERLAPPED outOvLap, inOvLap;
    outOvLap.hEvent  = CreateEvent(NULL, false, false, "CYUSB_OUT");
    inOvLap.hEvent   = CreateEvent(NULL, false, false, "CYUSB_IN");

    char buffer[8]="***###";
    unsigned char  inBuf[8]="000000";

    unsigned int OMIfirstpincardno ;
    unsigned int OMIsecondpincardno;
    unsigned int OMIfirstpinonboard ;
    unsigned int OMIsecondpinonboard ;

    LONG  length = 8;

    char tempbyte1;
    char tempbyte2;
   
        OMIfirstpincardno = (firstpin - 1) / 100;
        OMIfirstpinonboard = ((firstpin - 1) - (OMIfirstpincardno * 100));
        tempbyte1 = OMIfirstpinonboard;
        tempbyte2 = tempbyte1;

            switch(tempbyte1 & 0x07)
            {
            case 0x00:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x04;
                break;
            case 0x01:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x02;
                break;
            case 0x02:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x06;
                break;
            case 0x03:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x01;
                break;
            case 0x04:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x07;
                break;
            case 0x05:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x00;
                break;
            case 0x06:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x05;
                break;
            case 0x07:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x03;
                break;
            }

            sprintf(&buffer[1],"%c",OMIfirstpincardno);
            sprintf(&buffer[2],"%c",tempbyte1);

        OMIsecondpincardno = (secondpin - 1) / 100;
        OMIsecondpinonboard = ((secondpin - 1) - (OMIsecondpincardno * 100));
        tempbyte1 = OMIsecondpinonboard;
        tempbyte2 = tempbyte1;

            switch(tempbyte1 & 0x07)
            {
            case 0x00:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x04;
                break;
            case 0x01:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x02;
                break;
            case 0x02:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x06;
                break;
            case 0x03:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x01;
                break;
            case 0x04:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x07;
                break;
            case 0x05:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x00;
                break;
            case 0x06:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x05;
                break;
            case 0x07:
                tempbyte1     = tempbyte2 & 0xF8;
                tempbyte1     = tempbyte1 | 0x03;
                break;
            }

            sprintf(&buffer[3],"%c",OMIsecondpincardno);
            sprintf(&buffer[4],"%c",tempbyte1);
            buffer[5] =  0xFC;        //  1111 1100
            buffer[6] = 0x00;

    UCHAR  *outContext= USBDevice->BulkOutEndPt->BeginDataXfer((unsigned char *)buffer, length,&outOvLap);


    UCHAR  *inContext = USBDevice->BulkInEndPt->BeginDataXfer(inBuf, length,&inOvLap);
    USBDevice->BulkInEndPt->WaitForXfer(&inOvLap,100);

    if (inBuf[1] == 255)
    {
        *pinsresult = 0;
    }
    else
    {
        *pinsresult = 1;   
    }

    CloseHandle(outOvLap.hEvent);
     CloseHandle(inOvLap.hEvent);


    return S_OK;
}

2. I am running this function 499500 times. each time I have to take the handle which is actually consuming time.

what should I do to take the all handles in constructor and calling begindataxfer in function or method.

this way only begindataxfer will be running in loop no handles.

 

Thank s in advance

Ameen Sharif






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20