---
title: RecvData
description: "接收服务端传输的数据。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/230RC2/armnative/kunpengcpsinstruction_17_0008.html
sourcePath: /source/zh/kunpengboostkithistory/230RC2/armnative/kunpengcpsinstruction_17_0008.html
indexId: 135da1708dd991834f32006352e477fbec1eb64427d9a10f59b7fdffeefe17c585
---
# RecvData

#### 函数功能

接收服务端传输的数据。


#### 约束说明

NA


#### 函数原型

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


#### 参数说明

| 参数名称 | 输入/输出 | 参数类型 | 参数描述 |
| --- | --- | --- | --- |
| type | 输入 | VMIMsgType | 参考指令流数据类型定义。 |
| data | 输出 | uint8\_t\* | 代表接收type类型数据buffer。 |
| length | 输入 | uint32\_t | 代表接收type类型数据buffer的长度。 |


#### 返回值说明

- 大于0：表示接收到type型数据的长度。
- VMI_CLIENT_RECV_ORDER_FAIL：表示接收函数执行顺序非法。
- VMI_CLIENT_RECV_MEMCPY_FAILED：表示接收函数内存拷贝失败。
- VMI_CLIENT_RECV_LENGTH_NO_MATCH：表示传入的length小于实际接收到数据长度。
- VMI_CLIENT_RECV_DATA_NULL：表示接收到的数据为空，当前无数据。
- VMI_CLIENT_RECV_INVALID_PAPAM：表示该函数传入的参数非法。


#### 调用示例

```
private InstructionEngine engine = new InstructionEngine();
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;
}
}
}
```
