C_runtime/erpc_PLCObject_server.cpp
changeset 4032 1ffff67678ad
parent 3946 8815b44be31e
child 4044 2a4b8b59d165
equal deleted inserted replaced
4031:a89ed401fbc6 4032:1ffff67678ad
     1 /*
     1 /*
     2  * Generated by erpcgen 1.12.0 on Mon May 20 17:54:19 2024.
     2  * Generated by erpcgen 1.12.0 on Mon Oct 28 15:10:14 2024.
     3  *
     3  *
     4  * AUTOGENERATED - DO NOT EDIT
     4  * AUTOGENERATED - DO NOT EDIT
     5  */
     5  */
     6 
     6 
     7 
     7 
   499         {
   499         {
   500             erpcStatus = StopPLC_shim(codec, messageFactory, transport, sequence);
   500             erpcStatus = StopPLC_shim(codec, messageFactory, transport, sequence);
   501             break;
   501             break;
   502         }
   502         }
   503 
   503 
       
   504         case BeremizPLCObjectService_interface::m_ExtendedCallId:
       
   505         {
       
   506             erpcStatus = ExtendedCall_shim(codec, messageFactory, transport, sequence);
       
   507             break;
       
   508         }
       
   509 
   504         default:
   510         default:
   505         {
   511         {
   506             erpcStatus = kErpcStatus_InvalidArgument;
   512             erpcStatus = kErpcStatus_InvalidArgument;
   507             break;
   513             break;
   508         }
   514         }
  1311         err = codec->getStatus();
  1317         err = codec->getStatus();
  1312     }
  1318     }
  1313 
  1319 
  1314     return err;
  1320     return err;
  1315 }
  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 }