Skip to content

Commit 23d467f

Browse files
authored
Add product version on Participant Discovery information (#4964)
* Refs #21197. Add sending ProductVersion on discovery Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev> * Refs #21197. Add tests Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev> * Refs #21197. Add line in versions.md Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev> * Refs #21197. Add information on ParticipantBuiltinTopicData Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev> * Refs #21197. Apply suggestions Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev> * Refs #21197. Apply suggestion Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev> * Refs #21197. Fix test Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev> --------- Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
1 parent 8c477dc commit 23d467f

11 files changed

Lines changed: 412 additions & 88 deletions

File tree

include/fastdds/dds/core/policy/ParameterTypes.hpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <fastdds/dds/core/Types.hpp>
3131
#include <fastdds/rtps/common/InstanceHandle.hpp>
3232
#include <fastdds/rtps/common/Locator.hpp>
33+
#include <fastdds/rtps/common/ProductVersion_t.hpp>
3334
#include <fastdds/rtps/common/SampleIdentity.hpp>
3435
#include <fastdds/rtps/common/SerializedPayload.hpp>
3536
#include <fastdds/rtps/common/Time_t.hpp>
@@ -165,11 +166,12 @@ enum ParameterId_t : uint16_t
165166
PID_RELATED_SAMPLE_IDENTITY = 0x0083,
166167

167168
/* eProsima Fast DDS extensions */
169+
PID_PRODUCT_VERSION = 0x8000,
168170
PID_PERSISTENCE_GUID = 0x8002,
169-
PID_CUSTOM_RELATED_SAMPLE_IDENTITY = 0x800f,
170171
PID_DISABLE_POSITIVE_ACKS = 0x8005,
171172
PID_DATASHARING = 0x8006,
172173
PID_NETWORK_CONFIGURATION_SET = 0x8007,
174+
PID_CUSTOM_RELATED_SAMPLE_IDENTITY = 0x800f,
173175
};
174176

175177
/*!
@@ -632,6 +634,39 @@ class ParameterVendorId_t : public Parameter_t
632634

633635
#define PARAMETER_VENDOR_LENGTH 4
634636

637+
/**
638+
* @ingroup PARAMETER_MODULE
639+
*/
640+
class ParameterProductVersion_t : public Parameter_t
641+
{
642+
public:
643+
644+
rtps::ProductVersion_t version;
645+
646+
/**
647+
* @brief Constructor without parameters
648+
*/
649+
ParameterProductVersion_t()
650+
{
651+
}
652+
653+
/**
654+
* Constructor using a parameter PID and the parameter length
655+
*
656+
* @param pid Pid of the parameter
657+
* @param in_length Its associated length
658+
*/
659+
ParameterProductVersion_t(
660+
ParameterId_t pid,
661+
uint16_t in_length)
662+
: Parameter_t(pid, in_length)
663+
{
664+
}
665+
666+
};
667+
668+
#define PARAMETER_PRODUCT_VERSION_LENGTH 4
669+
635670
/**
636671
* @ingroup PARAMETER_MODULE
637672
*/
@@ -1883,6 +1918,7 @@ using ParameterGuid_t = fastdds::dds::ParameterGuid_t;
18831918
using ParameterDomainId_t = fastdds::dds::ParameterDomainId_t;
18841919
using ParameterProtocolVersion_t = fastdds::dds::ParameterProtocolVersion_t;
18851920
using ParameterVendorId_t = fastdds::dds::ParameterVendorId_t;
1921+
using ParameterProductVersion_t = fastdds::dds::ParameterProductVersion_t;
18861922
using ParameterIP4Address_t = fastdds::dds::ParameterIP4Address_t;
18871923
using ParameterBool_t = fastdds::dds::ParameterBool_t;
18881924
using ParameterStatusInfo_t = fastdds::dds::ParameterStatusInfo_t;

include/fastdds/rtps/builtin/data/ParticipantBuiltinTopicData.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <fastdds/dds/core/policy/QosPolicies.hpp>
2424
#include <fastdds/rtps/builtin/data/BuiltinTopicKey.hpp>
25+
#include <fastdds/rtps/common/ProductVersion_t.hpp>
2526
#include <fastdds/rtps/common/RemoteLocators.hpp>
2627

