Rate This Document
Findability
Accuracy
Completeness
Readability

RecvData

Function Usage

Receives data.

Restrictions

N/A

Prototype

int32_t RecvData(VMIMsgType type, uint8_t* data, uint32_t length)

Parameters

Parameter

Input/Output

Class

Description

type

Input

VMIMsgType

Type of data to be received. For details, see the definitions of enumerated values of VMIMsgType in VmiEngine.h.

data

Output

uint8_t*

Address of the buffer for receiving the type data.

length

Input

uint32_t

Length of the buffer for receiving the type data.

Returns

  • > 0: The length of the type data is received.
  • VMI_CLIENT_RECV_ORDER_FAIL: The execution order of the data receiving function is invalid.
  • VMI_CLIENT_RECV_MEMCPY_FAILED: The data receiving function fails to copy the memory.
  • VMI_CLIENT_RECV_LENGTH_NO_MATCH: The input length is less than the length of the received data.
  • VMI_CLIENT_RECV_DATA_NULL: The received data is null, and there is no data currently.
  • VMI_CLIENT_RECV_INVALID_PAPAM: The input parameter of the function is invalid.

Example Call

void Test()  
{    
    const int MAX_BUF_LEN =1048576;
    uint8_t *recvBuf = new uint8_t[MAX_BUF_LEN]; 
    while (!stopFlag) { 
        int packetLen = RecvData(VMIMsgType::AUDIO, recvBuf, MAX_BUF_LEN); 
        if (packetLen > 0) { 
            // continue recv data when there is data found 
             …
            continue; 
        } 
     }
}