From fe694190104d16837750091ecaef42eb74e9a97b Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Wed, 23 Apr 2025 17:50:40 +0200 Subject: [PATCH] Binary msg sending fix --- Messages/BinaryMsg.cpp | 4 +++- Participants/ParticipantUDP.cpp | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Messages/BinaryMsg.cpp b/Messages/BinaryMsg.cpp index d04ac2d..c831753 100644 --- a/Messages/BinaryMsg.cpp +++ b/Messages/BinaryMsg.cpp @@ -6,7 +6,7 @@ BinaryMsg::BinaryMsg(unsigned char networkId, Thing* thing) { this->networkId = networkId; this->thingId = thing->id; this->thing = thing; - unsigned char ix = BinaryMsg::length; + unsigned char ix = 0; //BinaryMsg::length; this->data = new char[255]; this->dataLength = this->thing->GenerateBinary(this->data, &ix); } @@ -41,6 +41,8 @@ unsigned char BinaryMsg::Serialize(char* buffer) { buffer[ix++] = this->networkId; buffer[ix++] = this->thingId; buffer[ix++] = this->dataLength; + for (int dataIx = 0; dataIx < this->dataLength; dataIx++) + buffer[ix++] = this->data[dataIx]; return this->length + this->dataLength; } diff --git a/Participants/ParticipantUDP.cpp b/Participants/ParticipantUDP.cpp index efe27d2..247b7c9 100644 --- a/Participants/ParticipantUDP.cpp +++ b/Participants/ParticipantUDP.cpp @@ -474,7 +474,7 @@ void ParticipantUDP::Process(Participant* sender, PoseMsg* msg) { void ParticipantUDP::Process(Participant* sender, BinaryMsg* msg) { #if defined(DEBUG) std::cout << this->name << ": process BinaryMsg [" << (int)msg->networkId - << "/" << (int)msg->thingId << "] "; + << "/" << (int)msg->thingId << "]\n"; #endif Participant* owner = Participant::GetParticipant(msg->networkId); @@ -489,9 +489,6 @@ void ParticipantUDP::Process(Participant* sender, BinaryMsg* msg) { << (int)msg->thingId << "]"; #endif } -#if defined(DEBUG) - std::cout << std::endl; -#endif #endif } }