代码拉取完成,页面将自动刷新
/*
* Generated by erpcgen 1.9.1 on Fri Jul 29 09:33:29 2022.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include "hello_server.h"
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
#include <new>
#include "erpc_port.h"
#endif
#include "erpc_manually_constructed.h"
#if 10901 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
using namespace erpc;
using namespace std;
#if ERPC_NESTED_CALLS_DETECTION
extern bool nestingDetection;
#endif
ERPC_MANUALLY_CONSTRUCTED_STATIC(Hello_service, s_Hello_service);
//! @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)
{
if(NULL == data)
{
return;
}
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) && (data->dataLength > 0))
{
codec->updateStatus(kErpcStatus_MemoryError);
}
else
{
memcpy(data->data, data_local, data->dataLength);
}
}
//! @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)
{
if(NULL == data)
{
return;
}
codec->writeBinary(data->dataLength, data->data);
}
//! @brief Function to free space allocated inside struct binary_t
static void free_binary_t_struct(binary_t * data);
// Free space allocated inside struct binary_t function implementation
static void free_binary_t_struct(binary_t * data)
{
if (data->data)
{
erpc_free(data->data);
}
}
// Call the correct server shim based on method unique ID.
erpc_status_t Hello_service::handleInvocation(uint32_t methodId, uint32_t sequence, Codec * codec, MessageBufferFactory *messageFactory)
{
erpc_status_t erpcStatus;
switch (methodId)
{
case kHello_sayHello_id:
{
erpcStatus = sayHello_shim(codec, messageFactory, sequence);
break;
}
default:
{
erpcStatus = kErpcStatus_InvalidArgument;
break;
}
}
return erpcStatus;
}
// Server shim for sayHello of Hello interface.
erpc_status_t Hello_service::sayHello_shim(Codec * codec, MessageBufferFactory *messageFactory, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
binary_t *txInput = NULL;
txInput = (binary_t *) erpc_malloc(sizeof(binary_t));
if (txInput == NULL)
{
codec->updateStatus(kErpcStatus_MemoryError);
}
binary_t * result = NULL;
// startReadMessage() was already called before this shim was invoked.
read_binary_t_struct(codec, txInput);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = sayHello(txInput);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBuffer());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset();
// Build response message.
codec->startWriteMessage(kReplyMessage, kHello_service_id, kHello_sayHello_id, sequence);
write_binary_t_struct(codec, result);
err = codec->getStatus();
}
if (txInput)
{
free_binary_t_struct(txInput);
}
if (txInput)
{
erpc_free(txInput);
}
if (result)
{
free_binary_t_struct(result);
}
if (result)
{
erpc_free(result);
}
return err;
}
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
erpc_service_t create_Hello_service()
{
return new (nothrow) Hello_service();
}
void destroy_Hello_service(erpc_service_t service)
{
if (service)
{
delete (Hello_service *)service;
}
}
#elif ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC
erpc_service_t create_Hello_service()
{
s_Hello_service.construct();
return s_Hello_service.get();
}
void destroy_Hello_service()
{
s_Hello_service.destroy();
}
#else
#warning "Unknown eRPC allocation policy!"
#endif
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。