从散列读结果中读取数据 - DmaScatterRead
函数简介
从散列读结果中读取指定地址的数据。(高级版功能,普通版无法使用)
接口名称
DmaScatterRead
DLL调用
int32_t OLA_CALL_TYPE DmaScatterRead(int64_t instance, int64_t scatterHandle, int64_t address, int64_t buffer, int32_t size);
参数定义:
instance(长整型数): OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。scatterHandle(长整型数): 散列句柄,由 DmaScatterCreate 返回address(长整型数): 要读取的地址buffer(长整型数): 输出缓冲区地址(可为 NULL)size(整型数): 读取大小
示例:
// 创建散列读句柄
int64_t scatterHandle = DmaScatterCreate(instance, deviceId, 1234);
// 准备地址
DmaScatterPrepare(instance, scatterHandle, 0x400000, 4);
DmaScatterPrepare(instance, scatterHandle, 0x400010, 4);
// 执行散列读
DmaScatterExecute(instance, scatterHandle);
// 读取数据
int32_t bytesRead1 = DmaScatterRead(instance, scatterHandle, 0x400000, NULL, 4);
int32_t bytesRead2 = DmaScatterRead(instance, scatterHandle, 0x400010, NULL, 4);
printf("读取字节数1: %d\n", bytesRead1);
printf("读取字节数2: %d\n", bytesRead2);
// 关闭句柄
DmaScatterClose(instance, scatterHandle);
返回值
整型数:
- 成功: 返回实际读取的字节数
- 失败: 返回 0
参数说明
address(地址):
- 必须是之前通过 DmaScatterPrepare 准备过的地址
- 如果地址未准备,返回 0
buffer(缓冲区):
- 可为 NULL,表示不需要输出缓冲区
- 如果提供,数据将写入该地址
size(大小):
- 要读取的字节数
- 必须与 DmaScatterPrepare 中指定的大小一致
应用场景
- 从散列读结果中提取数据
- 批量读取多个地址的数据
- 高效内存访问
相关接口
- DmaScatterCreate - 创建散列读句柄
- DmaScatterExecute - 执行散列读
- DmaScatterClear - 清除散列读准备的数据