2728
namespace eprosima {
@@ -57,6 +58,9 @@ struct ParticipantBuiltinTopicData
5758
/// Vendor id
5859
VendorId_t vendor_id;
5960

61+
/// Product version
62+
ProductVersion_t product_version;
63+
6064
/// Participant domain id
6165
dds::DomainId_t domain_id;
6266
};
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/**
16+
* @file ProductVersion_t.hpp
17+
*/
18+
19+
#ifndef FASTDDS_RTPS_COMMON__PRODUCTVERSION_T_HPP
20+
#define FASTDDS_RTPS_COMMON__PRODUCTVERSION_T_HPP
21+
22+
#include <cstdint>
23+
#include <iomanip>
24+
#include <iostream>
25+
26+
namespace eprosima {
27+
namespace fastdds {
28+
namespace rtps {
29+
30+
struct ProductVersion_t
31+
{
32+
uint8_t major {0};
33+
uint8_t minor {0};
34+
uint8_t patch {0};
35+
uint8_t tweak {0};
36+
};
37+
38+
} // namespace rtps
39+
} // namespace fastdds
40+
} // namespace eprosima
41+
42+
/**
43+
* @brief ostream operator<< for ProductVersion_t
44+
*
45+
* @param output: the output stream
46+
* @param product_version: the product version to append to the output stream
47+
*/
48+
inline std::ostream& operator <<(
49+
std::ostream& output,
50+
eprosima::fastdds::rtps::ProductVersion_t product_version)
51+
{
52+
output << static_cast<uint32_t>(product_version.major)
53+
<< "." << static_cast<uint32_t>(product_version.minor)
54+
<< "." << static_cast<uint32_t>(product_version.patch)
55+
<< "." << static_cast<uint32_t>(product_version.tweak);
56+
return output;
57+
}
58+
59+
#endif /* FASTDDS_RTPS_COMMON__PRODUCTVERSION_T_HPP */

include/fastdds/rtps/common/Types.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <fastdds/fastdds_dll.hpp>
2828

29+
#include <fastdds/rtps/common/ProductVersion_t.hpp>
2930
#include <fastdds/rtps/common/VendorId_t.hpp>
3031

3132
namespace eprosima {

src/cpp/fastdds/core/policy/ParameterSerializer.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,36 @@ inline bool ParameterSerializer<ParameterVendorId_t>::read_content_from_cdr_mess
433433
return valid;
434434
}
435435

436+
template<>
437+
inline bool ParameterSerializer<ParameterProductVersion_t>::add_content_to_cdr_message(
438+
const ParameterProductVersion_t& parameter,
439+
rtps::CDRMessage_t* cdr_message)
440+
{
441+
bool valid = rtps::CDRMessage::addOctet(cdr_message, parameter.version.major);
442+
valid &= rtps::CDRMessage::addOctet(cdr_message, parameter.version.minor);
443+
valid &= rtps::CDRMessage::addOctet(cdr_message, parameter.version.patch);
444+
valid &= rtps::CDRMessage::addOctet(cdr_message, parameter.version.tweak);
445+
return valid;
446+
}
447+
448+
template<>
449+
inline bool ParameterSerializer<ParameterProductVersion_t>::read_content_from_cdr_message(
450+
ParameterProductVersion_t& parameter,
451+
rtps::CDRMessage_t* cdr_message,
452+
const uint16_t parameter_length)
453+
{
454+
if (parameter_length != PARAMETER_PRODUCT_VERSION_LENGTH)
455+
{
456+
return false;
457+
}
458+
parameter.length = parameter_length;
459+
bool valid = rtps::CDRMessage::readOctet(cdr_message, &parameter.version.major);
460+
valid &= rtps::CDRMessage::readOctet(cdr_message, &parameter.version.minor);
461+
valid &= rtps::CDRMessage::readOctet(cdr_message, &parameter.version.patch);
462+
valid &= rtps::CDRMessage::readOctet(cdr_message, &parameter.version.tweak);
463+
return valid;
464+
}
465+
436466
template<>
437467
inline bool ParameterSerializer<ParameterDomainId_t>::add_content_to_cdr_message(
438468
const ParameterDomainId_t& parameter,

0 commit comments

Comments
 (0)