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

Function EncodeEPath

source/src/cip/cipcommon.c:758–813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

756}
757
758int EncodeEPath(CipEpath *epath,
759 EipUint8 **message) {
760 unsigned int length = epath->path_size;
761 AddIntToMessage(epath->path_size, message);
762
763 if (epath->class_id < 256) {
764 **message = 0x20; /*8Bit Class Id */
765 ++(*message);
766 **message = (EipUint8) epath->class_id;
767 ++(*message);
768 length -= 1;
769 } else {
770 **message = 0x21; /*16Bit Class Id */
771 ++(*message);
772 **message = 0; /*pad byte */
773 ++(*message);
774 AddIntToMessage(epath->class_id, message);
775 length -= 2;
776 }
777
778 if (0 < length) {
779 if (epath->instance_number < 256) {
780 **message = 0x24; /*8Bit Instance Id */
781 ++(*message);
782 **message = (EipUint8) epath->instance_number;
783 ++(*message);
784 length -= 1;
785 } else {
786 **message = 0x25; /*16Bit Instance Id */
787 ++(*message);
788 **message = 0; /*padd byte */
789 ++(*message);
790 AddIntToMessage(epath->instance_number, message);
791 length -= 2;
792 }
793
794 if (0 < length) {
795 if (epath->attribute_number < 256) {
796 **message = 0x30; /*8Bit Attribute Id */
797 ++(*message);
798 **message = (EipUint8) epath->attribute_number;
799 ++(*message);
800 length -= 1;
801 } else {
802 **message = 0x31; /*16Bit Attribute Id */
803 ++(*message);
804 **message = 0; /*pad byte */
805 ++(*message);
806 AddIntToMessage(epath->attribute_number, message);
807 length -= 2;
808 }
809 }
810 }
811
812 return 2 + epath->path_size * 2; /* path size is in 16 bit chunks according to the specification */
813}
814
815int DecodePaddedEPath(CipEpath *epath,

Callers 1

EncodeDataFunction · 0.85

Calls 1

AddIntToMessageFunction · 0.85

Tested by

no test coverage detected