2#include <bits/stdc++.h>
13 const std::string &connectionId) {
14 uhal::ConnectionManager connectionMgr(connectionFilePath);
16 new uhal::HwInterface(connectionMgr.getDevice(connectionId));
46 uhal::ValWord<uint32_t> lReg = lNode.read();
49 std::cerr <<
"Error: Register read failed." << std::endl;
52 result = lReg.value();
80 std::vector<uint32_t> &results,
81 const uint32_t &aSize) {
83 uhal::ValVector<uint32_t> lReg = lNode.readBlock(aSize);
86 std::cerr <<
"Error: Register read failed." << std::endl;
90 copy(lReg.begin(), lReg.end(), back_inserter(results));
103 const std::vector<uint32_t> values) {
105 lNode.writeBlock(values);
118 const std::string &connectionId) {
119 static IpBusImpl _self(connectionFilePath, connectionId);
129 if (level ==
"Debug") {
130 uhal::setLogLevelTo(uhal::Debug());
131 }
else if (level ==
"Info") {
132 uhal::setLogLevelTo(uhal::Info());
133 }
else if (level ==
"Notice") {
134 uhal::setLogLevelTo(uhal::Notice());
135 }
else if (level ==
"Warning") {
136 uhal::setLogLevelTo(uhal::Warning());
137 }
else if (level ==
"Error") {
138 uhal::setLogLevelTo(uhal::Error());
139 }
else if (level ==
"Fatal") {
140 uhal::setLogLevelTo(uhal::Fatal());
142 std::cerr <<
"Invalid log level. Use Debug, Info, Notice, Warning, "
143 <<
"Error, or Fatal." << std::endl;
144 uhal::setLogLevelTo(uhal::Info());
158 }
catch (
const std::exception& e) {
159 std::cerr <<
"Error closing connection: " << e.what() << std::endl;
bool writeBlock(const std::string &nodeId, const std::vector< uint32_t > values)
Writes a block of data to a block of registers or a block-write port.
~IpBusImpl()
Destructor of IpBusImpl.
uint32_t getSize(const std::string &nodeId) const
Computes the node size.
bool readBlock(const std::string &nodeId, std::vector< uint32_t > &results, const uint32_t &aSize)
Reads a block of data from a block of registers or a block-read port.
IpBusImpl(const std::string &connectionFilePath, const std::string &connectionId)
Constructor of IpBusImpl.
bool read(const std::string &nodeId, uint32_t &res)
Reads a register using the uHAL library.
static IpBusImpl * pipbus_createSocket(const std::string &connectionFilePath, const std::string &connectionId)
Creates an IpBusImpl instance.
uhal::HwInterface * hardwareInterface
bool write(const std::string &nodeId, const uint32_t values)
Writes a register using the uHAL library.
void close()
Close the IpBusImpl connection.
static void setLogLevelTo(const std::string level)
Sets the uHAL log level to the given level.