MCPcopy Create free account
hub / github.com/EIPStackGroup/OpENer / EncodeData

Function EncodeData

source/src/cip/cipcommon.c:450–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

448}
449
450int EncodeData(const EipUint8 cip_type,
451 const void *const cip_data,
452 EipUint8 **cip_message) {
453 int counter = 0;
454
455 switch (cip_type)
456 /* check the data type of attribute */
457 {
458 case (kCipBool):
459 case (kCipSint):
460 case (kCipUsint):
461 case (kCipByte):
462 counter = AddSintToMessage(*(EipUint8 *) (cip_data), cip_message);
463 break;
464
465 case (kCipInt):
466 case (kCipUint):
467 case (kCipWord):
468 counter = AddIntToMessage(*(EipUint16 *) (cip_data), cip_message);
469 break;
470
471 case (kCipDint):
472 case (kCipUdint):
473 case (kCipDword):
474 case (kCipReal):
475 counter = AddDintToMessage(*(EipUint32 *) (cip_data), cip_message);
476 break;
477
478#ifdef OPENER_SUPPORT_64BIT_DATATYPES
479 case (kCipLint):
480 case (kCipUlint):
481 case (kCipLword):
482 case (kCipLreal):
483 counter = AddLintToMessage(*(EipUint64 *) (cip_data), cip_message);
484 break;
485#endif
486
487 case (kCipStime):
488 case (kCipDate):
489 case (kCipTimeOfDay):
490 case (kCipDateAndTime):
491 break;
492 case (kCipString): {
493 CipString *const string = (CipString *) cip_data;
494
495 AddIntToMessage(*(EipUint16 *) &(string->length), cip_message);
496 memcpy(*cip_message, string->string, string->length);
497 *cip_message += string->length;
498
499 counter = string->length + 2; /* we have a two byte length field */
500 if (counter & 0x01) {
501 /* we have an odd byte count */
502 **cip_message = 0;
503 ++(*cip_message);
504 counter++;
505 }
506 break;
507 }

Callers 6

GetAttributeSingleFunction · 0.85
EncodeInterfaceCountersFunction · 0.85
EncodeMediaCountersFunction · 0.85
EncodeInterfaceControlFunction · 0.85

Calls 5

AddSintToMessageFunction · 0.85
AddIntToMessageFunction · 0.85
AddDintToMessageFunction · 0.85
AddLintToMessageFunction · 0.85
EncodeEPathFunction · 0.85

Tested by

no test coverage detected