385 lines
10 KiB
C++
385 lines
10 KiB
C++
|
|
/*
|
||
|
|
* Generated by erpcgen 1.14.0 on Wed Jan 14 16:06:40 2026.
|
||
|
|
*
|
||
|
|
* AUTOGENERATED - DO NOT EDIT
|
||
|
|
*/
|
||
|
|
|
||
|
|
|
||
|
|
#include "face_servo_server.hpp"
|
||
|
|
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
|
||
|
|
#include <new>
|
||
|
|
#include "erpc_port.h"
|
||
|
|
#endif
|
||
|
|
#include "erpc_manually_constructed.hpp"
|
||
|
|
|
||
|
|
#if 11400 != ERPC_VERSION_NUMBER
|
||
|
|
#error "The generated shim code version is different to the rest of eRPC code."
|
||
|
|
#endif
|
||
|
|
|
||
|
|
using namespace erpc;
|
||
|
|
using namespace std;
|
||
|
|
using namespace erpcShim;
|
||
|
|
|
||
|
|
#if ERPC_NESTED_CALLS_DETECTION
|
||
|
|
extern bool nestingDetection;
|
||
|
|
#endif
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// Constant variable definitions
|
||
|
|
#if defined(__MINGW32__)
|
||
|
|
__declspec( selectany )
|
||
|
|
#else
|
||
|
|
#pragma weak kServoIdMaxLen
|
||
|
|
#endif
|
||
|
|
extern const int32_t kServoIdMaxLen = 32;
|
||
|
|
#if defined(__MINGW32__)
|
||
|
|
__declspec( selectany )
|
||
|
|
#else
|
||
|
|
#pragma weak kMaxServoCount
|
||
|
|
#endif
|
||
|
|
extern const int32_t kMaxServoCount = 48;
|
||
|
|
|
||
|
|
//! @brief Function to read struct list_float_1_t
|
||
|
|
static void read_list_float_1_t_struct(erpc::Codec * codec, list_float_1_t * data);
|
||
|
|
|
||
|
|
//! @brief Function to read struct ServoCmd
|
||
|
|
static void read_ServoCmd_struct(erpc::Codec * codec, ServoCmd * data);
|
||
|
|
|
||
|
|
//! @brief Function to read struct list_ServoCmd_1_t
|
||
|
|
static void read_list_ServoCmd_1_t_struct(erpc::Codec * codec, list_ServoCmd_1_t * data);
|
||
|
|
|
||
|
|
|
||
|
|
// Read struct list_float_1_t function implementation
|
||
|
|
static void read_list_float_1_t_struct(erpc::Codec * codec, list_float_1_t * data)
|
||
|
|
{
|
||
|
|
if(NULL == data)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
codec->startReadList(data->elementsCount);
|
||
|
|
data->elements = (float *) erpc_malloc(data->elementsCount * sizeof(float));
|
||
|
|
if ((data->elements == NULL) && (data->elementsCount > 0))
|
||
|
|
{
|
||
|
|
codec->updateStatus(kErpcStatus_MemoryError);
|
||
|
|
}
|
||
|
|
for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
|
||
|
|
{
|
||
|
|
codec->read(data->elements[listCount]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Read struct ServoCmd function implementation
|
||
|
|
static void read_ServoCmd_struct(erpc::Codec * codec, ServoCmd * data)
|
||
|
|
{
|
||
|
|
if(NULL == data)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
{
|
||
|
|
uint32_t id_len;
|
||
|
|
char * id_local;
|
||
|
|
codec->readString(id_len, &id_local);
|
||
|
|
data->id = (char*) erpc_malloc((id_len + 1) * sizeof(char));
|
||
|
|
if ((data->id == NULL) || (id_local == NULL))
|
||
|
|
{
|
||
|
|
codec->updateStatus(kErpcStatus_MemoryError);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
memcpy(data->id, id_local, id_len);
|
||
|
|
(data->id)[id_len] = 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
codec->read(data->angle_deg);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Read struct list_ServoCmd_1_t function implementation
|
||
|
|
static void read_list_ServoCmd_1_t_struct(erpc::Codec * codec, list_ServoCmd_1_t * data)
|
||
|
|
{
|
||
|
|
if(NULL == data)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
codec->startReadList(data->elementsCount);
|
||
|
|
data->elements = (ServoCmd *) erpc_malloc(data->elementsCount * sizeof(ServoCmd));
|
||
|
|
if ((data->elements == NULL) && (data->elementsCount > 0))
|
||
|
|
{
|
||
|
|
codec->updateStatus(kErpcStatus_MemoryError);
|
||
|
|
}
|
||
|
|
for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
|
||
|
|
{
|
||
|
|
read_ServoCmd_struct(codec, &(data->elements[listCount]));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
//! @brief Function to free space allocated inside struct list_float_1_t
|
||
|
|
static void free_list_float_1_t_struct(list_float_1_t * data);
|
||
|
|
|
||
|
|
//! @brief Function to free space allocated inside struct ServoCmd
|
||
|
|
static void free_ServoCmd_struct(ServoCmd * data);
|
||
|
|
|
||
|
|
//! @brief Function to free space allocated inside struct list_ServoCmd_1_t
|
||
|
|
static void free_list_ServoCmd_1_t_struct(list_ServoCmd_1_t * data);
|
||
|
|
|
||
|
|
|
||
|
|
// Free space allocated inside struct list_float_1_t function implementation
|
||
|
|
static void free_list_float_1_t_struct(list_float_1_t * data)
|
||
|
|
{
|
||
|
|
erpc_free(data->elements);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Free space allocated inside struct ServoCmd function implementation
|
||
|
|
static void free_ServoCmd_struct(ServoCmd * data)
|
||
|
|
{
|
||
|
|
erpc_free(data->id);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Free space allocated inside struct list_ServoCmd_1_t function implementation
|
||
|
|
static void free_list_ServoCmd_1_t_struct(list_ServoCmd_1_t * data)
|
||
|
|
{
|
||
|
|
for (uint32_t listCount = 0; listCount < data->elementsCount; ++listCount)
|
||
|
|
{
|
||
|
|
free_ServoCmd_struct(&data->elements[listCount]);
|
||
|
|
}
|
||
|
|
|
||
|
|
erpc_free(data->elements);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
FaceServo_service::FaceServo_service(FaceServo_interface *_FaceServo_interface)
|
||
|
|
: erpc::Service(FaceServo_interface::m_serviceId)
|
||
|
|
, m_handler(_FaceServo_interface)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
FaceServo_service::~FaceServo_service()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
// return service interface handler.
|
||
|
|
FaceServo_interface* FaceServo_service::getHandler(void)
|
||
|
|
{
|
||
|
|
return m_handler;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Call the correct server shim based on method unique ID.
|
||
|
|
erpc_status_t FaceServo_service::handleInvocation(uint32_t methodId, uint32_t sequence, Codec * codec, MessageBufferFactory *messageFactory, Transport * transport)
|
||
|
|
{
|
||
|
|
erpc_status_t erpcStatus;
|
||
|
|
switch (methodId)
|
||
|
|
{
|
||
|
|
case FaceServo_interface::m_setAllAnglesId:
|
||
|
|
{
|
||
|
|
erpcStatus = setAllAngles_shim(codec, messageFactory, transport, sequence);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
case FaceServo_interface::m_setAnglesId:
|
||
|
|
{
|
||
|
|
erpcStatus = setAngles_shim(codec, messageFactory, transport, sequence);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
case FaceServo_interface::m_setAngleId:
|
||
|
|
{
|
||
|
|
erpcStatus = setAngle_shim(codec, messageFactory, transport, sequence);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
default:
|
||
|
|
{
|
||
|
|
erpcStatus = kErpcStatus_InvalidArgument;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return erpcStatus;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Server shim for setAllAngles of FaceServo interface.
|
||
|
|
erpc_status_t FaceServo_service::setAllAngles_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
|
||
|
|
{
|
||
|
|
erpc_status_t err = kErpcStatus_Success;
|
||
|
|
|
||
|
|
list_float_1_t *angles_deg = NULL;
|
||
|
|
angles_deg = (list_float_1_t *) erpc_malloc(sizeof(list_float_1_t));
|
||
|
|
if (angles_deg == NULL)
|
||
|
|
{
|
||
|
|
codec->updateStatus(kErpcStatus_MemoryError);
|
||
|
|
}
|
||
|
|
int32_t result;
|
||
|
|
|
||
|
|
// startReadMessage() was already called before this shim was invoked.
|
||
|
|
|
||
|
|
read_list_float_1_t_struct(codec, angles_deg);
|
||
|
|
|
||
|
|
err = codec->getStatus();
|
||
|
|
if (err == kErpcStatus_Success)
|
||
|
|
{
|
||
|
|
// Invoke the actual served function.
|
||
|
|
#if ERPC_NESTED_CALLS_DETECTION
|
||
|
|
nestingDetection = true;
|
||
|
|
#endif
|
||
|
|
result = m_handler->setAllAngles(angles_deg);
|
||
|
|
#if ERPC_NESTED_CALLS_DETECTION
|
||
|
|
nestingDetection = false;
|
||
|
|
#endif
|
||
|
|
|
||
|
|
// preparing MessageBuffer for serializing data
|
||
|
|
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
|
||
|
|
}
|
||
|
|
|
||
|
|
if (err == kErpcStatus_Success)
|
||
|
|
{
|
||
|
|
// preparing codec for serializing data
|
||
|
|
codec->reset(transport->reserveHeaderSize());
|
||
|
|
|
||
|
|
// Build response message.
|
||
|
|
codec->startWriteMessage(message_type_t::kReplyMessage, FaceServo_interface::m_serviceId, FaceServo_interface::m_setAllAnglesId, sequence);
|
||
|
|
|
||
|
|
codec->write(result);
|
||
|
|
|
||
|
|
err = codec->getStatus();
|
||
|
|
}
|
||
|
|
|
||
|
|
if (angles_deg)
|
||
|
|
{
|
||
|
|
free_list_float_1_t_struct(angles_deg);
|
||
|
|
}
|
||
|
|
erpc_free(angles_deg);
|
||
|
|
|
||
|
|
return err;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Server shim for setAngles of FaceServo interface.
|
||
|
|
erpc_status_t FaceServo_service::setAngles_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
|
||
|
|
{
|
||
|
|
erpc_status_t err = kErpcStatus_Success;
|
||
|
|
|
||
|
|
list_ServoCmd_1_t *cmds = NULL;
|
||
|
|
cmds = (list_ServoCmd_1_t *) erpc_malloc(sizeof(list_ServoCmd_1_t));
|
||
|
|
if (cmds == NULL)
|
||
|
|
{
|
||
|
|
codec->updateStatus(kErpcStatus_MemoryError);
|
||
|
|
}
|
||
|
|
int32_t result;
|
||
|
|
|
||
|
|
// startReadMessage() was already called before this shim was invoked.
|
||
|
|
|
||
|
|
read_list_ServoCmd_1_t_struct(codec, cmds);
|
||
|
|
|
||
|
|
err = codec->getStatus();
|
||
|
|
if (err == kErpcStatus_Success)
|
||
|
|
{
|
||
|
|
// Invoke the actual served function.
|
||
|
|
#if ERPC_NESTED_CALLS_DETECTION
|
||
|
|
nestingDetection = true;
|
||
|
|
#endif
|
||
|
|
result = m_handler->setAngles(cmds);
|
||
|
|
#if ERPC_NESTED_CALLS_DETECTION
|
||
|
|
nestingDetection = false;
|
||
|
|
#endif
|
||
|
|
|
||
|
|
// preparing MessageBuffer for serializing data
|
||
|
|
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
|
||
|
|
}
|
||
|
|
|
||
|
|
if (err == kErpcStatus_Success)
|
||
|
|
{
|
||
|
|
// preparing codec for serializing data
|
||
|
|
codec->reset(transport->reserveHeaderSize());
|
||
|
|
|
||
|
|
// Build response message.
|
||
|
|
codec->startWriteMessage(message_type_t::kReplyMessage, FaceServo_interface::m_serviceId, FaceServo_interface::m_setAnglesId, sequence);
|
||
|
|
|
||
|
|
codec->write(result);
|
||
|
|
|
||
|
|
err = codec->getStatus();
|
||
|
|
}
|
||
|
|
|
||
|
|
if (cmds)
|
||
|
|
{
|
||
|
|
free_list_ServoCmd_1_t_struct(cmds);
|
||
|
|
}
|
||
|
|
erpc_free(cmds);
|
||
|
|
|
||
|
|
return err;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Server shim for setAngle of FaceServo interface.
|
||
|
|
erpc_status_t FaceServo_service::setAngle_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
|
||
|
|
{
|
||
|
|
erpc_status_t err = kErpcStatus_Success;
|
||
|
|
|
||
|
|
char * id = NULL;
|
||
|
|
float angle_deg;
|
||
|
|
int32_t result;
|
||
|
|
|
||
|
|
// startReadMessage() was already called before this shim was invoked.
|
||
|
|
|
||
|
|
{
|
||
|
|
uint32_t id_len;
|
||
|
|
char * id_local;
|
||
|
|
codec->readString(id_len, &id_local);
|
||
|
|
if ((kServoIdMaxLen >= 0) && (id_len <= static_cast<uint32_t>(kServoIdMaxLen)))
|
||
|
|
{
|
||
|
|
id = (char*) erpc_malloc((kServoIdMaxLen + 1) * sizeof(char));
|
||
|
|
if ((id == NULL) || (id_local == NULL))
|
||
|
|
{
|
||
|
|
codec->updateStatus(kErpcStatus_MemoryError);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
memcpy(id, id_local, id_len);
|
||
|
|
(id)[id_len] = 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
codec->updateStatus(kErpcStatus_InvalidArgument);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
codec->read(angle_deg);
|
||
|
|
|
||
|
|
err = codec->getStatus();
|
||
|
|
if (err == kErpcStatus_Success)
|
||
|
|
{
|
||
|
|
// Invoke the actual served function.
|
||
|
|
#if ERPC_NESTED_CALLS_DETECTION
|
||
|
|
nestingDetection = true;
|
||
|
|
#endif
|
||
|
|
result = m_handler->setAngle(id, angle_deg);
|
||
|
|
#if ERPC_NESTED_CALLS_DETECTION
|
||
|
|
nestingDetection = false;
|
||
|
|
#endif
|
||
|
|
|
||
|
|
// preparing MessageBuffer for serializing data
|
||
|
|
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
|
||
|
|
}
|
||
|
|
|
||
|
|
if (err == kErpcStatus_Success)
|
||
|
|
{
|
||
|
|
// preparing codec for serializing data
|
||
|
|
codec->reset(transport->reserveHeaderSize());
|
||
|
|
|
||
|
|
// Build response message.
|
||
|
|
codec->startWriteMessage(message_type_t::kReplyMessage, FaceServo_interface::m_serviceId, FaceServo_interface::m_setAngleId, sequence);
|
||
|
|
|
||
|
|
codec->write(result);
|
||
|
|
|
||
|
|
err = codec->getStatus();
|
||
|
|
}
|
||
|
|
|
||
|
|
erpc_free(id);
|
||
|
|
|
||
|
|
return err;
|
||
|
|
}
|