#include "Helper.h"
#include <wzcpp/features/utils.h>
#include <iostream>
#include <memory>
using namespace wz::baos::ip;
namespace
{
{
std::cout.fill('0');
std::cout << std::hex << std::uppercase;
for (auto& item : parameterBytes)
{
std::cout << std::setw(2) << static_cast<int>(item) << " ";
}
std::cout << std::nouppercase << std::dec;
}
}
int main(int argc, char* argv[])
{
try
{
std::cout << "******************************************" << std::endl;
std::cout << "GetParamterByte sample" << std::endl;
std::cout << "******************************************" << std::endl;
std::cout << std::endl;
CommandLineOptions options;
options.parse(argc, argv);
if (options.wasHelpdisplayed())
{
return 0;
}
const std::string ipAddress = options.getIpAddress();
std::cout << " Connection requested for " << ipAddress << std::endl;
BaosTcpConnection connection;
connection.open(ipAddress);
std::cout << "Reading parameter byte 1:" << std::endl;
auto parameterByte = connection.getParameterByte(1);
if (parameterByte.has_value())
{
std::cout << "Parameter data (1): " << std::setw(2) << static_cast<int>(*parameterByte) << std::endl;
}
std::cout << std::endl;
std::cout << "Reading parameter byte 12:" << std::endl;
parameterByte = connection.getParameterByte(12);
if (parameterByte.has_value())
{
std::cout << "Parameter data (12): " << std::setw(2) << static_cast<int>(*parameterByte) << std::endl;
}
std::cout << std::endl;
std::cout << "Reading parameter bytes 2 - 5:" << std::endl;
traceParameterBytes(parameterBytes);
std::cout << std::endl << std::endl;
std::cout << "Reading parameter bytes 11 - 60:" << std::endl;
parameterBytes = connection.getParameterBytes(11, 50);
traceParameterBytes(parameterBytes);
std::cout << std::endl << std::endl;
}
catch (const std::exception& e)
{
std::cerr << "Failed: " << e.what() << std::endl;
return -1;
}
return 0;
}
Specialization for a TCP IP v4 BAOSConnection.
Global BAOS protocol defines and types.
Global BAOS SDK function and options.
Groups BAOS binary protocol specific types , defines and classes for Indications, Responses etc.
Definition: Defines.h:32
std::vector< std::uint8_t > ParameterBytes
Strong type for a list of parameter bytes.
Definition: Defines.h:616
Global BAOS sdk namespace.
Definition: config.h:62
void setBaosLogLevel(wzcpp::LogLevel level)