From a4732fd7694949e0bc3d6bd7872ff1fcaa883e25 Mon Sep 17 00:00:00 2001 From: sumolx Date: Thu, 4 Jul 2024 11:04:56 -0400 Subject: [PATCH 1/3] Logging framework can now be adapted to alternative frameworks. --- include/rtps/discovery/SPDPAgent.h | 4 +- include/rtps/entities/StatefulReader.tpp | 25 ++++----- include/rtps/entities/StatefulWriter.tpp | 10 ++-- include/rtps/entities/StatelessWriter.tpp | 4 +- .../storages/ThreadSafeCircularBuffer.tpp | 2 + include/rtps/utils/Log.h | 45 ++++++++++------ include/rtps/utils/printutils.h | 29 ---------- include/rtps/utils/strutils.h | 40 ++++++++++++++ src/ThreadPool.cpp | 4 +- src/communication/UdpDriver.cpp | 53 ++++++++++++++++--- src/discovery/SEDPAgent.cpp | 2 + src/entities/Domain.cpp | 2 + src/entities/Participant.cpp | 2 + src/entities/Reader.cpp | 6 +-- src/entities/StatelessReader.cpp | 10 ++-- src/entities/Writer.cpp | 5 +- src/messages/MessageReceiver.cpp | 22 ++++---- src/storages/PBufWrapper.cpp | 4 +- 18 files changed, 180 insertions(+), 89 deletions(-) delete mode 100644 include/rtps/utils/printutils.h create mode 100644 include/rtps/utils/strutils.h diff --git a/include/rtps/discovery/SPDPAgent.h b/include/rtps/discovery/SPDPAgent.h index 183fb22e..c7c8d17d 100644 --- a/include/rtps/discovery/SPDPAgent.h +++ b/include/rtps/discovery/SPDPAgent.h @@ -34,13 +34,15 @@ Author: i11 - Embedded Software, RWTH Aachen University #include "ucdr/microcdr.h" #if SPDP_VERBOSE && RTPS_GLOBAL_VERBOSE -#include "rtps/utils/printutils.h" +#ifndef SPDP_LOG +#include "rtps/utils/strutils.h" #define SPDP_LOG(...) \ if (true) { \ printf("[SPDP] "); \ printf(__VA_ARGS__); \ printf("\r\n"); \ } +#endif #else #define SPDP_LOG(...) // #endif diff --git a/include/rtps/entities/StatefulReader.tpp b/include/rtps/entities/StatefulReader.tpp index 5f576e5f..149939e4 100644 --- a/include/rtps/entities/StatefulReader.tpp +++ b/include/rtps/entities/StatefulReader.tpp @@ -31,13 +31,15 @@ Author: i11 - Embedded Software, RWTH Aachen University #include "rtps/utils/Log.h" #if SFR_VERBOSE && RTPS_GLOBAL_VERBOSE -#include "rtps/utils/printutils.h" +#include "rtps/utils/strutils.h" +#ifndef SFR_LOG #define SFR_LOG(...) \ if (true) { \ printf("[StatefulReader %s] ", &m_attributes.topicName[0]); \ printf(__VA_ARGS__); \ printf("\r\n"); \ } +#endif #else #define SFR_LOG(...) // #endif @@ -102,9 +104,9 @@ template bool StatefulReaderT::addNewMatchedWriter( const WriterProxy &newProxy) { #if SFR_VERBOSE && RTPS_GLOBAL_VERBOSE - SFR_LOG("New writer added with id: "); - printGuid(newProxy.remoteWriterGuid); - SFR_LOG("\n"); + char buffer[64]; + guid2Str(newProxy.remoteWriterGuid, buffer, sizeof(buffer)); + SFR_LOG("New writer added with id: %s", buffer); #endif return m_proxies.add(newProxy); } @@ -124,12 +126,11 @@ bool StatefulReaderT::onNewGapMessage( WriterProxy *writer = getProxy(writerProxyGuid); if (writer == nullptr) { - #if SFR_VERBOSE && RTPS_GLOBAL_VERBOSE + char buffer[64]; + entityId2Str(msg.writerId, buffer, sizeof(buffer)); SFR_LOG("Ignore GAP. Couldn't find a matching " - "writer with id:"); - printEntityId(msg.writerId); - SFR_LOG("\n"); + "writer with id: %s", buffer); #endif return false; } @@ -203,6 +204,7 @@ bool StatefulReaderT::onNewGapMessage( } + return false; } } @@ -222,12 +224,11 @@ bool StatefulReaderT::onNewHeartbeat( WriterProxy *writer = getProxy(writerProxyGuid); if (writer == nullptr) { - #if SFR_VERBOSE && RTPS_GLOBAL_VERBOSE + char buffer[64]; + entityId2Str(msg.writerId, buffer, sizeof(buffer)); SFR_LOG("Ignore heartbeat. Couldn't find a matching " - "writer with id:"); - printEntityId(msg.writerId); - SFR_LOG("\n"); + "writer with id: %s", buffer); #endif return false; } diff --git a/include/rtps/entities/StatefulWriter.tpp b/include/rtps/entities/StatefulWriter.tpp index 93fb50dc..ffaf7cee 100644 --- a/include/rtps/entities/StatefulWriter.tpp +++ b/include/rtps/entities/StatefulWriter.tpp @@ -33,13 +33,15 @@ Author: i11 - Embedded Software, RWTH Aachen University using rtps::StatefulWriterT; #if SFW_VERBOSE && RTPS_GLOBAL_VERBOSE -#include "rtps/utils/printutils.h" +#include "rtps/utils/strutils.h" +#ifndef SFW_LOG #define SFW_LOG(...) \ if (true) { \ printf("[Stateful Writer %s] ", this->m_attributes.topicName); \ printf(__VA_ARGS__); \ printf("\r\n"); \ } +#endif #else #define SFW_LOG(...) // #endif @@ -239,9 +241,9 @@ void StatefulWriterT::onNewAckNack( if (reader == nullptr) { #if SFW_VERBOSE && RTPS_GLOBAL_VERBOSE - SFW_LOG("No proxy found with id: "); - printEntityId(msg.readerId); - SFW_LOG(" Dropping acknack.\n"); + char buffer[64]; + entityId2Str(msg.readerId, buffer, sizeof(buffer)); + SFW_LOG("No proxy found with id: %s Dropping acknack.", buffer); #endif return; } diff --git a/include/rtps/entities/StatelessWriter.tpp b/include/rtps/entities/StatelessWriter.tpp index bb4982e0..23dd42df 100644 --- a/include/rtps/entities/StatelessWriter.tpp +++ b/include/rtps/entities/StatelessWriter.tpp @@ -39,13 +39,15 @@ using rtps::SequenceNumber_t; using rtps::StatelessWriterT; #if SLW_VERBOSE && RTPS_GLOBAL_VERBOSE -#include "rtps/utils/printutils.h" +#ifndef SLW_LOG +#include "rtps/utils/strutils.h" #define SLW_LOG(...) \ if (true) { \ printf("[StatelessWriter %s] ", &this->m_attributes.topicName[0]); \ printf(__VA_ARGS__); \ printf("\n"); \ } +#endif #else #define SLW_LOG(...) // #endif diff --git a/include/rtps/storages/ThreadSafeCircularBuffer.tpp b/include/rtps/storages/ThreadSafeCircularBuffer.tpp index be1d7e84..57ea3109 100644 --- a/include/rtps/storages/ThreadSafeCircularBuffer.tpp +++ b/include/rtps/storages/ThreadSafeCircularBuffer.tpp @@ -6,12 +6,14 @@ #include "rtps/utils/Log.h" #if TSCB_VERBOSE && RTPS_GLOBAL_VERBOSE +#ifndef TSCB_LOG #define TSCB_LOG(...) \ if (true) { \ printf("[TSCircularBuffer] "); \ printf(__VA_ARGS__); \ printf("\n"); \ } +#endif #else #define TSCB_LOG(...) // #endif diff --git a/include/rtps/utils/Log.h b/include/rtps/utils/Log.h index 37e61b5c..5de99cb0 100644 --- a/include/rtps/utils/Log.h +++ b/include/rtps/utils/Log.h @@ -28,20 +28,35 @@ Author: i11 - Embedded Software, RWTH Aachen University #include #include -#define RTPS_GLOBAL_VERBOSE 0 - -#define SFW_VERBOSE 0 -#define SPDP_VERBOSE 0 -#define PBUF_WRAP_VERBOSE 0 -#define SEDP_VERBOSE 0 -#define RECV_VERBOSE 0 -#define PARTICIPANT_VERBOSE 0 -#define DOMAIN_VERBOSE 0 -#define UDP_DRIVER_VERBOSE 0 -#define TSCB_VERBOSE 0 -#define SLW_VERBOSE 0 -#define SFR_VERBOSE 0 -#define SLR_VERBOSE 0 -#define THREAD_POOL_VERBOSE 0 +#define RTPS_GLOBAL_VERBOSE 1 + +#define SFW_VERBOSE 1 +#define SPDP_VERBOSE 1 +#define PBUF_WRAP_VERBOSE 1 +#define SEDP_VERBOSE 1 +#define RECV_VERBOSE 1 +#define PARTICIPANT_VERBOSE 1 +#define DOMAIN_VERBOSE 1 +#define UDP_DRIVER_VERBOSE 1 +#define TSCB_VERBOSE 1 +#define SLW_VERBOSE 1 +#define SFR_VERBOSE 1 +#define SLR_VERBOSE 1 +#define THREAD_POOL_VERBOSE 1 +#define PRINTF printf + +#undef SFW_LOG +#undef SPDP_LOG +#undef PBUF_LOG +#undef SEDP_LOG +#undef RECV_LOG +#undef PARTICIPANT_LOG +#undef DOMAIN_LOG +#undef UDP_DRIVER_LOG +#undef TSCB_LOG +#undef SLW_LOG +#undef SFR_LOG +#undef SLR_LOG +#undef THREAD_POOL_LOG #endif // RTPS_LOG_H diff --git a/include/rtps/utils/printutils.h b/include/rtps/utils/printutils.h deleted file mode 100644 index 4d4d1bfa..00000000 --- a/include/rtps/utils/printutils.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// Created by andreas on 13.01.19. -// - -#ifndef RTPS_PRINTUTILS_H -#define RTPS_PRINTUTILS_H - -#include "rtps/common/types.h" - -inline void printEntityId(rtps::EntityId_t id) { - for (const auto byte : id.entityKey) { - printf("%x", (int)byte); - } - printf("%x", static_cast(id.entityKind)); -} - -inline void printGuidPrefix(rtps::GuidPrefix_t prefix) { - for (const auto byte : prefix.id) { - printf("%x", (int)byte); - } -} - -inline void printGuid(rtps::Guid_t guid) { - printGuidPrefix(guid.prefix); - printf(":"); - printEntityId(guid.entityId); -} - -#endif // RTPS_PRINTUTILS_H diff --git a/include/rtps/utils/strutils.h b/include/rtps/utils/strutils.h new file mode 100644 index 00000000..c705aed8 --- /dev/null +++ b/include/rtps/utils/strutils.h @@ -0,0 +1,40 @@ +// +// Created by andreas on 13.01.19. +// + +#ifndef RTPS_STRUTILS_H +#define RTPS_STRUTILS_H + +#include "rtps/common/types.h" + +inline int entityId2Str(rtps::EntityId_t id, char* str, size_t size) { + int bytes = 0; + for (const auto byte : id.entityKey) { + bytes += snprintf(&str[bytes], size - bytes, "%x", (int)byte); + } + bytes += + snprintf( + &str[bytes], + size - bytes, + "%x", + static_cast(id.entityKind) + ); + return bytes; +} + +inline int guidPrefix2Str(rtps::GuidPrefix_t prefix, char* str, size_t size) { + int bytes = 0; + for (const auto byte : prefix.id) { + bytes += snprintf(&str[bytes], size - bytes, "%x", (int)byte); + } + return bytes; +} + +inline int guid2Str(rtps::Guid_t guid, char* str, size_t size) { + int bytes = guidPrefix2Str(guid.prefix, str, size); + bytes += snprintf(&str[bytes], size - bytes, ":"); + bytes += entityId2Str(guid.entityId, &str[bytes], size - bytes); + return bytes; +} + +#endif // RTPS_STRUTILS_H diff --git a/src/ThreadPool.cpp b/src/ThreadPool.cpp index aca048b9..8ffb7962 100644 --- a/src/ThreadPool.cpp +++ b/src/ThreadPool.cpp @@ -34,13 +34,15 @@ Author: i11 - Embedded Software, RWTH Aachen University using rtps::ThreadPool; #if THREAD_POOL_VERBOSE && RTPS_GLOBAL_VERBOSE -#include "rtps/utils/printutils.h" +#ifndef THREAD_POOL_LOG +#include "rtps/utils/strutils.h" #define THREAD_POOL_LOG(...) \ if (true) { \ printf("[ThreadPool] "); \ printf(__VA_ARGS__); \ printf("\r\n"); \ } +#endif #else #define THREAD_POOL_LOG(...) // #endif diff --git a/src/communication/UdpDriver.cpp b/src/communication/UdpDriver.cpp index 32c2452f..e6c45b1a 100644 --- a/src/communication/UdpDriver.cpp +++ b/src/communication/UdpDriver.cpp @@ -30,16 +30,22 @@ Author: i11 - Embedded Software, RWTH Aachen University #include #include +#if PLATFORM_ESP32 +#include +#endif + using rtps::UdpDriver; #if UDP_DRIVER_VERBOSE && RTPS_GLOBAL_VERBOSE -#include "rtps/utils/printutils.h" +#ifndef UDP_DRIVER_LOG +#include "rtps/utils/strutils.h" #define UDP_DRIVER_LOG(...) \ if (true) { \ printf("[UDP Driver] "); \ printf(__VA_ARGS__); \ printf("\r\n"); \ } +#endif #else #define UDP_DRIVER_LOG(...) // #endif @@ -83,8 +89,13 @@ UdpDriver::createUdpConnection(Ip4Port_t receivePort) { } bool UdpDriver::isSameSubnet(ip4_addr_t addr) { +#if PLATFORM_ESP32 + return (ip4_addr_netcmp(&addr, &(netif_default->ip_addr.u_addr.ip4), + &(netif_default->netmask.u_addr.ip4)) != 0); +#else return (ip4_addr_netcmp(&addr, &(netif_default->ip_addr), &(netif_default->netmask)) != 0); +#endif } bool UdpDriver::isMulticastAddress(ip4_addr_t addr) { @@ -100,19 +111,37 @@ bool UdpDriver::joinMultiCastGroup(ip4_addr_t addr) const { { TcpipCoreLock lock; +#if PLATFORM_ESP32 + iret = igmp_joingroup(ip_2_ip4(IP_ADDR_ANY), (&addr)); +#else iret = igmp_joingroup(IP_ADDR_ANY, (&addr)); +#endif } if (iret != ERR_OK) { - +#if PLATFORM_ESP32 + ip_addr_t tmpAddr; + memcpy((char *)&tmpAddr.u_addr.ip4, (char *)&addr.addr, sizeof(ip4_addr)); + tmpAddr.type = IPADDR_TYPE_V4; + UDP_DRIVER_LOG("Failed to join IGMP multicast group %s\n", + ipaddr_ntoa(&tmpAddr)); +#else UDP_DRIVER_LOG("Failed to join IGMP multicast group %s\n", ipaddr_ntoa(&addr)); +#endif return false; } else { - +#if PLATFORM_ESP32 + ip_addr_t tmpAddr; + memcpy((char *)&tmpAddr.u_addr.ip4, (char *)&addr.addr, sizeof(ip4_addr)); + tmpAddr.type = IPADDR_TYPE_V4; + UDP_DRIVER_LOG("Succesfully joined IGMP multicast group %s\n", + ipaddr_ntoa(&tmpAddr)); +#else UDP_DRIVER_LOG("Succesfully joined IGMP multicast group %s\n", ipaddr_ntoa(&addr)); +#endif } return true; } @@ -122,15 +151,27 @@ bool UdpDriver::sendPacket(const UdpConnection &conn, ip4_addr_t &destAddr, err_t err; { TcpipCoreLock lock; +#if PLATFORM_ESP32 + ip_addr_t tmpAddr; + memcpy((char *)&tmpAddr.u_addr.ip4, (char *)&destAddr.addr, sizeof(ip4_addr)); + tmpAddr.type = IPADDR_TYPE_V4; + err = udp_sendto(conn.pcb, &buffer, &tmpAddr, destPort); +#else err = udp_sendto(conn.pcb, &buffer, &destAddr, destPort); +#endif } if (err != ERR_OK) { - ; - +#if PLATFORM_ESP32 + ip_addr_t tmpAddr; + memcpy((char *)&tmpAddr.u_addr.ip4, (char *)&destAddr.addr, sizeof(ip4_addr)); + tmpAddr.type = IPADDR_TYPE_V4; + UDP_DRIVER_LOG("UDP TRANSMIT NOT SUCCESSFUL %s:%u size: %u err: %i\n", + ipaddr_ntoa(&tmpAddr), destPort, buffer.tot_len, err); +#else UDP_DRIVER_LOG("UDP TRANSMIT NOT SUCCESSFUL %s:%u size: %u err: %i\n", ipaddr_ntoa(&destAddr), destPort, buffer.tot_len, err); - +#endif return false; } return true; diff --git a/src/discovery/SEDPAgent.cpp b/src/discovery/SEDPAgent.cpp index 000da101..b0130e7f 100644 --- a/src/discovery/SEDPAgent.cpp +++ b/src/discovery/SEDPAgent.cpp @@ -34,12 +34,14 @@ Author: i11 - Embedded Software, RWTH Aachen University using rtps::SEDPAgent; #if SEDP_VERBOSE && RTPS_GLOBAL_VERBOSE +#ifndef SEDP_LOG #define SEDP_LOG(...) \ if (true) { \ printf("[SEDP] "); \ printf(__VA_ARGS__); \ printf("\r\n"); \ } +#endif #else #define SEDP_LOG(...) // #endif diff --git a/src/entities/Domain.cpp b/src/entities/Domain.cpp index feeb4bfa..82fdac15 100644 --- a/src/entities/Domain.cpp +++ b/src/entities/Domain.cpp @@ -27,12 +27,14 @@ Author: i11 - Embedded Software, RWTH Aachen University #include "rtps/utils/udpUtils.h" #if DOMAIN_VERBOSE && RTPS_GLOBAL_VERBOSE +#ifndef DOMAIN_LOG #define DOMAIN_LOG(...) \ if (true) { \ printf("[Domain] "); \ printf(__VA_ARGS__); \ printf("\n"); \ } +#endif #else #define DOMAIN_LOG(...) // #endif diff --git a/src/entities/Participant.cpp b/src/entities/Participant.cpp index 4b305e8a..1bd60a75 100644 --- a/src/entities/Participant.cpp +++ b/src/entities/Participant.cpp @@ -30,12 +30,14 @@ Author: i11 - Embedded Software, RWTH Aachen University #include "rtps/utils/Log.h" #if PARTICIPANT_VERBOSE && RTPS_GLOBAL_VERBOSE +#ifndef PARTICIPANT_LOG #define PARTICIPANT_LOG(...) \ if (true) { \ printf("[Participant] "); \ printf(__VA_ARGS__); \ printf("\r\n"); \ } +#endif #else #define PARTICIPANT_LOG(...) // #endif diff --git a/src/entities/Reader.cpp b/src/entities/Reader.cpp index 911a8be4..87810ecd 100644 --- a/src/entities/Reader.cpp +++ b/src/entities/Reader.cpp @@ -133,9 +133,9 @@ bool Reader::removeProxy(const Guid_t &guid) { bool Reader::addNewMatchedWriter(const WriterProxy &newProxy) { Lock lock{m_proxies_mutex}; #if (SFR_VERBOSE || SLR_VERBOSE) && RTPS_GLOBAL_VERBOSE - SFR_LOG("New writer added with id: "); - printGuid(newProxy.remoteWriterGuid); - SFR_LOG("\n"); + char buffer[64]; + guid2Str(newProxy.remoteWriterGuid, buffer, sizeof(buffer)); + SFR_LOG("New writer added with id: %s", buffer); #endif return m_proxies.add(newProxy); } diff --git a/src/entities/StatelessReader.cpp b/src/entities/StatelessReader.cpp index 1fde550d..9a02b8d3 100644 --- a/src/entities/StatelessReader.cpp +++ b/src/entities/StatelessReader.cpp @@ -29,13 +29,15 @@ Author: i11 - Embedded Software, RWTH Aachen University using rtps::StatelessReader; #if SLR_VERBOSE && RTPS_GLOBAL_VERBOSE -#include "rtps/utils/printutils.h" +#include "rtps/utils/strutils.h" +#ifndef SLR_LOG #define SLR_LOG(...) \ if (true) { \ printf("[StatelessReader %s] ", &m_attributes.topicName[0]); \ printf(__VA_ARGS__); \ printf("\n"); \ } +#endif #else #define SLR_LOG(...) // #endif @@ -60,9 +62,9 @@ void StatelessReader::newChange(const ReaderCacheChange &cacheChange) { bool StatelessReader::addNewMatchedWriter(const WriterProxy &newProxy) { #if (SLR_VERBOSE && RTPS_GLOBAL_VERBOSE) - SLR_LOG("Adding WriterProxy"); - printGuid(newProxy.remoteWriterGuid); - printf("\n"); + char buffer[64]; + guid2Str(newProxy.remoteWriterGuid, buffer, sizeof(buffer)); + SLR_LOG("Adding WriterProxy: %s", buffer); #endif return m_proxies.add(newProxy); } diff --git a/src/entities/Writer.cpp b/src/entities/Writer.cpp index be21ffee..165d5512 100644 --- a/src/entities/Writer.cpp +++ b/src/entities/Writer.cpp @@ -10,8 +10,9 @@ using namespace rtps; bool rtps::Writer::addNewMatchedReader(const ReaderProxy &newProxy) { INIT_GUARD(); #if SFW_VERBOSE && RTPS_GLOBAL_VERBOSE - SFW_LOG("New reader added with id: "); - printGuid(newProxy.remoteReaderGuid); + char buffer[64]; + guid2Str(newProxy.remoteReaderGuid, buffer, sizeof(buffer)); + SFW_LOG("New reader added with id: %s", buffer); #endif Lock lock{m_mutex}; bool success = m_proxies.add(newProxy); diff --git a/src/messages/MessageReceiver.cpp b/src/messages/MessageReceiver.cpp index 589f2e7e..25c80c5b 100644 --- a/src/messages/MessageReceiver.cpp +++ b/src/messages/MessageReceiver.cpp @@ -33,13 +33,15 @@ Author: i11 - Embedded Software, RWTH Aachen University using rtps::MessageReceiver; #if RECV_VERBOSE && RTPS_GLOBAL_VERBOSE -#include "rtps/utils/printutils.h" +#ifndef RECV_LOG +#include "rtps/utils/strutils.h" #define RECV_LOG(...) \ if (true) { \ printf("[RECV] "); \ printf(__VA_ARGS__); \ printf("\n"); \ } +#endif #else #define RECV_LOG(...) // #endif @@ -153,9 +155,9 @@ bool MessageReceiver::processDataSubmessage( Reader *reader; if (dataSubmsg.readerId == ENTITYID_UNKNOWN) { #if RECV_VERBOSE && RTPS_GLOBAL_VERBOSE - RECV_LOG("Received ENTITYID_UNKNOWN readerID, searching for writer ID = "); - printGuid(Guid_t{sourceGuidPrefix, dataSubmsg.writerId}); - printf("\n"); + char buffer[64]; + guid2Str(Guid_t{sourceGuidPrefix, dataSubmsg.writerId}, buffer, sizeof(buffer)); + RECV_LOG("Received ENTITYID_UNKNOWN readerID, searching for writer ID = %s", buffer); #endif reader = mp_part->getReaderByWriterId( Guid_t{sourceGuidPrefix, dataSubmsg.writerId}); @@ -168,9 +170,9 @@ bool MessageReceiver::processDataSubmessage( Guid_t{sourceGuidPrefix, dataSubmsg.writerId}); if (reader_by_writer == nullptr && reader != nullptr) { - RECV_LOG("FOUND By READER ID, NOT BY WRITER ID ="); - printGuid(Guid_t{sourceGuidPrefix, dataSubmsg.writerId}); - printf("\n"); + char buffer[64]; + guid2Str(Guid_t{sourceGuidPrefix, dataSubmsg.writerId}, buffer, sizeof(buffer)); + RECV_LOG("FOUND By READER ID, NOT BY WRITER ID = %s", buffer); } #endif } @@ -181,9 +183,9 @@ bool MessageReceiver::processDataSubmessage( reader->newChange(change); } else { #if RECV_VERBOSE && RTPS_GLOBAL_VERBOSE - RECV_LOG("Couldn't find a reader with id: "); - printEntityId(dataSubmsg.readerId); - printf("\n"); + char buffer[64]; + entityId2Str(dataSubmsg.readerId, buffer, sizeof(buffer)); + RECV_LOG("Couldn't find a reader with id: %s", buffer); #endif } diff --git a/src/storages/PBufWrapper.cpp b/src/storages/PBufWrapper.cpp index c183f049..adce3c7d 100644 --- a/src/storages/PBufWrapper.cpp +++ b/src/storages/PBufWrapper.cpp @@ -31,13 +31,15 @@ Author: i11 - Embedded Software, RWTH Aachen University using rtps::PBufWrapper; #if PBUF_WRAP_VERBOSE && RTPS_GLOBAL_VERBOSE -#include "rtps/utils/printutils.h" +#ifndef PBUF_WRAP_LOG +#include "rtps/utils/strutils.h" #define PBUF_WRAP_LOG(...) \ if (true) { \ printf("[PBUF Wrapper] "); \ printf(__VA_ARGS__); \ printf("\n"); \ } +#endif #else #define PBUF_WRAP_LOG(...) // #endif From 26acea7830adaa84bea8d6969c7b043cf1e92866 Mon Sep 17 00:00:00 2001 From: sumolx Date: Thu, 4 Jul 2024 11:09:46 -0400 Subject: [PATCH 2/3] Fixed missing replacement of printGuidPrefix -> guidPrefix2Str --- src/discovery/SPDPAgent.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/discovery/SPDPAgent.cpp b/src/discovery/SPDPAgent.cpp index dabc5fc4..fa13a372 100644 --- a/src/discovery/SPDPAgent.cpp +++ b/src/discovery/SPDPAgent.cpp @@ -161,8 +161,9 @@ void SPDPAgent::processProxyData() { addProxiesForBuiltInEndpoints(); m_buildInEndpoints.spdpWriter->setAllChangesToUnsent(); #if SPDP_VERBOSE && RTPS_GLOBAL_VERBOSE - SPDP_LOG("Added new participant with guid: "); - printGuidPrefix(m_proxyDataBuffer.m_guid.prefix); + char buffer[64]; + guidPrefix2Str(m_proxyDataBuffer.m_guid.prefix, buffer, sizeof(buffer)); + SPDP_LOG("Added new participant with guid: %s", buffer); } else { SPDP_LOG("Failed to add new participant"); } From c8d58321646d8492da3b89eef2296782974833f9 Mon Sep 17 00:00:00 2001 From: sumolx Date: Thu, 4 Jul 2024 22:07:18 -0400 Subject: [PATCH 3/3] Disabled logging for PR --- include/rtps/utils/Log.h | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/include/rtps/utils/Log.h b/include/rtps/utils/Log.h index 5de99cb0..32a72a08 100644 --- a/include/rtps/utils/Log.h +++ b/include/rtps/utils/Log.h @@ -28,22 +28,21 @@ Author: i11 - Embedded Software, RWTH Aachen University #include #include -#define RTPS_GLOBAL_VERBOSE 1 - -#define SFW_VERBOSE 1 -#define SPDP_VERBOSE 1 -#define PBUF_WRAP_VERBOSE 1 -#define SEDP_VERBOSE 1 -#define RECV_VERBOSE 1 -#define PARTICIPANT_VERBOSE 1 -#define DOMAIN_VERBOSE 1 -#define UDP_DRIVER_VERBOSE 1 -#define TSCB_VERBOSE 1 -#define SLW_VERBOSE 1 -#define SFR_VERBOSE 1 -#define SLR_VERBOSE 1 -#define THREAD_POOL_VERBOSE 1 -#define PRINTF printf +#define RTPS_GLOBAL_VERBOSE 0 + +#define SFW_VERBOSE 0 +#define SPDP_VERBOSE 0 +#define PBUF_WRAP_VERBOSE 0 +#define SEDP_VERBOSE 0 +#define RECV_VERBOSE 0 +#define PARTICIPANT_VERBOSE 0 +#define DOMAIN_VERBOSE 0 +#define UDP_DRIVER_VERBOSE 0 +#define TSCB_VERBOSE 0 +#define SLW_VERBOSE 0 +#define SFR_VERBOSE 0 +#define SLR_VERBOSE 0 +#define THREAD_POOL_VERBOSE 0 #undef SFW_LOG #undef SPDP_LOG