Skip to content
Snippets Groups Projects
Commit 3b8da250 authored by Querejeta Lomas, Leire's avatar Querejeta Lomas, Leire
Browse files

Subir nuevo archivo

parent 28b34696
No related branches found
No related tags found
No related merge requests found
/**
* @file class_client_example.cpp
* @author Alfonso Dominguez <alfonso.dominguez@tecnalia.com>
* @date 2020
*
* Copyright 2020 Tecnalia Research & Innovation.
* Distributed under the GNU GPL v3.
* For full terms see https://www.gnu.org/licenses/gpl.txt
*
* @brief CLASS client for testing purposes
*/
#include <string>
#include <communication/udp_client.hpp>
#include <iostream>
#include <boost/chrono.hpp>
#include <boost/thread/thread.hpp>
int main(int argc, char* argv[])
{
if (argc != 4)
{
std::cerr << "ERROR: Executable expects 3 arguments (IP and port where the server is listening) and port where the client will wait for server msgs"<< std::endl;
std::cerr << "Usage: ./class_client <server_host> <server_port> <local_port>" << std::endl;
return 1;
}
UDPClient client(argv[1], argv[2], -1);
std::string local_port = argv[3];
std::stringstream ss;
ss << "connect " << local_port;
std::string msg = ss.str();
client.send(msg);
int numberLoopMax = 10;
int numberLoop = 0;
std::cout << "Wait for 10 secs and then disconnect" << std::endl;
client.send("iam DESKTOP\r\n");
client.send("firmware ?\r\n");
//client.send("device ?\r\n");
client.send("acq config *freq 250.0 *channels 2 *type monopolar\r\n");
client.send("acq stream on\r\n");
client.send("acq on\r\n");
while (numberLoop < numberLoopMax)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
numberLoop += 1;
std::cout << numberLoop << " sec(s)" << std::endl;
}
client.send("acq off\r\n");
ss.str(std::string());
ss << "disconnect " << local_port;
msg = ss.str();
client.send(msg);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment