C_runtime/service/erpc_PLCObject_server.cpp
changeset 4058 5472b88bbc9d
equal deleted inserted replaced
4057:cf42c3dbdd5c 4058:5472b88bbc9d
       
     1 /*
       
     2  * Generated by erpcgen 1.13.0 on Fri Nov 22 15:03:08 2024.
       
     3  *
       
     4  * AUTOGENERATED - DO NOT EDIT
       
     5  */
       
     6 
       
     7 
       
     8 #include "erpc_PLCObject_server.hpp"
       
     9 #if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
       
    10 #include <new>
       
    11 #include "erpc_port.h"
       
    12 #endif
       
    13 #include "erpc_manually_constructed.hpp"
       
    14 
       
    15 #if 11300 != ERPC_VERSION_NUMBER
       
    16 #error "The generated shim code version is different to the rest of eRPC code."
       
    17 #endif
       
    18 
       
    19 using namespace erpc;
       
    20 using namespace std;
       
    21 using namespace erpcShim;
       
    22 
       
    23 #if ERPC_NESTED_CALLS_DETECTION
       
    24 extern bool nestingDetection;
       
    25 #endif
       
    26 
       
    27 
       
    28 //! @brief Function to read struct binary_t
       
    29 static void read_binary_t_struct(erpc::Codec * codec, binary_t * data);
       
    30 
       
    31 //! @brief Function to read struct extra_file
       
    32 static void read_extra_file_struct(erpc::Codec * codec, extra_file * data);
       
    33 
       
    34 //! @brief Function to read struct list_extra_file_1_t
       
    35 static void read_list_extra_file_1_t_struct(erpc::Codec * codec, list_extra_file_1_t * data);
       
    36 
       
    37 //! @brief Function to read struct trace_order
       
    38 static void read_trace_order_struct(erpc::Codec * codec, trace_order * data);
       
    39 
       
    40 //! @brief Function to read struct list_trace_order_1_t
       
    41 static void read_list_trace_order_1_t_struct(erpc::Codec * codec, list_trace_order_1_t * data);
       
    42 
       
    43 
       
    44 // Read struct binary_t function implementation
       
    45 static void read_binary_t_struct(erpc::Codec * codec, binary_t * data)
       
    46 {
       
    47     if(NULL == data)
       
    48     {
       
    49         return;
       
    50     }
       
    51 
       
    52     uint8_t * data_local;
       
    53     codec->readBinary(data->dataLength, &data_local);
       
    54     if (data->dataLength > 0)
       
    55     {
       
    56     data->data = (uint8_t *) erpc_malloc(data->dataLength * sizeof(uint8_t));
       
    57         if (data->data == NULL)
       
    58         {
       
    59             codec->updateStatus(kErpcStatus_MemoryError);
       
    60         }
       
    61         else
       
    62         {
       
    63             memcpy(data->data, data_local, data->dataLength);
       
    64         }
       
    65     }
       
    66     else
       
    67     {
       
    68         data->data = NULL;
       
    69     }
       
    70 }
       
    71 
       
    72 // Read struct extra_file function implementation
       
    73 static void read_extra_file_struct(erpc::Codec * codec, extra_file * data)
       
    74 {
       
    75     if(NULL == data)
       
    76     {
       
    77         return;
       
    78     }
       
    79 
       
    80     {
       
    81         uint32_t fname_len;
       
    82         char * fname_local;
       
    83         codec->readString(fname_len, &fname_local);
       
    84         data->fname = (char*) erpc_malloc((fname_len + 1) * sizeof(char));
       
    85         if ((data->fname == NULL) || (fname_local == NULL))
       
    86         {
       
    87             codec->updateStatus(kErpcStatus_MemoryError);
       
    88         }
       
    89         else
       
    90         {
       
    91             memcpy(data->fname, fname_local, fname_len);
       
    92             (data->fname)[fname_len] = 0;
       
    93         }
       
    94     }
       
    95 
       
    96     read_binary_t_struct(codec, &(data->blobID));
       
    97 }
       
    98 
       
    99 // Read struct list_extra_file_1_t function implementation
       
   100 static void read_list_extra_file_1_t_struct(erpc::Codec * codec, list_extra_file_1_t * data)
       
   101 {
       
   102     if(NULL == data)
       
   103     {
       
   104         return;
       
   105     }
       
   106 
       
   107     codec->startReadList(data->elementsCount);
       
   108     data->elements = (extra_file *) erpc_malloc(data->elementsCount * sizeof(extra_file));
       
   109     if ((data->elements == NULL) && (data->elementsCount > 0))
       
   110     {
       
   111         codec->updateStatus(kErpcStatus_MemoryError);
       
   112     }
       
   113     for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
       
   114     {
       
   115         read_extra_file_struct(codec, &(data->elements[listCount]));
       
   116     }
       
   117 }
       
   118 
       
   119 // Read struct trace_order function implementation
       
   120 static void read_trace_order_struct(erpc::Codec * codec, trace_order * data)
       
   121 {
       
   122     if(NULL == data)
       
   123     {
       
   124         return;
       
   125     }
       
   126 
       
   127     codec->read(data->idx);
       
   128 
       
   129     read_binary_t_struct(codec, &(data->force));
       
   130 }
       
   131 
       
   132 // Read struct list_trace_order_1_t function implementation
       
   133 static void read_list_trace_order_1_t_struct(erpc::Codec * codec, list_trace_order_1_t * data)
       
   134 {
       
   135     if(NULL == data)
       
   136     {
       
   137         return;
       
   138     }
       
   139 
       
   140     codec->startReadList(data->elementsCount);
       
   141     data->elements = (trace_order *) erpc_malloc(data->elementsCount * sizeof(trace_order));
       
   142     if ((data->elements == NULL) && (data->elementsCount > 0))
       
   143     {
       
   144         codec->updateStatus(kErpcStatus_MemoryError);
       
   145     }
       
   146     for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
       
   147     {
       
   148         read_trace_order_struct(codec, &(data->elements[listCount]));
       
   149     }
       
   150 }
       
   151 
       
   152 
       
   153 //! @brief Function to write struct binary_t
       
   154 static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data);
       
   155 
       
   156 //! @brief Function to write struct log_message
       
   157 static void write_log_message_struct(erpc::Codec * codec, const log_message * data);
       
   158 
       
   159 //! @brief Function to write struct PSKID
       
   160 static void write_PSKID_struct(erpc::Codec * codec, const PSKID * data);
       
   161 
       
   162 //! @brief Function to write struct PLCstatus
       
   163 static void write_PLCstatus_struct(erpc::Codec * codec, const PLCstatus * data);
       
   164 
       
   165 //! @brief Function to write struct trace_sample
       
   166 static void write_trace_sample_struct(erpc::Codec * codec, const trace_sample * data);
       
   167 
       
   168 //! @brief Function to write struct TraceVariables
       
   169 static void write_TraceVariables_struct(erpc::Codec * codec, const TraceVariables * data);
       
   170 
       
   171 //! @brief Function to write struct list_trace_sample_1_t
       
   172 static void write_list_trace_sample_1_t_struct(erpc::Codec * codec, const list_trace_sample_1_t * data);
       
   173 
       
   174 
       
   175 // Write struct binary_t function implementation
       
   176 static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data)
       
   177 {
       
   178     if(NULL == data)
       
   179     {
       
   180         return;
       
   181     }
       
   182 
       
   183     codec->writeBinary(data->dataLength, data->data);
       
   184 }
       
   185 
       
   186 // Write struct log_message function implementation
       
   187 static void write_log_message_struct(erpc::Codec * codec, const log_message * data)
       
   188 {
       
   189     if(NULL == data)
       
   190     {
       
   191         return;
       
   192     }
       
   193 
       
   194     {
       
   195         uint32_t msg_len = strlen((const char*)data->msg);
       
   196 
       
   197         codec->writeString(msg_len, (const char*)data->msg);
       
   198     }
       
   199 
       
   200     codec->write(data->tick);
       
   201 
       
   202     codec->write(data->sec);
       
   203 
       
   204     codec->write(data->nsec);
       
   205 }
       
   206 
       
   207 // Write struct PSKID function implementation
       
   208 static void write_PSKID_struct(erpc::Codec * codec, const PSKID * data)
       
   209 {
       
   210     if(NULL == data)
       
   211     {
       
   212         return;
       
   213     }
       
   214 
       
   215     {
       
   216         uint32_t ID_len = strlen((const char*)data->ID);
       
   217 
       
   218         codec->writeString(ID_len, (const char*)data->ID);
       
   219     }
       
   220 
       
   221     {
       
   222         uint32_t PSK_len = strlen((const char*)data->PSK);
       
   223 
       
   224         codec->writeString(PSK_len, (const char*)data->PSK);
       
   225     }
       
   226 }
       
   227 
       
   228 // Write struct PLCstatus function implementation
       
   229 static void write_PLCstatus_struct(erpc::Codec * codec, const PLCstatus * data)
       
   230 {
       
   231     if(NULL == data)
       
   232     {
       
   233         return;
       
   234     }
       
   235 
       
   236     codec->write(static_cast<int32_t>(data->PLCstatus));
       
   237 
       
   238     for (uint32_t arrayCount0 = 0U; arrayCount0 < 4U; ++arrayCount0)
       
   239     {
       
   240         codec->write(data->logcounts[arrayCount0]);
       
   241     }
       
   242 }
       
   243 
       
   244 // Write struct trace_sample function implementation
       
   245 static void write_trace_sample_struct(erpc::Codec * codec, const trace_sample * data)
       
   246 {
       
   247     if(NULL == data)
       
   248     {
       
   249         return;
       
   250     }
       
   251 
       
   252     codec->write(data->tick);
       
   253 
       
   254     write_binary_t_struct(codec, &(data->TraceBuffer));
       
   255 }
       
   256 
       
   257 // Write struct TraceVariables function implementation
       
   258 static void write_TraceVariables_struct(erpc::Codec * codec, const TraceVariables * data)
       
   259 {
       
   260     if(NULL == data)
       
   261     {
       
   262         return;
       
   263     }
       
   264 
       
   265     codec->write(static_cast<int32_t>(data->PLCstatus));
       
   266 
       
   267     write_list_trace_sample_1_t_struct(codec, &(data->traces));
       
   268 }
       
   269 
       
   270 // Write struct list_trace_sample_1_t function implementation
       
   271 static void write_list_trace_sample_1_t_struct(erpc::Codec * codec, const list_trace_sample_1_t * data)
       
   272 {
       
   273     if(NULL == data)
       
   274     {
       
   275         return;
       
   276     }
       
   277 
       
   278     codec->startWriteList(data->elementsCount);
       
   279     for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
       
   280     {
       
   281         write_trace_sample_struct(codec, &(data->elements[listCount]));
       
   282     }
       
   283 }
       
   284 
       
   285 
       
   286 //! @brief Function to free space allocated inside struct binary_t
       
   287 static void free_binary_t_struct(binary_t * data);
       
   288 
       
   289 //! @brief Function to free space allocated inside struct log_message
       
   290 static void free_log_message_struct(log_message * data);
       
   291 
       
   292 //! @brief Function to free space allocated inside struct PSKID
       
   293 static void free_PSKID_struct(PSKID * data);
       
   294 
       
   295 //! @brief Function to free space allocated inside struct trace_sample
       
   296 static void free_trace_sample_struct(trace_sample * data);
       
   297 
       
   298 //! @brief Function to free space allocated inside struct TraceVariables
       
   299 static void free_TraceVariables_struct(TraceVariables * data);
       
   300 
       
   301 //! @brief Function to free space allocated inside struct list_trace_sample_1_t
       
   302 static void free_list_trace_sample_1_t_struct(list_trace_sample_1_t * data);
       
   303 
       
   304 //! @brief Function to free space allocated inside struct extra_file
       
   305 static void free_extra_file_struct(extra_file * data);
       
   306 
       
   307 //! @brief Function to free space allocated inside struct list_extra_file_1_t
       
   308 static void free_list_extra_file_1_t_struct(list_extra_file_1_t * data);
       
   309 
       
   310 //! @brief Function to free space allocated inside struct trace_order
       
   311 static void free_trace_order_struct(trace_order * data);
       
   312 
       
   313 //! @brief Function to free space allocated inside struct list_trace_order_1_t
       
   314 static void free_list_trace_order_1_t_struct(list_trace_order_1_t * data);
       
   315 
       
   316 
       
   317 // Free space allocated inside struct binary_t function implementation
       
   318 static void free_binary_t_struct(binary_t * data)
       
   319 {
       
   320     erpc_free(data->data);
       
   321 }
       
   322 
       
   323 // Free space allocated inside struct log_message function implementation
       
   324 static void free_log_message_struct(log_message * data)
       
   325 {
       
   326     erpc_free(data->msg);
       
   327 }
       
   328 
       
   329 // Free space allocated inside struct PSKID function implementation
       
   330 static void free_PSKID_struct(PSKID * data)
       
   331 {
       
   332     erpc_free(data->ID);
       
   333 
       
   334     erpc_free(data->PSK);
       
   335 }
       
   336 
       
   337 // Free space allocated inside struct trace_sample function implementation
       
   338 static void free_trace_sample_struct(trace_sample * data)
       
   339 {
       
   340     free_binary_t_struct(&data->TraceBuffer);
       
   341 }
       
   342 
       
   343 // Free space allocated inside struct TraceVariables function implementation
       
   344 static void free_TraceVariables_struct(TraceVariables * data)
       
   345 {
       
   346     free_list_trace_sample_1_t_struct(&data->traces);
       
   347 }
       
   348 
       
   349 // Free space allocated inside struct list_trace_sample_1_t function implementation
       
   350 static void free_list_trace_sample_1_t_struct(list_trace_sample_1_t * data)
       
   351 {
       
   352     for (uint32_t listCount = 0; listCount < data->elementsCount; ++listCount)
       
   353     {
       
   354         free_trace_sample_struct(&data->elements[listCount]);
       
   355     }
       
   356 
       
   357     erpc_free(data->elements);
       
   358 }
       
   359 
       
   360 // Free space allocated inside struct extra_file function implementation
       
   361 static void free_extra_file_struct(extra_file * data)
       
   362 {
       
   363     erpc_free(data->fname);
       
   364 
       
   365     free_binary_t_struct(&data->blobID);
       
   366 }
       
   367 
       
   368 // Free space allocated inside struct list_extra_file_1_t function implementation
       
   369 static void free_list_extra_file_1_t_struct(list_extra_file_1_t * data)
       
   370 {
       
   371     for (uint32_t listCount = 0; listCount < data->elementsCount; ++listCount)
       
   372     {
       
   373         free_extra_file_struct(&data->elements[listCount]);
       
   374     }
       
   375 
       
   376     erpc_free(data->elements);
       
   377 }
       
   378 
       
   379 // Free space allocated inside struct trace_order function implementation
       
   380 static void free_trace_order_struct(trace_order * data)
       
   381 {
       
   382     free_binary_t_struct(&data->force);
       
   383 }
       
   384 
       
   385 // Free space allocated inside struct list_trace_order_1_t function implementation
       
   386 static void free_list_trace_order_1_t_struct(list_trace_order_1_t * data)
       
   387 {
       
   388     for (uint32_t listCount = 0; listCount < data->elementsCount; ++listCount)
       
   389     {
       
   390         free_trace_order_struct(&data->elements[listCount]);
       
   391     }
       
   392 
       
   393     erpc_free(data->elements);
       
   394 }
       
   395 
       
   396 
       
   397 
       
   398 BeremizPLCObjectService_service::BeremizPLCObjectService_service(BeremizPLCObjectService_interface *_BeremizPLCObjectService_interface)
       
   399     : erpc::Service(BeremizPLCObjectService_interface::m_serviceId)
       
   400     , m_handler(_BeremizPLCObjectService_interface)
       
   401 {
       
   402 }
       
   403 
       
   404 BeremizPLCObjectService_service::~BeremizPLCObjectService_service()
       
   405 {
       
   406 }
       
   407 
       
   408 // return service interface handler.
       
   409 BeremizPLCObjectService_interface* BeremizPLCObjectService_service::getHandler(void)
       
   410 {
       
   411     return m_handler;
       
   412 }
       
   413 
       
   414 // Call the correct server shim based on method unique ID.
       
   415 erpc_status_t BeremizPLCObjectService_service::handleInvocation(uint32_t methodId, uint32_t sequence, Codec * codec, MessageBufferFactory *messageFactory, Transport * transport)
       
   416 {
       
   417     erpc_status_t erpcStatus;
       
   418     switch (methodId)
       
   419     {
       
   420         case BeremizPLCObjectService_interface::m_AppendChunkToBlobId:
       
   421         {
       
   422             erpcStatus = AppendChunkToBlob_shim(codec, messageFactory, transport, sequence);
       
   423             break;
       
   424         }
       
   425 
       
   426         case BeremizPLCObjectService_interface::m_GetLogMessageId:
       
   427         {
       
   428             erpcStatus = GetLogMessage_shim(codec, messageFactory, transport, sequence);
       
   429             break;
       
   430         }
       
   431 
       
   432         case BeremizPLCObjectService_interface::m_GetPLCIDId:
       
   433         {
       
   434             erpcStatus = GetPLCID_shim(codec, messageFactory, transport, sequence);
       
   435             break;
       
   436         }
       
   437 
       
   438         case BeremizPLCObjectService_interface::m_GetPLCstatusId:
       
   439         {
       
   440             erpcStatus = GetPLCstatus_shim(codec, messageFactory, transport, sequence);
       
   441             break;
       
   442         }
       
   443 
       
   444         case BeremizPLCObjectService_interface::m_GetTraceVariablesId:
       
   445         {
       
   446             erpcStatus = GetTraceVariables_shim(codec, messageFactory, transport, sequence);
       
   447             break;
       
   448         }
       
   449 
       
   450         case BeremizPLCObjectService_interface::m_MatchMD5Id:
       
   451         {
       
   452             erpcStatus = MatchMD5_shim(codec, messageFactory, transport, sequence);
       
   453             break;
       
   454         }
       
   455 
       
   456         case BeremizPLCObjectService_interface::m_NewPLCId:
       
   457         {
       
   458             erpcStatus = NewPLC_shim(codec, messageFactory, transport, sequence);
       
   459             break;
       
   460         }
       
   461 
       
   462         case BeremizPLCObjectService_interface::m_PurgeBlobsId:
       
   463         {
       
   464             erpcStatus = PurgeBlobs_shim(codec, messageFactory, transport, sequence);
       
   465             break;
       
   466         }
       
   467 
       
   468         case BeremizPLCObjectService_interface::m_RepairPLCId:
       
   469         {
       
   470             erpcStatus = RepairPLC_shim(codec, messageFactory, transport, sequence);
       
   471             break;
       
   472         }
       
   473 
       
   474         case BeremizPLCObjectService_interface::m_ResetLogCountId:
       
   475         {
       
   476             erpcStatus = ResetLogCount_shim(codec, messageFactory, transport, sequence);
       
   477             break;
       
   478         }
       
   479 
       
   480         case BeremizPLCObjectService_interface::m_SeedBlobId:
       
   481         {
       
   482             erpcStatus = SeedBlob_shim(codec, messageFactory, transport, sequence);
       
   483             break;
       
   484         }
       
   485 
       
   486         case BeremizPLCObjectService_interface::m_SetTraceVariablesListId:
       
   487         {
       
   488             erpcStatus = SetTraceVariablesList_shim(codec, messageFactory, transport, sequence);
       
   489             break;
       
   490         }
       
   491 
       
   492         case BeremizPLCObjectService_interface::m_StartPLCId:
       
   493         {
       
   494             erpcStatus = StartPLC_shim(codec, messageFactory, transport, sequence);
       
   495             break;
       
   496         }
       
   497 
       
   498         case BeremizPLCObjectService_interface::m_StopPLCId:
       
   499         {
       
   500             erpcStatus = StopPLC_shim(codec, messageFactory, transport, sequence);
       
   501             break;
       
   502         }
       
   503 
       
   504         case BeremizPLCObjectService_interface::m_ExtendedCallId:
       
   505         {
       
   506             erpcStatus = ExtendedCall_shim(codec, messageFactory, transport, sequence);
       
   507             break;
       
   508         }
       
   509 
       
   510         default:
       
   511         {
       
   512             erpcStatus = kErpcStatus_InvalidArgument;
       
   513             break;
       
   514         }
       
   515     }
       
   516 
       
   517     return erpcStatus;
       
   518 }
       
   519 
       
   520 // Server shim for AppendChunkToBlob of BeremizPLCObjectService interface.
       
   521 erpc_status_t BeremizPLCObjectService_service::AppendChunkToBlob_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
   522 {
       
   523     erpc_status_t err = kErpcStatus_Success;
       
   524 
       
   525     binary_t *data = NULL;
       
   526     data = (binary_t *) erpc_malloc(sizeof(binary_t));
       
   527     if (data == NULL)
       
   528     {
       
   529         codec->updateStatus(kErpcStatus_MemoryError);
       
   530     }
       
   531     binary_t *blobID = NULL;
       
   532     blobID = (binary_t *) erpc_malloc(sizeof(binary_t));
       
   533     if (blobID == NULL)
       
   534     {
       
   535         codec->updateStatus(kErpcStatus_MemoryError);
       
   536     }
       
   537     binary_t *newBlobID = NULL;
       
   538     uint32_t result;
       
   539 
       
   540     // startReadMessage() was already called before this shim was invoked.
       
   541 
       
   542     read_binary_t_struct(codec, data);
       
   543 
       
   544     read_binary_t_struct(codec, blobID);
       
   545 
       
   546     newBlobID = (binary_t *) erpc_malloc(sizeof(binary_t));
       
   547     if (newBlobID == NULL)
       
   548     {
       
   549         codec->updateStatus(kErpcStatus_MemoryError);
       
   550     }
       
   551 
       
   552     err = codec->getStatus();
       
   553     if (err == kErpcStatus_Success)
       
   554     {
       
   555         // Invoke the actual served function.
       
   556 #if ERPC_NESTED_CALLS_DETECTION
       
   557         nestingDetection = true;
       
   558 #endif
       
   559         result = m_handler->AppendChunkToBlob(data, blobID, newBlobID);
       
   560 #if ERPC_NESTED_CALLS_DETECTION
       
   561         nestingDetection = false;
       
   562 #endif
       
   563 
       
   564         // preparing MessageBuffer for serializing data
       
   565         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
   566     }
       
   567 
       
   568     if (err == kErpcStatus_Success)
       
   569     {
       
   570         // preparing codec for serializing data
       
   571         codec->reset(transport->reserveHeaderSize());
       
   572 
       
   573         // Build response message.
       
   574         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_AppendChunkToBlobId, sequence);
       
   575 
       
   576         write_binary_t_struct(codec, newBlobID);
       
   577 
       
   578         codec->write(result);
       
   579 
       
   580         err = codec->getStatus();
       
   581     }
       
   582 
       
   583     if (data)
       
   584     {
       
   585         free_binary_t_struct(data);
       
   586     }
       
   587     erpc_free(data);
       
   588 
       
   589     if (blobID)
       
   590     {
       
   591         free_binary_t_struct(blobID);
       
   592     }
       
   593     erpc_free(blobID);
       
   594 
       
   595     if (newBlobID)
       
   596     {
       
   597         free_binary_t_struct(newBlobID);
       
   598     }
       
   599     erpc_free(newBlobID);
       
   600 
       
   601     return err;
       
   602 }
       
   603 
       
   604 // Server shim for GetLogMessage of BeremizPLCObjectService interface.
       
   605 erpc_status_t BeremizPLCObjectService_service::GetLogMessage_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
   606 {
       
   607     erpc_status_t err = kErpcStatus_Success;
       
   608 
       
   609     uint8_t level;
       
   610     uint32_t msgID;
       
   611     log_message *message = NULL;
       
   612     uint32_t result;
       
   613 
       
   614     // startReadMessage() was already called before this shim was invoked.
       
   615 
       
   616     codec->read(level);
       
   617 
       
   618     codec->read(msgID);
       
   619 
       
   620     message = (log_message *) erpc_malloc(sizeof(log_message));
       
   621     if (message == NULL)
       
   622     {
       
   623         codec->updateStatus(kErpcStatus_MemoryError);
       
   624     }
       
   625 
       
   626     err = codec->getStatus();
       
   627     if (err == kErpcStatus_Success)
       
   628     {
       
   629         // Invoke the actual served function.
       
   630 #if ERPC_NESTED_CALLS_DETECTION
       
   631         nestingDetection = true;
       
   632 #endif
       
   633         result = m_handler->GetLogMessage(level, msgID, message);
       
   634 #if ERPC_NESTED_CALLS_DETECTION
       
   635         nestingDetection = false;
       
   636 #endif
       
   637 
       
   638         // preparing MessageBuffer for serializing data
       
   639         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
   640     }
       
   641 
       
   642     if (err == kErpcStatus_Success)
       
   643     {
       
   644         // preparing codec for serializing data
       
   645         codec->reset(transport->reserveHeaderSize());
       
   646 
       
   647         // Build response message.
       
   648         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_GetLogMessageId, sequence);
       
   649 
       
   650         write_log_message_struct(codec, message);
       
   651 
       
   652         codec->write(result);
       
   653 
       
   654         err = codec->getStatus();
       
   655     }
       
   656 
       
   657     if (message)
       
   658     {
       
   659         free_log_message_struct(message);
       
   660     }
       
   661     erpc_free(message);
       
   662 
       
   663     return err;
       
   664 }
       
   665 
       
   666 // Server shim for GetPLCID of BeremizPLCObjectService interface.
       
   667 erpc_status_t BeremizPLCObjectService_service::GetPLCID_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
   668 {
       
   669     erpc_status_t err = kErpcStatus_Success;
       
   670 
       
   671     PSKID *plcID = NULL;
       
   672     uint32_t result;
       
   673 
       
   674     // startReadMessage() was already called before this shim was invoked.
       
   675 
       
   676     plcID = (PSKID *) erpc_malloc(sizeof(PSKID));
       
   677     if (plcID == NULL)
       
   678     {
       
   679         codec->updateStatus(kErpcStatus_MemoryError);
       
   680     }
       
   681 
       
   682     err = codec->getStatus();
       
   683     if (err == kErpcStatus_Success)
       
   684     {
       
   685         // Invoke the actual served function.
       
   686 #if ERPC_NESTED_CALLS_DETECTION
       
   687         nestingDetection = true;
       
   688 #endif
       
   689         result = m_handler->GetPLCID(plcID);
       
   690 #if ERPC_NESTED_CALLS_DETECTION
       
   691         nestingDetection = false;
       
   692 #endif
       
   693 
       
   694         // preparing MessageBuffer for serializing data
       
   695         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
   696     }
       
   697 
       
   698     if (err == kErpcStatus_Success)
       
   699     {
       
   700         // preparing codec for serializing data
       
   701         codec->reset(transport->reserveHeaderSize());
       
   702 
       
   703         // Build response message.
       
   704         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_GetPLCIDId, sequence);
       
   705 
       
   706         write_PSKID_struct(codec, plcID);
       
   707 
       
   708         codec->write(result);
       
   709 
       
   710         err = codec->getStatus();
       
   711     }
       
   712 
       
   713     if (plcID)
       
   714     {
       
   715         free_PSKID_struct(plcID);
       
   716     }
       
   717     erpc_free(plcID);
       
   718 
       
   719     return err;
       
   720 }
       
   721 
       
   722 // Server shim for GetPLCstatus of BeremizPLCObjectService interface.
       
   723 erpc_status_t BeremizPLCObjectService_service::GetPLCstatus_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
   724 {
       
   725     erpc_status_t err = kErpcStatus_Success;
       
   726 
       
   727     PLCstatus *status = NULL;
       
   728     uint32_t result;
       
   729 
       
   730     // startReadMessage() was already called before this shim was invoked.
       
   731 
       
   732     status = (PLCstatus *) erpc_malloc(sizeof(PLCstatus));
       
   733     if (status == NULL)
       
   734     {
       
   735         codec->updateStatus(kErpcStatus_MemoryError);
       
   736     }
       
   737 
       
   738     err = codec->getStatus();
       
   739     if (err == kErpcStatus_Success)
       
   740     {
       
   741         // Invoke the actual served function.
       
   742 #if ERPC_NESTED_CALLS_DETECTION
       
   743         nestingDetection = true;
       
   744 #endif
       
   745         result = m_handler->GetPLCstatus(status);
       
   746 #if ERPC_NESTED_CALLS_DETECTION
       
   747         nestingDetection = false;
       
   748 #endif
       
   749 
       
   750         // preparing MessageBuffer for serializing data
       
   751         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
   752     }
       
   753 
       
   754     if (err == kErpcStatus_Success)
       
   755     {
       
   756         // preparing codec for serializing data
       
   757         codec->reset(transport->reserveHeaderSize());
       
   758 
       
   759         // Build response message.
       
   760         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_GetPLCstatusId, sequence);
       
   761 
       
   762         write_PLCstatus_struct(codec, status);
       
   763 
       
   764         codec->write(result);
       
   765 
       
   766         err = codec->getStatus();
       
   767     }
       
   768 
       
   769     erpc_free(status);
       
   770 
       
   771     return err;
       
   772 }
       
   773 
       
   774 // Server shim for GetTraceVariables of BeremizPLCObjectService interface.
       
   775 erpc_status_t BeremizPLCObjectService_service::GetTraceVariables_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
   776 {
       
   777     erpc_status_t err = kErpcStatus_Success;
       
   778 
       
   779     uint32_t debugToken;
       
   780     TraceVariables *traces = NULL;
       
   781     uint32_t result;
       
   782 
       
   783     // startReadMessage() was already called before this shim was invoked.
       
   784 
       
   785     codec->read(debugToken);
       
   786 
       
   787     traces = (TraceVariables *) erpc_malloc(sizeof(TraceVariables));
       
   788     if (traces == NULL)
       
   789     {
       
   790         codec->updateStatus(kErpcStatus_MemoryError);
       
   791     }
       
   792 
       
   793     err = codec->getStatus();
       
   794     if (err == kErpcStatus_Success)
       
   795     {
       
   796         // Invoke the actual served function.
       
   797 #if ERPC_NESTED_CALLS_DETECTION
       
   798         nestingDetection = true;
       
   799 #endif
       
   800         result = m_handler->GetTraceVariables(debugToken, traces);
       
   801 #if ERPC_NESTED_CALLS_DETECTION
       
   802         nestingDetection = false;
       
   803 #endif
       
   804 
       
   805         // preparing MessageBuffer for serializing data
       
   806         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
   807     }
       
   808 
       
   809     if (err == kErpcStatus_Success)
       
   810     {
       
   811         // preparing codec for serializing data
       
   812         codec->reset(transport->reserveHeaderSize());
       
   813 
       
   814         // Build response message.
       
   815         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_GetTraceVariablesId, sequence);
       
   816 
       
   817         write_TraceVariables_struct(codec, traces);
       
   818 
       
   819         codec->write(result);
       
   820 
       
   821         err = codec->getStatus();
       
   822     }
       
   823 
       
   824     if (traces)
       
   825     {
       
   826         free_TraceVariables_struct(traces);
       
   827     }
       
   828     erpc_free(traces);
       
   829 
       
   830     return err;
       
   831 }
       
   832 
       
   833 // Server shim for MatchMD5 of BeremizPLCObjectService interface.
       
   834 erpc_status_t BeremizPLCObjectService_service::MatchMD5_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
   835 {
       
   836     erpc_status_t err = kErpcStatus_Success;
       
   837 
       
   838     char * MD5 = NULL;
       
   839     bool match;
       
   840     uint32_t result;
       
   841 
       
   842     // startReadMessage() was already called before this shim was invoked.
       
   843 
       
   844     {
       
   845         uint32_t MD5_len;
       
   846         char * MD5_local;
       
   847         codec->readString(MD5_len, &MD5_local);
       
   848         MD5 = (char*) erpc_malloc((MD5_len + 1) * sizeof(char));
       
   849         if ((MD5 == NULL) || (MD5_local == NULL))
       
   850         {
       
   851             codec->updateStatus(kErpcStatus_MemoryError);
       
   852         }
       
   853         else
       
   854         {
       
   855             memcpy(MD5, MD5_local, MD5_len);
       
   856             (MD5)[MD5_len] = 0;
       
   857         }
       
   858     }
       
   859 
       
   860     err = codec->getStatus();
       
   861     if (err == kErpcStatus_Success)
       
   862     {
       
   863         // Invoke the actual served function.
       
   864 #if ERPC_NESTED_CALLS_DETECTION
       
   865         nestingDetection = true;
       
   866 #endif
       
   867         result = m_handler->MatchMD5(MD5, &match);
       
   868 #if ERPC_NESTED_CALLS_DETECTION
       
   869         nestingDetection = false;
       
   870 #endif
       
   871 
       
   872         // preparing MessageBuffer for serializing data
       
   873         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
   874     }
       
   875 
       
   876     if (err == kErpcStatus_Success)
       
   877     {
       
   878         // preparing codec for serializing data
       
   879         codec->reset(transport->reserveHeaderSize());
       
   880 
       
   881         // Build response message.
       
   882         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_MatchMD5Id, sequence);
       
   883 
       
   884         codec->write(match);
       
   885 
       
   886         codec->write(result);
       
   887 
       
   888         err = codec->getStatus();
       
   889     }
       
   890 
       
   891     erpc_free(MD5);
       
   892 
       
   893     return err;
       
   894 }
       
   895 
       
   896 // Server shim for NewPLC of BeremizPLCObjectService interface.
       
   897 erpc_status_t BeremizPLCObjectService_service::NewPLC_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
   898 {
       
   899     erpc_status_t err = kErpcStatus_Success;
       
   900 
       
   901     char * md5sum = NULL;
       
   902     binary_t *plcObjectBlobID = NULL;
       
   903     plcObjectBlobID = (binary_t *) erpc_malloc(sizeof(binary_t));
       
   904     if (plcObjectBlobID == NULL)
       
   905     {
       
   906         codec->updateStatus(kErpcStatus_MemoryError);
       
   907     }
       
   908     list_extra_file_1_t *extrafiles = NULL;
       
   909     extrafiles = (list_extra_file_1_t *) erpc_malloc(sizeof(list_extra_file_1_t));
       
   910     if (extrafiles == NULL)
       
   911     {
       
   912         codec->updateStatus(kErpcStatus_MemoryError);
       
   913     }
       
   914     bool success;
       
   915     uint32_t result;
       
   916 
       
   917     // startReadMessage() was already called before this shim was invoked.
       
   918 
       
   919     {
       
   920         uint32_t md5sum_len;
       
   921         char * md5sum_local;
       
   922         codec->readString(md5sum_len, &md5sum_local);
       
   923         md5sum = (char*) erpc_malloc((md5sum_len + 1) * sizeof(char));
       
   924         if ((md5sum == NULL) || (md5sum_local == NULL))
       
   925         {
       
   926             codec->updateStatus(kErpcStatus_MemoryError);
       
   927         }
       
   928         else
       
   929         {
       
   930             memcpy(md5sum, md5sum_local, md5sum_len);
       
   931             (md5sum)[md5sum_len] = 0;
       
   932         }
       
   933     }
       
   934 
       
   935     read_binary_t_struct(codec, plcObjectBlobID);
       
   936 
       
   937     read_list_extra_file_1_t_struct(codec, extrafiles);
       
   938 
       
   939     err = codec->getStatus();
       
   940     if (err == kErpcStatus_Success)
       
   941     {
       
   942         // Invoke the actual served function.
       
   943 #if ERPC_NESTED_CALLS_DETECTION
       
   944         nestingDetection = true;
       
   945 #endif
       
   946         result = m_handler->NewPLC(md5sum, plcObjectBlobID, extrafiles, &success);
       
   947 #if ERPC_NESTED_CALLS_DETECTION
       
   948         nestingDetection = false;
       
   949 #endif
       
   950 
       
   951         // preparing MessageBuffer for serializing data
       
   952         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
   953     }
       
   954 
       
   955     if (err == kErpcStatus_Success)
       
   956     {
       
   957         // preparing codec for serializing data
       
   958         codec->reset(transport->reserveHeaderSize());
       
   959 
       
   960         // Build response message.
       
   961         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_NewPLCId, sequence);
       
   962 
       
   963         codec->write(success);
       
   964 
       
   965         codec->write(result);
       
   966 
       
   967         err = codec->getStatus();
       
   968     }
       
   969 
       
   970     erpc_free(md5sum);
       
   971 
       
   972     if (plcObjectBlobID)
       
   973     {
       
   974         free_binary_t_struct(plcObjectBlobID);
       
   975     }
       
   976     erpc_free(plcObjectBlobID);
       
   977 
       
   978     if (extrafiles)
       
   979     {
       
   980         free_list_extra_file_1_t_struct(extrafiles);
       
   981     }
       
   982     erpc_free(extrafiles);
       
   983 
       
   984     return err;
       
   985 }
       
   986 
       
   987 // Server shim for PurgeBlobs of BeremizPLCObjectService interface.
       
   988 erpc_status_t BeremizPLCObjectService_service::PurgeBlobs_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
   989 {
       
   990     erpc_status_t err = kErpcStatus_Success;
       
   991 
       
   992     uint32_t result;
       
   993 
       
   994     // startReadMessage() was already called before this shim was invoked.
       
   995 
       
   996     err = codec->getStatus();
       
   997     if (err == kErpcStatus_Success)
       
   998     {
       
   999         // Invoke the actual served function.
       
  1000 #if ERPC_NESTED_CALLS_DETECTION
       
  1001         nestingDetection = true;
       
  1002 #endif
       
  1003         result = m_handler->PurgeBlobs();
       
  1004 #if ERPC_NESTED_CALLS_DETECTION
       
  1005         nestingDetection = false;
       
  1006 #endif
       
  1007 
       
  1008         // preparing MessageBuffer for serializing data
       
  1009         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
  1010     }
       
  1011 
       
  1012     if (err == kErpcStatus_Success)
       
  1013     {
       
  1014         // preparing codec for serializing data
       
  1015         codec->reset(transport->reserveHeaderSize());
       
  1016 
       
  1017         // Build response message.
       
  1018         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_PurgeBlobsId, sequence);
       
  1019 
       
  1020         codec->write(result);
       
  1021 
       
  1022         err = codec->getStatus();
       
  1023     }
       
  1024 
       
  1025     return err;
       
  1026 }
       
  1027 
       
  1028 // Server shim for RepairPLC of BeremizPLCObjectService interface.
       
  1029 erpc_status_t BeremizPLCObjectService_service::RepairPLC_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
  1030 {
       
  1031     erpc_status_t err = kErpcStatus_Success;
       
  1032 
       
  1033     uint32_t result;
       
  1034 
       
  1035     // startReadMessage() was already called before this shim was invoked.
       
  1036 
       
  1037     err = codec->getStatus();
       
  1038     if (err == kErpcStatus_Success)
       
  1039     {
       
  1040         // Invoke the actual served function.
       
  1041 #if ERPC_NESTED_CALLS_DETECTION
       
  1042         nestingDetection = true;
       
  1043 #endif
       
  1044         result = m_handler->RepairPLC();
       
  1045 #if ERPC_NESTED_CALLS_DETECTION
       
  1046         nestingDetection = false;
       
  1047 #endif
       
  1048 
       
  1049         // preparing MessageBuffer for serializing data
       
  1050         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
  1051     }
       
  1052 
       
  1053     if (err == kErpcStatus_Success)
       
  1054     {
       
  1055         // preparing codec for serializing data
       
  1056         codec->reset(transport->reserveHeaderSize());
       
  1057 
       
  1058         // Build response message.
       
  1059         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_RepairPLCId, sequence);
       
  1060 
       
  1061         codec->write(result);
       
  1062 
       
  1063         err = codec->getStatus();
       
  1064     }
       
  1065 
       
  1066     return err;
       
  1067 }
       
  1068 
       
  1069 // Server shim for ResetLogCount of BeremizPLCObjectService interface.
       
  1070 erpc_status_t BeremizPLCObjectService_service::ResetLogCount_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
  1071 {
       
  1072     erpc_status_t err = kErpcStatus_Success;
       
  1073 
       
  1074     uint32_t result;
       
  1075 
       
  1076     // startReadMessage() was already called before this shim was invoked.
       
  1077 
       
  1078     err = codec->getStatus();
       
  1079     if (err == kErpcStatus_Success)
       
  1080     {
       
  1081         // Invoke the actual served function.
       
  1082 #if ERPC_NESTED_CALLS_DETECTION
       
  1083         nestingDetection = true;
       
  1084 #endif
       
  1085         result = m_handler->ResetLogCount();
       
  1086 #if ERPC_NESTED_CALLS_DETECTION
       
  1087         nestingDetection = false;
       
  1088 #endif
       
  1089 
       
  1090         // preparing MessageBuffer for serializing data
       
  1091         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
  1092     }
       
  1093 
       
  1094     if (err == kErpcStatus_Success)
       
  1095     {
       
  1096         // preparing codec for serializing data
       
  1097         codec->reset(transport->reserveHeaderSize());
       
  1098 
       
  1099         // Build response message.
       
  1100         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_ResetLogCountId, sequence);
       
  1101 
       
  1102         codec->write(result);
       
  1103 
       
  1104         err = codec->getStatus();
       
  1105     }
       
  1106 
       
  1107     return err;
       
  1108 }
       
  1109 
       
  1110 // Server shim for SeedBlob of BeremizPLCObjectService interface.
       
  1111 erpc_status_t BeremizPLCObjectService_service::SeedBlob_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
  1112 {
       
  1113     erpc_status_t err = kErpcStatus_Success;
       
  1114 
       
  1115     binary_t *seed = NULL;
       
  1116     seed = (binary_t *) erpc_malloc(sizeof(binary_t));
       
  1117     if (seed == NULL)
       
  1118     {
       
  1119         codec->updateStatus(kErpcStatus_MemoryError);
       
  1120     }
       
  1121     binary_t *blobID = NULL;
       
  1122     uint32_t result;
       
  1123 
       
  1124     // startReadMessage() was already called before this shim was invoked.
       
  1125 
       
  1126     read_binary_t_struct(codec, seed);
       
  1127 
       
  1128     blobID = (binary_t *) erpc_malloc(sizeof(binary_t));
       
  1129     if (blobID == NULL)
       
  1130     {
       
  1131         codec->updateStatus(kErpcStatus_MemoryError);
       
  1132     }
       
  1133 
       
  1134     err = codec->getStatus();
       
  1135     if (err == kErpcStatus_Success)
       
  1136     {
       
  1137         // Invoke the actual served function.
       
  1138 #if ERPC_NESTED_CALLS_DETECTION
       
  1139         nestingDetection = true;
       
  1140 #endif
       
  1141         result = m_handler->SeedBlob(seed, blobID);
       
  1142 #if ERPC_NESTED_CALLS_DETECTION
       
  1143         nestingDetection = false;
       
  1144 #endif
       
  1145 
       
  1146         // preparing MessageBuffer for serializing data
       
  1147         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
  1148     }
       
  1149 
       
  1150     if (err == kErpcStatus_Success)
       
  1151     {
       
  1152         // preparing codec for serializing data
       
  1153         codec->reset(transport->reserveHeaderSize());
       
  1154 
       
  1155         // Build response message.
       
  1156         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_SeedBlobId, sequence);
       
  1157 
       
  1158         write_binary_t_struct(codec, blobID);
       
  1159 
       
  1160         codec->write(result);
       
  1161 
       
  1162         err = codec->getStatus();
       
  1163     }
       
  1164 
       
  1165     if (seed)
       
  1166     {
       
  1167         free_binary_t_struct(seed);
       
  1168     }
       
  1169     erpc_free(seed);
       
  1170 
       
  1171     if (blobID)
       
  1172     {
       
  1173         free_binary_t_struct(blobID);
       
  1174     }
       
  1175     erpc_free(blobID);
       
  1176 
       
  1177     return err;
       
  1178 }
       
  1179 
       
  1180 // Server shim for SetTraceVariablesList of BeremizPLCObjectService interface.
       
  1181 erpc_status_t BeremizPLCObjectService_service::SetTraceVariablesList_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
  1182 {
       
  1183     erpc_status_t err = kErpcStatus_Success;
       
  1184 
       
  1185     list_trace_order_1_t *orders = NULL;
       
  1186     orders = (list_trace_order_1_t *) erpc_malloc(sizeof(list_trace_order_1_t));
       
  1187     if (orders == NULL)
       
  1188     {
       
  1189         codec->updateStatus(kErpcStatus_MemoryError);
       
  1190     }
       
  1191     int32_t debugtoken;
       
  1192     uint32_t result;
       
  1193 
       
  1194     // startReadMessage() was already called before this shim was invoked.
       
  1195 
       
  1196     read_list_trace_order_1_t_struct(codec, orders);
       
  1197 
       
  1198     err = codec->getStatus();
       
  1199     if (err == kErpcStatus_Success)
       
  1200     {
       
  1201         // Invoke the actual served function.
       
  1202 #if ERPC_NESTED_CALLS_DETECTION
       
  1203         nestingDetection = true;
       
  1204 #endif
       
  1205         result = m_handler->SetTraceVariablesList(orders, &debugtoken);
       
  1206 #if ERPC_NESTED_CALLS_DETECTION
       
  1207         nestingDetection = false;
       
  1208 #endif
       
  1209 
       
  1210         // preparing MessageBuffer for serializing data
       
  1211         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
  1212     }
       
  1213 
       
  1214     if (err == kErpcStatus_Success)
       
  1215     {
       
  1216         // preparing codec for serializing data
       
  1217         codec->reset(transport->reserveHeaderSize());
       
  1218 
       
  1219         // Build response message.
       
  1220         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_SetTraceVariablesListId, sequence);
       
  1221 
       
  1222         codec->write(debugtoken);
       
  1223 
       
  1224         codec->write(result);
       
  1225 
       
  1226         err = codec->getStatus();
       
  1227     }
       
  1228 
       
  1229     if (orders)
       
  1230     {
       
  1231         free_list_trace_order_1_t_struct(orders);
       
  1232     }
       
  1233     erpc_free(orders);
       
  1234 
       
  1235     return err;
       
  1236 }
       
  1237 
       
  1238 // Server shim for StartPLC of BeremizPLCObjectService interface.
       
  1239 erpc_status_t BeremizPLCObjectService_service::StartPLC_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
  1240 {
       
  1241     erpc_status_t err = kErpcStatus_Success;
       
  1242 
       
  1243     uint32_t result;
       
  1244 
       
  1245     // startReadMessage() was already called before this shim was invoked.
       
  1246 
       
  1247     err = codec->getStatus();
       
  1248     if (err == kErpcStatus_Success)
       
  1249     {
       
  1250         // Invoke the actual served function.
       
  1251 #if ERPC_NESTED_CALLS_DETECTION
       
  1252         nestingDetection = true;
       
  1253 #endif
       
  1254         result = m_handler->StartPLC();
       
  1255 #if ERPC_NESTED_CALLS_DETECTION
       
  1256         nestingDetection = false;
       
  1257 #endif
       
  1258 
       
  1259         // preparing MessageBuffer for serializing data
       
  1260         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
  1261     }
       
  1262 
       
  1263     if (err == kErpcStatus_Success)
       
  1264     {
       
  1265         // preparing codec for serializing data
       
  1266         codec->reset(transport->reserveHeaderSize());
       
  1267 
       
  1268         // Build response message.
       
  1269         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_StartPLCId, sequence);
       
  1270 
       
  1271         codec->write(result);
       
  1272 
       
  1273         err = codec->getStatus();
       
  1274     }
       
  1275 
       
  1276     return err;
       
  1277 }
       
  1278 
       
  1279 // Server shim for StopPLC of BeremizPLCObjectService interface.
       
  1280 erpc_status_t BeremizPLCObjectService_service::StopPLC_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
  1281 {
       
  1282     erpc_status_t err = kErpcStatus_Success;
       
  1283 
       
  1284     bool success;
       
  1285     uint32_t result;
       
  1286 
       
  1287     // startReadMessage() was already called before this shim was invoked.
       
  1288 
       
  1289     err = codec->getStatus();
       
  1290     if (err == kErpcStatus_Success)
       
  1291     {
       
  1292         // Invoke the actual served function.
       
  1293 #if ERPC_NESTED_CALLS_DETECTION
       
  1294         nestingDetection = true;
       
  1295 #endif
       
  1296         result = m_handler->StopPLC(&success);
       
  1297 #if ERPC_NESTED_CALLS_DETECTION
       
  1298         nestingDetection = false;
       
  1299 #endif
       
  1300 
       
  1301         // preparing MessageBuffer for serializing data
       
  1302         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
  1303     }
       
  1304 
       
  1305     if (err == kErpcStatus_Success)
       
  1306     {
       
  1307         // preparing codec for serializing data
       
  1308         codec->reset(transport->reserveHeaderSize());
       
  1309 
       
  1310         // Build response message.
       
  1311         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_StopPLCId, sequence);
       
  1312 
       
  1313         codec->write(success);
       
  1314 
       
  1315         codec->write(result);
       
  1316 
       
  1317         err = codec->getStatus();
       
  1318     }
       
  1319 
       
  1320     return err;
       
  1321 }
       
  1322 
       
  1323 // Server shim for ExtendedCall of BeremizPLCObjectService interface.
       
  1324 erpc_status_t BeremizPLCObjectService_service::ExtendedCall_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
       
  1325 {
       
  1326     erpc_status_t err = kErpcStatus_Success;
       
  1327 
       
  1328     char * method = NULL;
       
  1329     binary_t *argument = NULL;
       
  1330     argument = (binary_t *) erpc_malloc(sizeof(binary_t));
       
  1331     if (argument == NULL)
       
  1332     {
       
  1333         codec->updateStatus(kErpcStatus_MemoryError);
       
  1334     }
       
  1335     binary_t *answer = NULL;
       
  1336     uint32_t result;
       
  1337 
       
  1338     // startReadMessage() was already called before this shim was invoked.
       
  1339 
       
  1340     {
       
  1341         uint32_t method_len;
       
  1342         char * method_local;
       
  1343         codec->readString(method_len, &method_local);
       
  1344         method = (char*) erpc_malloc((method_len + 1) * sizeof(char));
       
  1345         if ((method == NULL) || (method_local == NULL))
       
  1346         {
       
  1347             codec->updateStatus(kErpcStatus_MemoryError);
       
  1348         }
       
  1349         else
       
  1350         {
       
  1351             memcpy(method, method_local, method_len);
       
  1352             (method)[method_len] = 0;
       
  1353         }
       
  1354     }
       
  1355 
       
  1356     read_binary_t_struct(codec, argument);
       
  1357 
       
  1358     answer = (binary_t *) erpc_malloc(sizeof(binary_t));
       
  1359     if (answer == NULL)
       
  1360     {
       
  1361         codec->updateStatus(kErpcStatus_MemoryError);
       
  1362     }
       
  1363 
       
  1364     err = codec->getStatus();
       
  1365     if (err == kErpcStatus_Success)
       
  1366     {
       
  1367         // Invoke the actual served function.
       
  1368 #if ERPC_NESTED_CALLS_DETECTION
       
  1369         nestingDetection = true;
       
  1370 #endif
       
  1371         result = m_handler->ExtendedCall(method, argument, answer);
       
  1372 #if ERPC_NESTED_CALLS_DETECTION
       
  1373         nestingDetection = false;
       
  1374 #endif
       
  1375 
       
  1376         // preparing MessageBuffer for serializing data
       
  1377         err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
       
  1378     }
       
  1379 
       
  1380     if (err == kErpcStatus_Success)
       
  1381     {
       
  1382         // preparing codec for serializing data
       
  1383         codec->reset(transport->reserveHeaderSize());
       
  1384 
       
  1385         // Build response message.
       
  1386         codec->startWriteMessage(message_type_t::kReplyMessage, BeremizPLCObjectService_interface::m_serviceId, BeremizPLCObjectService_interface::m_ExtendedCallId, sequence);
       
  1387 
       
  1388         write_binary_t_struct(codec, answer);
       
  1389 
       
  1390         codec->write(result);
       
  1391 
       
  1392         err = codec->getStatus();
       
  1393     }
       
  1394 
       
  1395     erpc_free(method);
       
  1396 
       
  1397     if (argument)
       
  1398     {
       
  1399         free_binary_t_struct(argument);
       
  1400     }
       
  1401     erpc_free(argument);
       
  1402 
       
  1403     if (answer)
       
  1404     {
       
  1405         free_binary_t_struct(answer);
       
  1406     }
       
  1407     erpc_free(answer);
       
  1408 
       
  1409     return err;
       
  1410 }