Skip to content
1 change: 1 addition & 0 deletions configfiles/Dummy/ToolChainConfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ mon_port 5000 # remote multicast port to send monitoring messa
multicast_send_period 5000 # logging & monitoring messages will be sent as a batch once per this period
alarm_cooldown_ms 1000 # alarms with the same device and message will be limited to this rate
mon_merge_period 5000 # monitoring messages with the same device and subject will be limited to this rate
MTU 1500 # MTU of interface used for logging/monitoring

##### Tools To Add #####
Tools_File configfiles/Dummy/ToolsConfig # list of tools to run and their config files
Expand Down
1 change: 1 addition & 0 deletions configfiles/template/ToolChainConfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ mon_port 5000 # remote multicast port to send monitoring messa
multicast_send_period 5000 # logging & monitoring messages will be sent as a batch once per this period
alarm_cooldown_ms 1000 # alarms with the same device and message will be limited to this rate
mon_merge_period 5000 # monitoring messages with the same device and subject will be limited to this rate
MTU 1500 # MTU of interface used for logging/monitoring

##### Tools To Add #####
Tools_File configfiles/ToolsConfig # list of tools to run and their config files
Expand Down
41 changes: 28 additions & 13 deletions src/RemoteControl/RemoteControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "ServiceDiscovery.h"
#include "zmq.hpp"
#include <zstd.h>
#include "zstd_helpers.h"

#include <boost/uuid/uuid.hpp> // uuid class
#include <boost/uuid/uuid_generators.hpp> // generators
Expand All @@ -18,9 +20,13 @@
#define GROUP_COMMAND_REPLY_WAIT 2000
#define FILE_SEND_WAIT 120000
#define FILE_SEND_PORT 24001
#define MAX_DECOMPRESSED_SIZE 655355
const unsigned char ZSTD_MAGIC_BYTES[4] = {0x28,0xB5,0x2F,0xFD}; // ZSTD_MAGICNUMBER from zstd.h BUT REVERSED!

using namespace ToolFramework;

bool ZstdDecompress(ZSTD_DCtx* zstd_dctx, char* msg, uint64_t msgsize, std::string& decompress_buffer);

int main(int argc, char** argv){

// if (argc!=3) return 1;
Expand All @@ -30,6 +36,7 @@ int main(int argc, char** argv){


zmq::context_t context(3);
ZSTD_DCtx* zstd_dctx = ZSTD_createDCtx();

//std::string address(argv[1]);
// std::stringstream tmp (argv[2]);
Expand Down Expand Up @@ -236,14 +243,17 @@ int main(int argc, char** argv){

zmq::message_t receive;
if(ServiceSend.recv(&receive)){
std::istringstream iss(static_cast<char*>(receive.data()));

std::string answer;
answer=iss.str();
if(!ZstdDecompress(zstd_dctx, (char*)receive.data(), receive.size(), answer)){
std::cerr<<"failed to decompress reply!: "<<answer<<std::endl;

} else {
Store rr;
rr.JsonParser(answer);
if(rr.Get<std::string>("msg_type")=="Command Reply") std::cout<<std::endl<<rr.Get<std::string>("msg_value")<<std::endl<<std::endl;

}

Store rr;
rr.JsonParser(answer);
if(rr.Get<std::string>("msg_type")=="Command Reply") std::cout<<std::endl<<(rr.Get<std::string>("msg_value"))<<std::endl<<std::endl;
}
else std::cout<<std::endl<<"message timed out"<<std::endl;

Expand Down Expand Up @@ -364,15 +374,18 @@ int main(int argc, char** argv){

zmq::message_t receive;
if(ServiceSend.recv(&receive)){
std::istringstream iss(static_cast<char*>(receive.data()));

std::string answer;
answer=iss.str();

Store rr;
rr.JsonParser(answer);
if(rr.Get<std::string>("msg_type")=="Command Reply") std::cout<<std::endl<<rr.Get<std::string>("msg_value")<<std::endl<<std::endl;
if(!ZstdDecompress(zstd_dctx, (char*)receive.data(), receive.size(), answer)){
std::cerr<<"failed to decompress reply!"<<std::endl;

} else {
Store rr;
rr.JsonParser(answer);
if(rr.Get<std::string>("msg_type")=="Command Reply") std::cout<<std::endl<<rr.Get<std::string>("msg_value")<<std::endl<<std::endl;

}
}

}
}

Expand All @@ -392,3 +405,5 @@ int main(int argc, char** argv){
return 0;

}


Loading
Loading