Share via


UsbDbgPdd_SendData (Compact 2013)

10/16/2014

Implement this function to start a send transfer on a USB endpoint and to send data.

Syntax

extern "C" DWORD UsbDbgPdd_SendData(
    DWORD epNum,
    PBYTE pBuffer,
    DWORD cbLength,
    DWORD transferFlags,
    DWORD* pTransferStatus
    )

Parameters

  • epNum
    [in] Endpoint on which to send data.

    Endpoint

    UsbDbgRndisMdd

    UsbDbgSerMdd

    0

    INT IN

    BULK OUT

    1

    INT IN

    BULK OUT

    2

    BULK IN

    BULK IN

    3

    BULK OUT

    Not used.

  • pBuffer
    [in] Buffered data to send.

    Note

    The buffer is not aligned.

  • cbLength
    [in] Size of the pBuffer parameter in bytes.
  • transferFlags
    [in] Flag indicating transfer status. Multiple flags may be ORed together.
  • pTransferStatus
    [out] Pointer to a flag indicating transfer status.

Return Value

Implement this function to return the number of bytes sent if successful; otherwise, return -1 if not successful. The MDD cancels the transfer if -1 is returned.

Example

The following example shows a typical implementation of the UsbDbgPdd_SendData function.

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

extern "C" DWORD UsbDbgPdd_SendData(
    DWORD epNum,
    PBYTE pBuffer,
    DWORD cbLength,
    DWORD transferFlags,
    DWORD* pTransferStatus
    )
{
    USBFN_PDD *pPddContext  = (USBFN_PDD *)&usbfn_pdd;
    DWORD dwBytesTransfered = 0;
    USBDBGMSG(USBDBG_ZONE_FUNC, (L"usbdbgpdd: +UsbDbgPdd_SendData\r\n"));

    USBDBGMSG(USBDBG_ZONE_VERBOSE, (L"+UsbDbgPdd_SendData:: , epNum --> 0x%x\r\n", epNum));
    USBDBGMSG(USBDBG_ZONE_VERBOSE, (L"+UsbDbgPdd_SendData:: , pBuffer --> 0x%x\r\n", pBuffer));
    USBDBGMSG(USBDBG_ZONE_VERBOSE, (L"+UsbDbgPdd_SendData:: , cbLength --> 0x%x\r\n", cbLength));
    USBDBGMSG(USBDBG_ZONE_VERBOSE, (L"+UsbDbgPdd_SendData:: , transferFlags --> 0x%x\r\n", transferFlags));


    if (!pPddContext->ep[epNum]->bTransmitBufferInUse)
    {
        // Copy the contents of the MDD Passed buffer to the local buffer.
        memcpy(pPddContext->ep[epNum]->TransmitBuffer, pBuffer, cbLength);
        IssueTransfer( pPddContext, epNum, pBuffer,  cbLength, IN_TRANSFER, &dwBytesTransfered);

        // for interrupt IN EP, indicate completion now.
        if (pPddContext->ep[epNum]->bmAttributes == 3)
        {
            *pTransferStatus |= USBDBG_PDD_TRANSFER_COMPLETE;
        }

        dwBytesTransfered = cbLength;
    }
    else
    {
        USBDBGMSG(USBDBG_ZONE_INFO, (L"UsbDbgPdd_SendData:: Transmit Buffer INUSE 0x%x\r\n", epNum));
    }

    USBDBGMSG(USBDBG_ZONE_VERBOSE, (L"UsbDbgPdd_SendData:: , pTransferStatus --> 0x%x\r\n", *pTransferStatus));
    USBDBGMSG(USBDBG_ZONE_VERBOSE, (L"UsbDbgPdd_SendData:: Transmitted 0x%x bytes\r\n", dwBytesTransfered));
    USBDBGMSG(USBDBG_ZONE_VERBOSE, (L"UsbDbgPdd_SendData::  pPddContext->ep[epNum]->TransmitBufferPhysical  0x%x\r\n",  \
                                        pPddContext->ep[epNum]->TransmitBufferPhysical));
    USBDBGMSG(USBDBG_ZONE_VERBOSE, (L"UsbDbgPdd_SendData:: bp0  0x%x\r\n", pPddContext->qhbuffer->td[epNum*2].bp0));


    USBDBGMSG(USBDBG_ZONE_FUNC, (L"usbdbgpdd: -UsbDbgPdd_SendData\r\n"));
    return dwBytesTransfered;
}

Requirements

Header

UsbDbgDdsi.h

See Also

Reference

USBDBG PDD Functions