1 Star 0 Fork 4

太子0007/erpcdemo

forked from 10km/erpcdemo 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
erpcdemo_client.cpp 5.02 KB
一键复制 编辑 原始数据 按行查看 历史
10km 提交于 2020-04-18 09:43 . add initial source
/* 定义项目名称,也是所有生成的源码文件名前缀 */
/*
* Generated by erpcgen 1.7.3 on Sat Apr 18 09:33:42 2020.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include "erpc_client_manager.h"
#include "erpc_port.h"
#include "erpc_codec.h"
extern "C"
{
#include "erpcdemo.h"
}
#if 10703 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
using namespace erpc;
using namespace std;
extern ClientManager *g_client;
//! @brief Function to write struct binary_t
static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data);
// Write struct binary_t function implementation
static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data)
{
codec->writeBinary(data->dataLength, data->data);
}
//! @brief Function to read struct binary_t
static void read_binary_t_struct(erpc::Codec * codec, binary_t * data);
// Read struct binary_t function implementation
static void read_binary_t_struct(erpc::Codec * codec, binary_t * data)
{
uint8_t * data_local;
codec->readBinary(&data->dataLength, &data_local);
data->data = (uint8_t *) erpc_malloc(data->dataLength * sizeof(uint8_t));
if (data->data == NULL)
{
codec->updateStatus(kErpcStatus_MemoryError);
}
else
{
memcpy(data->data, data_local, data->dataLength);
}
}
// DEMO interface RD_demoHello function client shim.
binary_t * RD_demoHello(const binary_t * txInput)
{
erpc_status_t err = kErpcStatus_Success;
binary_t * result = NULL;
// Get a new request.
RequestContext request = g_client->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(kInvocationMessage, kDEMO_service_id, kDEMO_RD_demoHello_id, request.getSequence());
write_binary_t_struct(codec, txInput);
// Send message to server
// Codec status is checked inside this function.
g_client->performRequest(request);
result = (binary_t *) erpc_malloc(sizeof(binary_t));
if (result == NULL)
{
codec->updateStatus(kErpcStatus_MemoryError);
}
read_binary_t_struct(codec, result);
err = codec->getStatus();
}
// Dispose of the request.
g_client->releaseRequest(request);
// Invoke error handler callback function
g_client->callErrorHandler(err, kDEMO_RD_demoHello_id);
return result;
}
// DEMO interface RD_demoHello2 function client shim.
lockErrors_t RD_demoHello2(const binary_t * txInput, binary_t * txOutput)
{
erpc_status_t err = kErpcStatus_Success;
lockErrors_t result;
// Get a new request.
RequestContext request = g_client->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(kInvocationMessage, kDEMO_service_id, kDEMO_RD_demoHello2_id, request.getSequence());
write_binary_t_struct(codec, txInput);
// Send message to server
// Codec status is checked inside this function.
g_client->performRequest(request);
int32_t _tmp_local;
read_binary_t_struct(codec, txOutput);
codec->read(&_tmp_local);
result = static_cast<lockErrors_t>(_tmp_local);
err = codec->getStatus();
}
// Dispose of the request.
g_client->releaseRequest(request);
// Invoke error handler callback function
g_client->callErrorHandler(err, kDEMO_RD_demoHello2_id);
if (err)
{
return (lockErrors_t) -1;
}
return result;
}
// DEMO interface RD_demoHello3 function client shim.
lockErrors_t RD_demoHello3(const binary_t * txInput, int8_t txOutput[64], int32_t * size)
{
erpc_status_t err = kErpcStatus_Success;
lockErrors_t result;
// Get a new request.
RequestContext request = g_client->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(kInvocationMessage, kDEMO_service_id, kDEMO_RD_demoHello3_id, request.getSequence());
write_binary_t_struct(codec, txInput);
// Send message to server
// Codec status is checked inside this function.
g_client->performRequest(request);
int32_t _tmp_local;
for (uint32_t arrayCount0 = 0; arrayCount0 < 64; ++arrayCount0)
{
codec->read(&txOutput[arrayCount0]);
}
codec->read(size);
codec->read(&_tmp_local);
result = static_cast<lockErrors_t>(_tmp_local);
err = codec->getStatus();
}
// Dispose of the request.
g_client->releaseRequest(request);
// Invoke error handler callback function
g_client->callErrorHandler(err, kDEMO_RD_demoHello3_id);
if (err)
{
return (lockErrors_t) -1;
}
return result;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/TaiZi0007/erpcdemo.git
git@gitee.com:TaiZi0007/erpcdemo.git
TaiZi0007
erpcdemo
erpcdemo
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385