Skip to content
Snippets Groups Projects

Usability gemrpc updates

Merged Laurent Petre requested to merge feature/gemrpc-updates into main
Files
3
@@ -2,12 +2,30 @@
#include <xhal/client/XHALInterface.h>
#include <regex>
#include <string>
xhal::client::XHALInterface::XHALInterface(const std::string& board_url, log4cplus::Logger& logger)
: m_board_url(board_url)
, m_logger(logger)
{
// Split the URL into hostname and port
std::regex re("([^:]+)(?::([0-9]+))?");
std::smatch m;
if (!std::regex_match(board_url, m, re))
throw std::runtime_error("Invalid board URL: " + board_url);
// First capture group -> hostname
const std::string board_hostname = m[1].str();
// Second capture group -> port
short board_port = 9811;
if (m[2].matched)
board_port = std::stoi(m[2].str());
try {
m_rpc.connect(board_url);
m_rpc.connect(board_hostname, board_port);
XHAL_INFO("Connected to " << m_board_url);
} catch (wisc::RPCSvc::ConnectionFailedException& e) {
XHAL_ERROR("Caught RPCErrorException: " << e.message.data());
Loading