Updated on 2022-03-13 GMT+08:00

Macro: HIAI_REGISTER_SERIALIZE_FUNC

Provides user-defined serialization and deserialization mechanisms for user-defined data types. This macro is defined in data_type_reg.h.

That is, during data sending, the struct pointers transferred by the user are converted into the struct buffer and data buffer. During data receiving, the struct buffer and data buffer obtained from the framework are converted into the structs.

Application scenario:

This API is used to quickly transfer data from the host side to the device side. If you want to improve the transfer performance, you must call this API.

  • This API is used to quickly transfer data from the host side to the device side.
  • If you want to use a high-performance transfer API, you must call this API to register serialization and deserialization functions.

Syntax

HIAI_REGISTER_SERIALIZE_FUNC(name, type, hiaiSerializeFunc, hiaiDeSerializeFunc)

Parameter Description

Parameter

Description

Value Range

name

Name of a registered message

-

type

Type of a user-defined type

-

hiaiSerializeFunc

Serialization function. The function format is as follows:

typedef void(*hiaiSerializeFunc)(void* inputPtr, std::string& ctrlStr,

uint8_t*& dataPtr, uint32_t& dataLen);

The parameters are described as follows:

  • inputPtr: struct pointer
  • ctrlStr: struct buffer
  • dataPtr: buffer of the struct data pointer
  • dataLen: struct data size

-

hiaiDeSerializeFunc

Deserialization function. The function format is as follows:

typedef std::shared_ptr<void>(*hiaiDeSerializeFunc)(

const char* ctrlPtr, const uint32_t& ctrlLen,

const uint8_t* dataPtr, const uint32_t& dataLen);

The parameters are described as follows:

  • ctrlPtr: struct pointer
  • ctrlLen: control information size in the data structure
  • dataPtr: struct data pointer
  • dataLen: size of the data storage space in the struct. This parameter is used only for verification and does not indicate the size of the original data.

-

Return Value

For details about the returned error codes, see "Error Codes."

Error Codes

No.

Error Code

Description

1

HIAI_OK

The running is OK.

2

HIAI_ENGINE_FUNCTOR_NULL

The HiAI Engine function is null.

3

HIAI_ENGINE_FUNCTOR_EXIST

The HiAI Engine function exists.