Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions components/rtps_embedded/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ idf_component_register(
"src/entities/Domain.cpp"
"src/entities/Participant.cpp"
"src/entities/Reader.cpp"
"src/entities/StatefulReader.cpp"
"src/entities/StatefulWriter.cpp"
"src/entities/StatelessReader.cpp"
"src/entities/StatelessWriter.cpp"
"src/entities/Writer.cpp"
"src/messages/MessageReceiver.cpp"
"src/messages/MessageTypes.cpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ namespace rtps {
class EsppTransport;
struct SubmessageHeartbeat;

template <class NetworkDriver> class StatefulReaderT final : public Reader {
class StatefulReader final : public Reader {
public:
StatefulReaderT()
StatefulReader()
: m_srcPort(0)
, m_transport(nullptr) {}
~StatefulReaderT() override;
bool init(const TopicData &attributes, NetworkDriver &driver);
~StatefulReader() override;
bool init(const TopicData &attributes, EsppTransport &driver);
void newChange(const ReaderCacheChange &cacheChange) override;
bool addNewMatchedWriter(const WriterProxy &newProxy) override;
bool onNewHeartbeat(const SubmessageHeartbeat &msg, const GuidPrefix_t &remotePrefix) override;
Expand All @@ -53,13 +53,9 @@ template <class NetworkDriver> class StatefulReaderT final : public Reader {

private:
Ip4Port_t m_srcPort; // TODO intended for reuse but buffer not used as such
NetworkDriver *m_transport;
EsppTransport *m_transport;
};

using StatefulReader = StatefulReaderT<EsppTransport>;

} // namespace rtps

#include "StatefulReader.tpp"

#endif // RTPS_STATEFULREADER_H
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ namespace rtps {

class EsppTransport;

template <class NetworkDriver> class StatefulWriterT final : public Writer {
class StatefulWriter final : public Writer {
public:
StatefulWriterT()
StatefulWriter()
: m_transport(nullptr) {}
~StatefulWriterT() override;
bool init(TopicData attributes, TopicKind_t topicKind, NetworkDriver &driver,
~StatefulWriter() override;
bool init(TopicData attributes, TopicKind_t topicKind, EsppTransport &driver,
bool enfUnicast = false);

//! Executes required steps like sending packets. Intended to be called by
Expand Down Expand Up @@ -76,7 +76,7 @@ template <class NetworkDriver> class StatefulWriterT final : public Writer {
void updateChangeKind(SequenceNumber_t &sequence_number);

private:
NetworkDriver *m_transport = nullptr;
EsppTransport *m_transport = nullptr;

HistoryCacheWithDeletion<Config::HISTORY_SIZE_STATEFUL> m_history;

Expand All @@ -103,9 +103,6 @@ template <class NetworkDriver> class StatefulWriterT final : public Writer {
const SequenceNumber_t &nextValid);
};

using StatefulWriter = StatefulWriterT<EsppTransport>;
} // namespace rtps

#include "StatefulWriter.tpp"

#endif // RTPS_STATEFULWRITER_H
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ namespace rtps {

class EsppTransport;

template <typename NetworkDriver> class StatelessWriterT : public Writer {
class StatelessWriter : public Writer {
public:
StatelessWriterT()
StatelessWriter()
: m_transport(nullptr) {}
~StatelessWriterT() override;
bool init(TopicData attributes, TopicKind_t topicKind, NetworkDriver &driver,
~StatelessWriter() override;
bool init(TopicData attributes, TopicKind_t topicKind, EsppTransport &driver,
bool enfUnicast = false);

void progress() override;
Expand All @@ -55,15 +55,11 @@ template <typename NetworkDriver> class StatelessWriterT : public Writer {
void reset() override;

private:
NetworkDriver *m_transport;
EsppTransport *m_transport;

SimpleHistoryCache<Config::HISTORY_SIZE_STATELESS> m_history;
};

using StatelessWriter = StatelessWriterT<EsppTransport>;

} // namespace rtps

#include "StatelessWriter.tpp"

#endif // RTPS_RTPSWRITER_H
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Author: i11 - Embedded Software, RWTH Aachen University
*/

#include "rtps/entities/StatefulReader.hpp"
#include "rtps/communication/EsppTransport.hpp"
#include "rtps/messages/MessageFactory.hpp"
#include "rtps/storages/PayloadBuffer.hpp"
#include "rtps/utils/Diagnostics.hpp"
Expand All @@ -45,16 +46,15 @@ using rtps::PacketInfo;
using rtps::ReaderCacheChange;
using rtps::SequenceNumber_t;
using rtps::SequenceNumberSet;
using rtps::StatefulReaderT;
using rtps::StatefulReader;
using rtps::SubmessageGap;
using rtps::SubmessageHeartbeat;
using rtps::TopicData;
using rtps::WriterProxy;

template <class NetworkDriver> StatefulReaderT<NetworkDriver>::~StatefulReaderT() {}
StatefulReader::~StatefulReader() {}

template <class NetworkDriver>
bool StatefulReaderT<NetworkDriver>::init(const TopicData &attributes, NetworkDriver &driver) {
bool StatefulReader::init(const TopicData &attributes, EsppTransport &driver) {
if (!initMutex()) {
return false;
}
Expand All @@ -67,8 +67,7 @@ bool StatefulReaderT<NetworkDriver>::init(const TopicData &attributes, NetworkDr
return true;
}

template <class NetworkDriver>
void StatefulReaderT<NetworkDriver>::newChange(const ReaderCacheChange &cacheChange) {
void StatefulReader::newChange(const ReaderCacheChange &cacheChange) {
if (m_callback_count == 0 || !m_is_initialized_) {
return;
}
Expand Down Expand Up @@ -96,17 +95,14 @@ void StatefulReaderT<NetworkDriver>::newChange(const ReaderCacheChange &cacheCha
}
}

template <class NetworkDriver>
bool StatefulReaderT<NetworkDriver>::addNewMatchedWriter(const WriterProxy &newProxy) {
bool StatefulReader::addNewMatchedWriter(const WriterProxy &newProxy) {
#if SFR_VERBOSE && RTPS_GLOBAL_VERBOSE
SFR_LOG("New writer added");
#endif
return m_proxies.add(newProxy);
}

template <class NetworkDriver>
bool StatefulReaderT<NetworkDriver>::onNewGapMessage(const SubmessageGap &msg,
const GuidPrefix_t &remotePrefix) {
bool StatefulReader::onNewGapMessage(const SubmessageGap &msg, const GuidPrefix_t &remotePrefix) {
std::lock_guard<std::recursive_mutex> lock(m_proxies_mutex);
if (!m_is_initialized_) {
return false;
Expand Down Expand Up @@ -204,9 +200,8 @@ bool StatefulReaderT<NetworkDriver>::onNewGapMessage(const SubmessageGap &msg,
}
}

template <class NetworkDriver>
bool StatefulReaderT<NetworkDriver>::onNewHeartbeat(const SubmessageHeartbeat &msg,
const GuidPrefix_t &sourceGuidPrefix) {
bool StatefulReader::onNewHeartbeat(const SubmessageHeartbeat &msg,
const GuidPrefix_t &sourceGuidPrefix) {
std::lock_guard<std::recursive_mutex> lock(m_proxies_mutex);
if (!m_is_initialized_) {
return false;
Expand Down Expand Up @@ -251,8 +246,7 @@ bool StatefulReaderT<NetworkDriver>::onNewHeartbeat(const SubmessageHeartbeat &m
return true;
}

template <class NetworkDriver>
bool StatefulReaderT<NetworkDriver>::sendPreemptiveAckNack(const WriterProxy &writer) {
bool StatefulReader::sendPreemptiveAckNack(const WriterProxy &writer) {
std::lock_guard<std::recursive_mutex> lock(m_proxies_mutex);
if (!m_is_initialized_) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Author: i11 - Embedded Software, RWTH Aachen University
*/

#include "rtps/entities/StatefulWriter.hpp"
#include "rtps/communication/EsppTransport.hpp"
#include "rtps/messages/MessageFactory.hpp"
#include "rtps/messages/MessageTypes.hpp"
#include "rtps/storages/PayloadBuffer.hpp"
Expand All @@ -39,7 +40,7 @@ using rtps::CacheChange;
using rtps::GuidPrefix_t;
using rtps::ReaderProxy;
using rtps::SequenceNumber_t;
using rtps::StatefulWriterT;
using rtps::StatefulWriter;
using rtps::SubmessageAckNack;

#if SFW_VERBOSE && RTPS_GLOBAL_VERBOSE
Expand All @@ -51,12 +52,10 @@ using rtps::SubmessageAckNack;
} while (0)
#endif

template <class NetworkDriver> StatefulWriterT<NetworkDriver>::~StatefulWriterT() = default;
StatefulWriter::~StatefulWriter() = default;

template <class NetworkDriver>
bool StatefulWriterT<NetworkDriver>::init(TopicData attributes, TopicKind_t topicKind,
NetworkDriver &driver,
bool enfUnicast) {
bool StatefulWriter::init(TopicData attributes, TopicKind_t topicKind, EsppTransport &driver,
bool enfUnicast) {

m_attributes = attributes;

Expand All @@ -81,15 +80,14 @@ bool StatefulWriterT<NetworkDriver>::init(TopicData attributes, TopicKind_t topi
return true;
}

template <class NetworkDriver> void StatefulWriterT<NetworkDriver>::reset() {
void StatefulWriter::reset() {
m_is_initialized_ = false;
// TODO
}

template <class NetworkDriver>
const rtps::CacheChange *
StatefulWriterT<NetworkDriver>::newChange(ChangeKind_t kind, const uint8_t *data, DataSize_t size,
bool inLineQoS, bool markDisposedAfterWrite) {
const rtps::CacheChange *StatefulWriter::newChange(ChangeKind_t kind, const uint8_t *data,
DataSize_t size, bool inLineQoS,
bool markDisposedAfterWrite) {
INIT_GUARD()
if (isIrrelevant(kind)) {
return nullptr;
Expand Down Expand Up @@ -129,7 +127,7 @@ StatefulWriterT<NetworkDriver>::newChange(ChangeKind_t kind, const uint8_t *data
return result;
}

template <class NetworkDriver> void StatefulWriterT<NetworkDriver>::progress() {
void StatefulWriter::progress() {
INIT_GUARD()
std::lock_guard<std::recursive_mutex> lock(m_mutex);
CacheChange *next = m_history.getChangeBySN(m_nextSequenceNumberToSend);
Expand Down Expand Up @@ -177,7 +175,7 @@ template <class NetworkDriver> void StatefulWriterT<NetworkDriver>::progress() {
}
}

template <class NetworkDriver> void StatefulWriterT<NetworkDriver>::setAllChangesToUnsent() {
void StatefulWriter::setAllChangesToUnsent() {
INIT_GUARD()
std::lock_guard<std::recursive_mutex> lock(m_mutex);

Expand All @@ -197,9 +195,8 @@ template <class NetworkDriver> void StatefulWriterT<NetworkDriver>::setAllChange
}
}

template <class NetworkDriver>
void StatefulWriterT<NetworkDriver>::onNewAckNack(const SubmessageAckNack &msg,
const GuidPrefix_t &sourceGuidPrefix) {
void StatefulWriter::onNewAckNack(const SubmessageAckNack &msg,
const GuidPrefix_t &sourceGuidPrefix) {
INIT_GUARD()
std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (!m_is_initialized_) {
Expand Down Expand Up @@ -301,14 +298,12 @@ void StatefulWriterT<NetworkDriver>::onNewAckNack(const SubmessageAckNack &msg,
}
}

template <class NetworkDriver>
bool rtps::StatefulWriterT<NetworkDriver>::removeFromHistory(const SequenceNumber_t &s) {
bool rtps::StatefulWriter::removeFromHistory(const SequenceNumber_t &s) {
std::lock_guard<std::recursive_mutex> lock(m_mutex);
return m_history.dropChange(s);
}

template <class NetworkDriver>
bool StatefulWriterT<NetworkDriver>::sendData(const ReaderProxy &reader, const CacheChange *next) {
bool StatefulWriter::sendData(const ReaderProxy &reader, const CacheChange *next) {
INIT_GUARD()
// TODO smarter packaging, e.g. create a message struct and serialize once.

Expand Down Expand Up @@ -337,10 +332,8 @@ bool StatefulWriterT<NetworkDriver>::sendData(const ReaderProxy &reader, const C
return true;
}

template <class NetworkDriver>
void StatefulWriterT<NetworkDriver>::sendGap(const ReaderProxy &reader,
const SequenceNumber_t &firstMissing,
const SequenceNumber_t &nextValid) {
void StatefulWriter::sendGap(const ReaderProxy &reader, const SequenceNumber_t &firstMissing,
const SequenceNumber_t &nextValid) {
INIT_GUARD()
// TODO smarter packaging, e.g. create a message struct and serialize once.

Expand All @@ -366,9 +359,7 @@ void StatefulWriterT<NetworkDriver>::sendGap(const ReaderProxy &reader,
m_transport->sendPacket(info);
}

template <class NetworkDriver>
bool StatefulWriterT<NetworkDriver>::sendDataWRMulticast(const ReaderProxy &reader,
const CacheChange *next) {
bool StatefulWriter::sendDataWRMulticast(const ReaderProxy &reader, const CacheChange *next) {
INIT_GUARD()

if (reader.useMulticast || reader.suppressUnicast == false) {
Expand Down Expand Up @@ -409,9 +400,8 @@ bool StatefulWriterT<NetworkDriver>::sendDataWRMulticast(const ReaderProxy &read
return true;
}

template <class NetworkDriver>
std::chrono::steady_clock::time_point
StatefulWriterT<NetworkDriver>::heartbeatTick(std::chrono::steady_clock::time_point now) {
StatefulWriter::heartbeatTick(std::chrono::steady_clock::time_point now) {
if (!m_is_initialized_) {
// Not ticking: report a far-future deadline so the scheduler ignores us.
return now + std::chrono::hours(24);
Expand Down Expand Up @@ -439,7 +429,7 @@ StatefulWriterT<NetworkDriver>::heartbeatTick(std::chrono::steady_clock::time_po
return m_nextHeartbeat;
}

template <class NetworkDriver> void StatefulWriterT<NetworkDriver>::dropDisposeAfterWriteChanges() {
void StatefulWriter::dropDisposeAfterWriteChanges() {
SequenceNumber_t oldest_retained;
while (m_disposeWithDelay.peakFirst(oldest_retained)) {

Expand Down Expand Up @@ -472,7 +462,7 @@ template <class NetworkDriver> void StatefulWriterT<NetworkDriver>::dropDisposeA
}
}

template <class NetworkDriver> void StatefulWriterT<NetworkDriver>::sendHeartBeat() {
void StatefulWriter::sendHeartBeat() {
INIT_GUARD()
if (m_proxies.isEmpty() || !m_is_initialized_) {

Expand Down
Loading