rohdeschwarz  0.2.0
TCPIP socket library for Rohde & Schwarz instrument control
Typedefs | Functions | Variables
main.cpp File Reference

rohdeschwarz::busses::socket::Socket example More...

#include "rohdeschwarz/busses.hpp"
#include <iostream>
#include <string>

Go to the source code of this file.

Typedefs

using Socket = rohdeschwarz::busses::Socket
 

Functions

int main ()
 

Variables

const char * HOST = "localhost"
 
const int PORT = 5025
 

Detailed Description

rohdeschwarz::busses::socket::Socket example

This example demonstrates basic use of the rohdeschwarz::busses::socket::Socket class.

// rohdeschwarz
// std lib
#include <iostream>
int main()
{
// connect to instrument
Instrument instrument;
if (instrument.openTcp("localhost"))
{
// connected
// get id
const auto id = rohdeschwarz::trim(instrument.id());
// print for debug
#ifndef NDEBUG
std::cout << "connected: " << id << std::endl;
#endif
}
else
{
// connection failed
// print for debug
#ifndef NDEBUG
std::cout << "error: connection to localhost failed" << std::endl;
#endif
}
return 0;
} // main
Object-oriented R&S Instrument control.
Definition: instrument.hpp:53
std::string id()
Queries instrument ID string.
Definition: instrument.cpp:256
bool openTcp(std::string host, unsigned int timeout_ms=2000)
Open tcp socket connection to an instrument.
Definition: instrument.cpp:57
void main()
Definition: main.cpp:19
rohdeschwarz helper function definition
rohdeschwarz::instruments::Instrument definition
boost::system::system_error system_error
System error exception.
Definition: socket.hpp:32
std::string trim(const std::string &text)
Trims whitespace beginning and end of string.
Definition: helpers.cpp:56
rohdeschwarz::busses::socket::Socket class definition
rohdeschwarz::busses::socket::system_error system_error
Definition: main.cpp:15
rohdeschwarz::instruments::Instrument Instrument
Definition: main.cpp:16

Definition in file main.cpp.

Typedef Documentation

◆ Socket

using Socket = rohdeschwarz::busses::Socket

Definition at line 13 of file main.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 26 of file main.cpp.

Variable Documentation

◆ HOST

const char* HOST = "localhost"

Definition at line 22 of file main.cpp.

◆ PORT

const int PORT = 5025

Definition at line 23 of file main.cpp.