Jump to content

UsbStartIsoTransfer: Difference between revisions

From EDM2
W.m.brul (talk | contribs)
Ak120 (talk | contribs)
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 3: Line 3:


==Syntax==
==Syntax==
<pre>
ulrc = UsbStartIsoTransfer(Handle,
ulrc = UsbStartIsoTransfer(Handle,ucEndpoint,ucAltSetting,ulEvent,pucParm,pucData,usFrameLength,usFrameCount)
                            ucEndpoint,ucAltSetting,
</pre>
                            ulEvent,
                            pucParm,pucData,
                            usFrameLength,usFrameCount)


==Parameters==
==Parameters==
; Handle : the Device Handle received from the previous UsbOpen.
; Handle : the Device Handle received from the previous UsbOpen.
; ucEndpoint : the Endpoint Number appropriate for the data transfer.
; ucEndpoint : the Endpoint Number appropriate for the data transfer.
; ucAltSetting : the Alternate Setting of the interface having this endpoint.
; ucAltSetting : the Alternate Setting of the interface having this endpoint.
; ulEvent : the handle of the event semaphore to be posted on completion.
; ulEvent : the handle of the event semaphore to be posted on completion.
; usFrameLength : the maximum number of bytes in an isochronous frame.
; usFrameLength : the maximum number of bytes in an isochronous frame.
; usFrameCount : the number of isochronous frames in the Data Buffer.  
; usFrameCount : the number of isochronous frames in the Data Buffer.  
; pucParm : the address of the Parm Buffer with usDatalength and usStatus.
; pucParm : the address of the Parm Buffer with usDatalength and usStatus.
; usDataLength : the variable to specify/receive the number of data bytes.
; usDataLength : the variable to specify/receive the number of data bytes.
; usStatus : the variable to receive the asynchronous Completion Status.
; usStatus : the variable to receive the asynchronous Completion Status.
''For device-to-host data transfer:''
''For device-to-host data transfer:''
; pucData : the address of the Data Buffer to receive the bytes transferred.
; pucData : the address of the Data Buffer to receive the bytes transferred.
''For host-to-device data transfer:''
''For host-to-device data transfer:''
; pucData : the address of the Data Buffer with the bytes to be transferred.
; pucData : the address of the Data Buffer with the bytes to be transferred.


==Return Code==
==Return Code==
<pre>
0x0000 - NO_ERROR
0x0000 - NO_ERROR
 
</pre>
===Errors===
===Errors===
<pre>
<pre>
Line 52: Line 41:


==Status Code==
==Status Code==
<pre>
0x0000 - USB_IORB_DONE
0x0000 - USB_IORB_DONE
 
</pre>
===Errors===
===Errors===
<pre>
0x4000 - USB_IORB_REQUEST
0x4000 - USB_IORB_REQUEST
0x80XX - USB_IORB_FAILED
0x80XX - USB_IORB_FAILED
 
</pre>
==Remarks==
==Remarks==
Concatenated Payloads are being used when usFrameCount equals zero. When UsbStartIsoTransfer is issued and Concatenated Payloads are being used
Concatenated Payloads are being used when usFrameCount equals zero. When UsbStartIsoTransfer is issued and Concatenated Payloads are being used then usDatalength in the Parm Buffer must be set to the number of bytes to be transferred. When the transfer request has been completed then usDataLength in the Parm Buffer contains the number of bytes transferred.
then usDatalength in the Parm Buffer must be set to the number of bytes to be transferred. When the transfer request has been completed then usDataLength in the Parm Buffer contains the number of bytes transferred.


Individual Iso Frames are being used when usFrameCount is larger than zero. When UsbStartIsoTransfer is issued and Individual Iso Frames are being used then each element of the additional usFrameSize[FrameCount] array in the Parm Buffer must be set to usFrameLength. When the transfer request has been completed then each element of the additional usFrameSize[FrameCount] array contains the number of bytes transferred. Individual Iso Frames are stored in the usFrameData[FrameCount][FrameLength] array in the Data Buffer.
Individual Iso Frames are being used when usFrameCount is larger than zero. When UsbStartIsoTransfer is issued and Individual Iso Frames are being used then each element of the additional usFrameSize[FrameCount] array in the Parm Buffer must be set to usFrameLength. When the transfer request has been completed then each element of the additional usFrameSize[FrameCount] array contains the number of bytes transferred. Individual Iso Frames are stored in the usFrameData[FrameCount][FrameLength] array in the Data Buffer.
Line 138: Line 124:


==Related Functions==
==Related Functions==
* [[UsbCancelTransfer]]
* [[UsbIsoOpen]]
* [[UsbOpen]]


[[Category:USBCalls]]
[[Category:USBCalls]]

Latest revision as of 22:39, 13 September 2021

Description

Starts asynchronous Isochronous Transfers with a specific endpoint.

Syntax

ulrc = UsbStartIsoTransfer(Handle,
                           ucEndpoint,ucAltSetting,
                           ulEvent,
                           pucParm,pucData,
                           usFrameLength,usFrameCount)

Parameters

Handle
the Device Handle received from the previous UsbOpen.
ucEndpoint
the Endpoint Number appropriate for the data transfer.
ucAltSetting
the Alternate Setting of the interface having this endpoint.
ulEvent
the handle of the event semaphore to be posted on completion.
usFrameLength
the maximum number of bytes in an isochronous frame.
usFrameCount
the number of isochronous frames in the Data Buffer.
pucParm
the address of the Parm Buffer with usDatalength and usStatus.
usDataLength
the variable to specify/receive the number of data bytes.
usStatus
the variable to receive the asynchronous Completion Status.

For device-to-host data transfer:

pucData
the address of the Data Buffer to receive the bytes transferred.

For host-to-device data transfer:

pucData
the address of the Data Buffer with the bytes to be transferred.

Return Code

0x0000 - NO_ERROR

Errors

0x0057 - ERROR_INVALID_PARAMETER
0x1B58 - USB_NOT_INIT
0xFF0D - ERROR_INVALID_DATA
0xFF13 - ERROR_I24_INVALID_PARAMETER
0xFF13 - USB_IDC_PARMERR
0xFF18 - USB_IDC_ADDRINV
0xFF37 - ERROR_DEV_NOT_EXIST
0xFF5D - EROR_NO_ITEMS
0xFFA7 - ERROR_LOCK_FAILED

Status Code

0x0000 - USB_IORB_DONE

Errors

0x4000 - USB_IORB_REQUEST
0x80XX - USB_IORB_FAILED

Remarks

Concatenated Payloads are being used when usFrameCount equals zero. When UsbStartIsoTransfer is issued and Concatenated Payloads are being used then usDatalength in the Parm Buffer must be set to the number of bytes to be transferred. When the transfer request has been completed then usDataLength in the Parm Buffer contains the number of bytes transferred.

Individual Iso Frames are being used when usFrameCount is larger than zero. When UsbStartIsoTransfer is issued and Individual Iso Frames are being used then each element of the additional usFrameSize[FrameCount] array in the Parm Buffer must be set to usFrameLength. When the transfer request has been completed then each element of the additional usFrameSize[FrameCount] array contains the number of bytes transferred. Individual Iso Frames are stored in the usFrameData[FrameCount][FrameLength] array in the Data Buffer.

Example Code

//Code Snippet - UsbStartIsoTransfer
// Individual Iso Frames
#define FrameCount 60
#define FrameLength 0x44
{
  APIRET ulrc;
  PUCHAR pucData;
  UCHAR ucAltSetting = 1;
  UCHAR ucData[FrameCount][FrameLength];
  UCHAR ucEndpoint = 0x86;
  ULONG ulTimeout = 8000;
  USHORT usFrameLength = FrameLength;
  USHORT usFrameCount = FrameCount;

  HEV hIsoComplete;
  PHEV phIsoComplete;
  typedef struct
  { USHORT usStatus;
    USHORT usDataLength;
    USHORT usFrameSize[FrameCount];
  } USBCALLS_ISO_RSP, *PUSBCALLS_ISO_RSP;
  PUSBCALLS_ISO_RSP pIsoResponse;
  USBCALLS_ISO_RSP IsoResponse;
  int i;

  //acquire semaphore
  phIsoComplete = &hIsoComplete;
  ulrc = DosCreateEventSem(NULL,phIsoComplete,DC_SEM_SHARED,FALSE);
  printf("\nDosCreateEventSem - ulrc: 0x%04X (%hu)",ulrc,ulrc);

  //start isochronous data transfer
  IsoResponse.usDataLength = sizeof(ucData);
  pIsoResponse = &IsoResponse; pucData = &ucData[0][0];
  for (i=0;i<usFrameCount;i++) IsoResponse.usFrameSize[i] = usFrameLength;
  ulrc = UsbStartIsoTransfer(Handle,ucEndpoint,ucAltSetting,hIsoComplete,(PUCHAR)pIsoResponse,pucData,usFrameLength,usFrameCount);
  printf("\nUsbStartIsoTransfer - ulrc: 0x%04X (%hu)",ulrc,ulrc);

  //await isochronous data transfer complete
  ulrc = DosWaitEventSem(hIsoComplete,ulTimeout);
  printf("\nDosWaitEventSem - ulrc: 0x%04X (%hu)",ulrc,ulrc);
  if (!ulrc) //success
  {
    ulrc = IsoResponse.usStatus;
    printf("\nCompletion Status - ulrc: 0x%04X (%hu)",ulrc,ulrc);
    if (!ulrc) //success
    {
      int j; printf(" - isochronous data:");
      for (j=0;j<usFrameCount;j++)
      {
        if (IsoResponse.usFrameSize[j]) printf("\n");
        for (i=0;i<IsoResponse.usFrameSize[j];i++)
        {
          printf("%02X",ucData[j][i]);
        }
      }
    }
  }
  else
  {
    // failure awaiting isochronous data transfer completion
    UsbCancelTransfer(Handle,ucEndpoint,ucAltSetting,hIsoComplete);
  }

  //release semaphore
  ulrc = DosCloseEventSem(hIsoComplete);
  printf("\nDosCloseEventSem - ulrc: 0x%04X (%hu)",ulrc,ulrc);
}

Related Functions