@@ -49,23 +49,45 @@ namespace cip {
4949 , _size{3 } {
5050 }
5151
52- std::vector<uint8_t > EPath::packPaddedPath () const {
53- Buffer buffer (_size*4 );
54-
55- auto classSegment = static_cast <CipUint>(EPathSegmentTypes::CLASS_16_BITS);
56- buffer << classSegment << _classId;
57-
58- if (_size > 1 ) {
59- auto instanceSegment = static_cast <CipUint>(EPathSegmentTypes::INSTANCE_16_BITS);
60- buffer << instanceSegment << _objectId;
61-
62- if (_size > 2 ) {
63- auto attributeSegment = static_cast <CipUint>(EPathSegmentTypes::ATTRIBUTE_16_BITS);
64- buffer << attributeSegment << _attributeId;
65- }
66- }
67-
68- return buffer.data ();
52+ std::vector<uint8_t > EPath::packPaddedPath (bool use_8_bit_path_segments) const {
53+ if (use_8_bit_path_segments)
54+ {
55+ Buffer buffer (_size*2 );
56+
57+ auto classSegment = static_cast <CipUsint>(EPathSegmentTypes::CLASS_8_BITS);
58+ buffer << classSegment << static_cast <CipUsint>(_classId);
59+
60+ if (_size > 1 ) {
61+ auto instanceSegment = static_cast <CipUsint>(EPathSegmentTypes::INSTANCE_8_BITS);
62+ buffer << instanceSegment << static_cast <CipUsint>(_objectId);
63+
64+ if (_size > 2 ) {
65+ auto attributeSegment = static_cast <CipUsint>(EPathSegmentTypes::ATTRIBUTE_8_BITS);
66+ buffer << attributeSegment << static_cast <CipUsint>(_attributeId);
67+ }
68+ }
69+
70+ return buffer.data ();
71+ }
72+ else
73+ {
74+ Buffer buffer (_size*4 );
75+
76+ auto classSegment = static_cast <CipUint>(EPathSegmentTypes::CLASS_16_BITS);
77+ buffer << classSegment << _classId;
78+
79+ if (_size > 1 ) {
80+ auto instanceSegment = static_cast <CipUint>(EPathSegmentTypes::INSTANCE_16_BITS);
81+ buffer << instanceSegment << _objectId;
82+
83+ if (_size > 2 ) {
84+ auto attributeSegment = static_cast <CipUint>(EPathSegmentTypes::ATTRIBUTE_16_BITS);
85+ buffer << attributeSegment << _attributeId;
86+ }
87+ }
88+
89+ return buffer.data ();
90+ }
6991 }
7092
7193 CipUint EPath::getClassId () const {
@@ -80,8 +102,13 @@ namespace cip {
80102 return _attributeId;
81103 }
82104
83- CipUsint EPath::getSizeInWords () const {
84- return _size*2 ;
105+ CipUsint EPath::getSizeInWords (bool use_8_bit_path_segments) const {
106+ if (use_8_bit_path_segments) {
107+ return _size;
108+ }
109+ else {
110+ return _size*2 ;
111+ }
85112 }
86113
87114 std::string EPath::toString () const {
0 commit comments