- Author
- Pascal JEAN, aka epsilonrt
- Copyright
- GNU Lesser General Public License
#include <csignal>
#include <thread>
#include <iostream>
#include <modbuspp.h>
using namespace std;
cout <<
"Receive message, size : " << req->
aduSize() << endl;
if (req->
function() == ReadInputRegisters) {
static uint16_t dummy = 1;
for (uint16_t i = 0; i < N; i++) {
}
}
return 0;
}
void
sighandler (int sig) {
cout << "everything was closed." << endl << "Have a nice day !" << endl;
exit (EXIT_SUCCESS);
}
int main (int argc, char **argv) {
if (argc < 2) {
cerr << "Error: the JSON filename must be provided as a parameter on the command line !" << endl;
cerr << "e.g. : " << argv[0] << " virtual-server-tcp.json" << endl;
exit (EXIT_FAILURE);
}
string jsonfile = argv[1];
cout << "Callback Server" << endl;
signal (SIGINT, sighandler);
signal (SIGTERM, sighandler);
cout << "Press CTRL+C to stop... " << endl << endl;
try {
cout << "opening " << jsonfile << "..." << endl;
cout << "Listening server on " <<
std::this_thread::sleep_for (std::chrono::milliseconds (200));
}
}
}
catch (std::exception & e) {
cerr << "Error: " << e.what() << endl;
}
catch (...) {
cerr << "Unattended exception !" << endl;
}
return EXIT_FAILURE;
}