μHAL (v2.8.22)
Part of the IPbus software repository
Loading...
Searching...
No Matches
cactus_pycohal.cpp
Go to the documentation of this file.
1
2// Boost includes
3#include "boost/lexical_cast.hpp"
4#include "boost/algorithm/string.hpp"
5
6// pybind11
7#include "pybind11/stl.h" // Automatically adds converters for STL collection/map classes
8#include "pybind11/pybind11.h"
9
10// uhal includes
16#include "uhal/ProtocolTCP.hpp"
17#include "uhal/ProtocolUDP.hpp"
18#include "uhal/SigBusGuard.hpp"
19#include "uhal/Node.hpp"
20#include "uhal/tests/tools.hpp"
21
22// pycohal includes
26
27
28namespace py = pybind11;
29
30
31namespace pycohal
32{
33 uint32_t defs_NOMASK()
34 {
35 return uhal::defs::NOMASK;
36 }
37
39 template<class T>
40 std::vector<T> copy_vector ( const std::vector<T>& aVec )
41 {
42 return std::vector<T> ( aVec );
43 }
44
46 template < class T >
47 std::vector<T> convert_string_to_vector ( const std::string& aString )
48 {
49 std::vector<std::string> sVec;
50 std::vector<T> result;
51
52 if ( ! aString.empty() )
53 {
54 boost::algorithm::split ( sVec, aString, boost::algorithm::is_any_of ( "," ) );
55 result.reserve ( sVec.size() );
56
57 for ( const auto& x: sVec )
58 {
59 result.push_back ( boost::lexical_cast<T> ( x ) );
60 }
61 }
62
63 return result;
64 }
65
66 template <>
67 std::vector<std::string> convert_string_to_vector ( const std::string& aString )
68 {
69 std::vector<std::string> result;
70
71 if ( ! aString.empty() )
72 {
73 boost::algorithm::split ( result, aString, boost::algorithm::is_any_of ( "," ) );
74 }
75
76 return result;
77 }
78
80#if PY_VERSION_HEX >= 0x03000000
81 bool test_check_uint32_argument ( uint32_t aUInt, const std::string& uIntString )
82#else
83 bool test_check_uint32_argument ( uint32_t aUInt, const py::bytes& uIntString )
84#endif
85 {
86 std::string stringFromUInt ( boost::lexical_cast<std::string> ( aUInt ) );
87 return ( stringFromUInt == std::string(uIntString) );
88 }
89
91 uint32_t test_convert_str_to_uint32 ( const std::string& uIntString )
92 {
93 return boost::lexical_cast<uint32_t> ( uIntString );
94 }
95
97 uhal::ValWord<uint32_t> get_dummy_ValWord(const uint32_t aValue, const bool aValid)
98 {
100 valWord.value( aValue );
101 valWord.valid( aValid );
102 return valWord;
103 }
104
105 // Internally creates instance of SigBusGuard class - used to verify that SIGBUS is automatically blocked when uhal loaded
107 {
108 const uhal::SigBusGuard lGuard;
109 }
110
112 void wrap_test_functions(py::module_& aModule)
113 {
114 py::module_ lSubModule = aModule.def_submodule("tests");
115
116 lSubModule.def ( "measureReadLatency", static_cast<double (*) ( uhal::ClientInterface&, uint32_t, uint32_t, size_t, bool, bool ) > ( &uhal::tests::measureReadLatency ) );
117 lSubModule.def ( "measureWriteLatency", static_cast<double (*) ( uhal::ClientInterface&, uint32_t, uint32_t, size_t, bool, bool ) > ( &uhal::tests::measureWriteLatency ) );
118 lSubModule.def ( "measureFileReadLatency", uhal::tests::measureFileReadLatency );
119 lSubModule.def ( "measureFileWriteLatency", uhal::tests::measureFileWriteLatency );
120 lSubModule.def ( "check_uint32_argument", pycohal::test_check_uint32_argument );
121 lSubModule.def ( "convert_str_to_uint32", pycohal::test_convert_str_to_uint32 );
122 lSubModule.def ( "convert_str_to_vec_str", pycohal::convert_string_to_vector<std::string> );
123 lSubModule.def ( "convert_str_to_vec_uint32", pycohal::convert_string_to_vector<uint32_t> );
124 lSubModule.def ( "copy_vec_uint32", pycohal::copy_vector<uint32_t> );
125 lSubModule.def ( "get_dummy_ValWord", pycohal::get_dummy_ValWord );
126
127 lSubModule.def ( "create_sigbus_guard", pycohal::create_sigbus_buard );
128 }
129
130
131 /* Typedefs for common return value policies */
133 const auto const_ref_return_policy = py::return_value_policy::copy;
137 const auto norm_ref_return_policy = py::return_value_policy::reference_internal;
138
140 std::shared_ptr<uhal::ClientInterface> buildClient(const std::string& aId, const std::string& aURI)
141 {
143 }
144
146 py::bytes hex_string ( const uhal::ValWord<uint32_t>& valWord )
147 {
148 std::ostringstream osstream;
149 osstream << "0x" << std::hex << valWord.value();
150 return osstream.str();
151 }
152
154 template <class T>
156 {
157 static const T& getItem ( const uhal::ValVector<T>& valVec, int i)
158 {
159 if (i >= int(valVec.size()))
160 throw py::index_error();
161
162 if (i < 0)
163 i += valVec.size();
164
165 if (i < 0)
166 throw py::index_error();
167
168 return valVec.at(i);
169 }
170
171 static std::vector<T> getSlice( const uhal::ValVector<T>& valVec, const py::slice aSlice )
172 {
173 size_t start, stop, step, slicelength;
174 if (!aSlice.compute(valVec.size(), &start, &stop, &step, &slicelength))
175 throw py::error_already_set();
176
177 std::vector<T> lSliced(slicelength);
178 for (size_t i = 0; i < slicelength; ++i) {
179 lSliced.at(i) = valVec.at(start);
180 start += step;
181 }
182 return lSliced;
183 }
184 };
185
186 std::string convert_to_string( const uhal::ValWord<uint32_t>& valWord )
187 {
188 return boost::lexical_cast<std::string>(valWord.value());
189 }
190
191 std::string convert_to_string ( const uhal::ValVector<uint32_t>& valVec )
192 {
193 std::ostringstream lStream;
194
195 lStream << "[";
196
197 for ( size_t i=0; i<valVec.size(); i++ )
198 {
199 lStream << valVec.at ( i );
200
201 if ( i!= ( valVec.size()-1 ) )
202 {
203 lStream << ", ";
204 }
205 }
206
207 lStream << "]";
208 return lStream.str();
209 }
210
211}//namespace pycohal
212
213
214
215inline py::object const& pass_through(py::object const& o)
216{
217 return o;
218}
219
221{
222 if ( aIt.next() )
223 return *aIt;
224
225 throw pybind11::stop_iteration();
226}
227
228
229// *** N.B: The argument of this BOOST_PYTHON_MODULE macro MUST be the same as the name of the library created, i.e. if creating library file my_py_binds_module.so , imported in python as:
230// import my_py_binds_module
231// then would have to put
232// BOOST_PYTHON_MODULE(my_py_binds_module)
233// Otherwise, will get the error message "ImportError: dynamic module does not define init function (initmy_py_binds_module)
235{
236 // Block SIGBUS, since required by SigBusGuard (used by mmap-based client)
238
239 m.def("NOMASK", pycohal::defs_NOMASK);
240
241 // ENUMS
243
244 // LOGGING FUNCTIONS
246
247 // EXCEPTIONS
249
250 // VERSION & BUILD INFO
252
253 // TEST FUNCTIONS
255
256 // Wrap uhal::ValHeader
257 py::class_<uhal::ValHeader>(m, "ValHeader")
258 .def (py::init< const uhal::ValHeader& >())
259 .def ( "valid", static_cast< bool ( uhal::ValHeader::* ) () > ( &uhal::ValHeader::valid ) )
260 ;
261
262 // Wrap uhal::ValWord<uint32_t>
263 py::class_<uhal::ValWord<uint32_t>>( m, "ValWord_uint32")
264 .def ( py::init<>() )
265 .def ( py::init< const uhal::ValWord<uint32_t>& >() )
266 .def ( "valid", static_cast< bool ( uhal::ValWord<uint32_t>::* ) () > ( &uhal::ValWord<uint32_t>::valid ) )
267 .def ( "value", static_cast< uint32_t ( uhal::ValWord<uint32_t>::* ) () const > ( &uhal::ValWord<uint32_t>::value ) )
268 .def ( "mask", static_cast< const uint32_t& ( uhal::ValWord<uint32_t>::* ) () const > ( &uhal::ValWord<uint32_t>::mask ) , pycohal::const_ref_return_policy )
269 .def ( "__str__", static_cast< std::string (*) ( const uhal::ValWord<uint32_t>& ) > ( &pycohal::convert_to_string ) )
270 .def ( "__int__", static_cast< uint32_t ( uhal::ValWord<uint32_t>::* ) () const> ( &uhal::ValWord<uint32_t>::value ) )
271#if PY_VERSION_HEX >= 0x03000000
272 .def ( "__index__", static_cast< uint32_t ( uhal::ValWord<uint32_t>::* ) () const> ( &uhal::ValWord<uint32_t>::value ) )
273#else
274 .def ( "__hex__", pycohal::hex_string )
275#endif
276 ;
277
278 // Wrap uhal::ValVector<uint32_t>
279 py::class_<uhal::ValVector<uint32_t>>(m, "ValVector_uint32", py::buffer_protocol())
280 .def ( py::init<>() )
281 .def ( py::init< const uhal::ValVector<uint32_t>& >() )
282 .def ( "valid", static_cast< bool ( uhal::ValVector<uint32_t>::* ) () > ( &uhal::ValVector<uint32_t>::valid ) )
283 .def ( "value", static_cast< std::vector<uint32_t> ( uhal::ValVector<uint32_t>::* ) () const > ( &uhal::ValVector<uint32_t>::value ) )
284 .def ( "size", &uhal::ValVector<uint32_t>::size )
286 .def ( "__str__", static_cast< std::string (*) ( const uhal::ValVector<uint32_t>& ) > ( &pycohal::convert_to_string ) )
287 .def ( "__len__", &uhal::ValVector<uint32_t>::size )
290 .def ( "__iter__", [](const uhal::ValVector<uint32_t>& v) { return py::make_iterator ( v.begin() , v.end() ); })
291 .def_buffer([](uhal::ValVector<uint32_t> &v) -> py::buffer_info {
292 const uint32_t* lData(v.valid() ? v.data() : nullptr);
293 if (lData == nullptr) {
294 return py::buffer_info();
295 }
296 return py::buffer_info(
297 lData, /* Pointer to buffer */
298 v.size(), /* Buffer size */
299 true /* Read-only */
300 );
301 })
302 ;
303
304 // Wrap uhal::Node
305 py::class_<uhal::Node>(m, "Node")
306 .def ( "hasNode", &uhal::Node::hasNode )
307 .def ( "getNode", static_cast<const uhal::Node& ( uhal::Node::* ) ( const std::string& ) const>( &uhal::Node::getNode ), pycohal::norm_ref_return_policy )
308 .def ( "getNodes", static_cast<std::vector<std::string> ( uhal::Node::* ) ( const std::string& ) const>(&uhal::Node::getNodes) )
309 .def ( "getNodes", static_cast<std::vector<std::string> ( uhal::Node::* ) () const>(&uhal::Node::getNodes) )
311 .def ( "getPath", &uhal::Node::getPath )
322 .def ( "write", &uhal::Node::write )
323 .def ( "writeBlock", &uhal::Node::writeBlock )
324 .def ( "writeBlockOffset",&uhal::Node::writeBlockOffset )
325 .def ( "read", &uhal::Node::read )
326 .def ( "readBlock", &uhal::Node::readBlock )
327 .def ( "readBlockOffset", &uhal::Node::readBlockOffset )
329 .def ( "__iter__", [](uhal::Node& n) { return py::make_iterator(n.begin(), n.end()); }, py::keep_alive<0, 1>())
331 ;
332
333 py::class_< uhal::Node::const_iterator >(m, "NodeConstIterator")
336 ;
337
338 // Wrap uhal::ClientInterface
339 py::class_<uhal::ClientInterface, std::shared_ptr<uhal::ClientInterface>>(m, "ClientInterface")
342 .def ( "write", static_cast<uhal::ValHeader ( uhal::ClientInterface::* ) ( const uint32_t&, const uint32_t& )> ( &uhal::ClientInterface::write ) )
343 .def ( "write", static_cast<uhal::ValHeader ( uhal::ClientInterface::* ) ( const uint32_t&, const uint32_t&, const uint32_t& )> ( &uhal::ClientInterface::write ) )
344 .def ( "read", static_cast<uhal::ValWord<uint32_t> ( uhal::ClientInterface::* ) ( const uint32_t& )> ( &uhal::ClientInterface::read) )
345 .def ( "read", static_cast<uhal::ValWord<uint32_t> ( uhal::ClientInterface::* ) ( const uint32_t&, const uint32_t& )> ( &uhal::ClientInterface::read ) )
346 .def ( "writeBlock", [](uhal::ClientInterface& c, const uint32_t& a, const std::vector< uint32_t >& v) { return c.writeBlock(a, v); } )
347 .def ( "writeBlock", static_cast<uhal::ValHeader ( uhal::ClientInterface::* ) ( const uint32_t&, const std::vector< uint32_t >& , const uhal::defs::BlockReadWriteMode&)>( &uhal::ClientInterface::writeBlock ) )
348 .def ( "readBlock", [](uhal::ClientInterface& c, const uint32_t& a, const uint32_t x) { return c.readBlock(a, x); } )
349 .def ( "readBlock", static_cast<uhal::ValVector<uint32_t> ( uhal::ClientInterface::* ) ( const uint32_t&, const uint32_t&, const uhal::defs::BlockReadWriteMode& )>( &uhal::ClientInterface::readBlock ) )
350 .def ( "rmw_bits", &uhal::ClientInterface::rmw_bits )
351 .def ( "rmw_sum", &uhal::ClientInterface::rmw_sum )
352 .def ( "dispatch", &uhal::ClientInterface::dispatch )
353 .def ( "setTimeoutPeriod", &uhal::ClientInterface::setTimeoutPeriod )
354 .def ( "getTimeoutPeriod", &uhal::ClientInterface::getTimeoutPeriod )
356 ;
357
358 py::class_<uhal::IPbusCore, uhal::ClientInterface, std::shared_ptr<uhal::IPbusCore>>(m, "IPbusCore")
359 .def ( "readConfigurationSpace", static_cast<uhal::ValWord<uint32_t> ( uhal::IPbusCore::* ) ( const uint32_t& )>(&uhal::IPbusCore::readConfigurationSpace))
360 .def ( "readConfigurationSpace", static_cast<uhal::ValWord<uint32_t> ( uhal::IPbusCore::* ) ( const uint32_t&, const uint32_t& )>(&uhal::IPbusCore::readConfigurationSpace))
361 ;
362
363 py::class_<uhal::UDP<uhal::IPbus<1, 3>>, uhal::IPbusCore, std::shared_ptr<uhal::UDP<uhal::IPbus<1, 3>>>>(m, "_UDP_IPbus_1_3");
364 py::class_<uhal::UDP<uhal::IPbus<2, 0>>, uhal::IPbusCore, std::shared_ptr<uhal::UDP<uhal::IPbus<2, 0>>>>(m, "_UDP_IPbus_2_0");
365
366 py::class_<uhal::TCP<uhal::IPbus<1, 3>, 1>, uhal::IPbusCore, std::shared_ptr<uhal::TCP<uhal::IPbus<1, 3>, 1>>>(m, "_TCP_IPbus_1_3");
367 py::class_<uhal::TCP<uhal::IPbus<2, 0>, 1>, uhal::IPbusCore, std::shared_ptr<uhal::TCP<uhal::IPbus<2, 0>, 1>>>(m, "_TCP_IPbus_2_0");
368
369 py::class_<uhal::TCP<uhal::ControlHub<uhal::IPbus<1, 3> >, 3>, uhal::IPbusCore, std::shared_ptr<uhal::TCP<uhal::ControlHub<uhal::IPbus<1, 3> >, 3>>>(m, "_TCP_ControlHub_IPbus_1_3");
370 py::class_<uhal::TCP<uhal::ControlHub<uhal::IPbus<2, 0>>, 3>, uhal::IPbusCore, std::shared_ptr<uhal::TCP<uhal::ControlHub<uhal::IPbus<2, 0> >, 3>>>(m, "_TCP_ControlHub_IPbus_2_0");
371
372 m.def ( "buildClient", pycohal::buildClient );
373
374 // Wrap uhal::HwInterface
375 py::class_<uhal::HwInterface> (m, "HwInterface")
376 .def ( py::init<const uhal::HwInterface&>() )
380 .def ( "dispatch", &uhal::HwInterface::dispatch )
381 .def ( "setTimeoutPeriod", &uhal::HwInterface::setTimeoutPeriod )
382 .def ( "getTimeoutPeriod", &uhal::HwInterface::getTimeoutPeriod )
383 .def ( "hasNode", &uhal::HwInterface::hasNode )
384 .def ( "getNode", static_cast< const uhal::Node& ( uhal::HwInterface::* ) () const > ( &uhal::HwInterface::getNode ), pycohal::norm_ref_return_policy )
385 .def ( "getNode", static_cast< const uhal::Node& ( uhal::HwInterface::* ) ( const std::string& ) const > ( &uhal::HwInterface::getNode ), pycohal::norm_ref_return_policy )
386 .def ( "getNodes", static_cast< std::vector<std::string> ( uhal::HwInterface::* ) () const > ( &uhal::HwInterface::getNodes ) )
387 .def ( "getNodes", static_cast< std::vector<std::string> ( uhal::HwInterface::* ) ( const std::string& ) const > ( &uhal::HwInterface::getNodes ) )
389 ;
390
391 // Wrap uhal::ConnectionManager
392 py::class_< uhal::ConnectionManager > (m, "ConnectionManager")
393 .def ( py::init<const std::string&>() )
394 .def ( py::init<const std::string&, const std::vector<std::string>&>() )
395 .def ( "getDevice", static_cast< uhal::HwInterface ( uhal::ConnectionManager::* ) ( const std::string& ) > ( &uhal::ConnectionManager::getDevice ) )
396 .def ( "getDevices", static_cast< std::vector<std::string> ( uhal::ConnectionManager::* ) () const > ( &uhal::ConnectionManager::getDevices ) )
397 .def ( "getDevices", static_cast< std::vector<std::string> ( uhal::ConnectionManager::* ) ( const std::string& ) const > ( &uhal::ConnectionManager::getDevices ) )
398 .def_static ( "clearAddressFileCache", &uhal::ConnectionManager::clearAddressFileCache )
399 ;
400
401 m.def ( "getDevice", static_cast<uhal::HwInterface (* ) ( const std::string&, const std::string&, const std::string& ) > ( &uhal::ConnectionManager::getDevice ) );
402 m.def ( "getDevice", static_cast<uhal::HwInterface (* ) ( const std::string&, const std::string&, const std::string&, const std::vector<std::string>& ) > ( &uhal::ConnectionManager::getDevice ) );
403}
404
const uhal::Node & NextNodeConstIterator(uhal::Node::const_iterator &aIt)
py::object const & pass_through(py::object const &o)
static ClientFactory & getInstance()
Static method to retrieve the single instance of the class.
std::shared_ptr< ClientInterface > getClient(const std::string &aId, const std::string &aUri)
Construct an IPbus client based on the protocol identifier specified.
An abstract base class for defining the interface to the various IPbus clients as well as providing t...
ValHeader write(const uint32_t &aAddr, const uint32_t &aValue)
Write a single, unmasked word to a register.
ValHeader writeBlock(const uint32_t &aAddr, const std::vector< uint32_t > &aValues, const defs::BlockReadWriteMode &aMode=defs::INCREMENTAL)
Write a block of data to a block of registers or a block-write port.
void dispatch()
Method to dispatch all queued transactions, and wait until all corresponding responses have been rece...
void setTimeoutPeriod(const uint32_t &aTimeoutPeriod=0)
A method to modify the timeout period for any pending or future transactions.
ValWord< uint32_t > rmw_bits(const uint32_t &aAddr, const uint32_t &aANDterm, const uint32_t &aORterm)
Read the value of a register, apply the AND-term, apply the OR-term, set the register to this new val...
ValWord< uint32_t > rmw_sum(const uint32_t &aAddr, const int32_t &aAddend)
Read the value of a register, add the addend, set the register to this new value and return a copy of...
ValVector< uint32_t > readBlock(const uint32_t &aAddr, const uint32_t &aSize, const defs::BlockReadWriteMode &aMode=defs::INCREMENTAL)
Read a block of unsigned data from a block of registers or a block-read port.
ValWord< uint32_t > read(const uint32_t &aAddr)
Read a single, unmasked, unsigned word.
const std::string & id() const
Return the identifier of the target for this client.
const std::string & uri() const
Return the url of the target for this client.
uint64_t getTimeoutPeriod()
A method to retrieve the timeout period currently being used.
A class to open and manage XML connection files and wrap up the interfaces to the NodeTreeBuilder and...
static void clearAddressFileCache()
Clears cache of Node tree structure for previously-opened address files (thread safe)
std::vector< std::string > getDevices() const
Return all device IDs known to this connection manager.
HwInterface getDevice(const std::string &aId)
Retrieves protocol, host, and port from the connection file to create an IPbus Client Retrieves the a...
A class which bundles a node tree and an IPbus client interface together providing everything you nee...
Definition: HwInterface.hpp:56
std::vector< std::string > getNodes() const
Return all node IDs known to this HwInterface.
const Node & getNode() const
Retrieve the top-level node.
const std::string & id() const
Return the identifier of the target for this client.
void dispatch()
Make the IPbus client issue a dispatch.
ClientInterface & getClient()
Get the underlying IPbus client.
Definition: HwInterface.cpp:78
bool hasNode(const std::string &aId) const
uint32_t getTimeoutPeriod()
A method to retrieve the timeout period currently being used.
const std::string & uri() const
Return the url of the target for this client.
void setTimeoutPeriod(const uint32_t &aTimeoutPeriod)
A method to modify the timeout period for any pending or future transactions.
A class providing the core IPbus packing functionality.
ValWord< uint32_t > readConfigurationSpace(const uint32_t &aAddr)
Read a single, unmasked, unsigned word from the configuration address space.
A heirarchical node for navigating heirarchical firmwares.
Definition: Node.hpp:85
ClientInterface & getClient() const
Get the underlying IPbus client.
Definition: Node.cpp:701
const defs::NodePermission & getPermission() const
Return the read/write access permissions of this node.
Definition: Node.cpp:280
const std::unordered_map< std::string, std::string > & getFirmwareInfo() const
Return parameters for inferring the VHDL address decoding.
Definition: Node.cpp:310
ValWord< uint32_t > read() const
Read a single, unmasked, unsigned word.
Definition: Node.cpp:611
const uint32_t & getMask() const
Return the mask to be applied if this node is a sub-field, rather than an entire register.
Definition: Node.cpp:262
const std::string & getId() const
Return the unique ID of the current node.
Definition: Node.cpp:191
ValHeader writeBlockOffset(const std::vector< uint32_t > &aValues, const uint32_t &aOffset) const
Write a block of data to a block of registers or a block-write port.
Definition: Node.cpp:573
const std::unordered_map< std::string, std::string > & getParameters() const
Return parameters of the current node.
Definition: Node.cpp:304
const Node & getNode(const std::string &aId) const
Retrieve the Node given by a full-stop delimeted name path relative, to the current node.
Definition: Node.cpp:441
const defs::BlockReadWriteMode & getMode() const
Return whether the node represents a single register, a block of registers or a block-read/write port...
Definition: Node.cpp:268
std::string getPath() const
Return the full path to the current node.
Definition: Node.cpp:197
ValHeader writeBlock(const std::vector< uint32_t > &aValues) const
Write a block of data to a block of registers or a block-write port.
Definition: Node.cpp:542
ValVector< uint32_t > readBlockOffset(const uint32_t &aSize, const uint32_t &aOffset) const
Read a block of unsigned data from a block of registers or a block-read port.
Definition: Node.cpp:663
ValHeader write(const uint32_t &aValue) const
Write a single, unmasked word to a register.
Definition: Node.cpp:516
const uint32_t & getAddress() const
Return the register address with which this node is associated.
Definition: Node.cpp:256
const std::string & getDescription() const
Return the optional description string which the user can specify for the current node.
Definition: Node.cpp:292
const_iterator end() const
Definition: Node.cpp:176
const uint32_t & getSize() const
Return the maximum size available to a block read/write.
Definition: Node.cpp:274
std::vector< std::string > getNodes() const
Return all node IDs known to this HwInterface.
Definition: Node.cpp:478
const std::string & getTags() const
Return the optional tags string which the user can specify for the current node.
Definition: Node.cpp:286
const_iterator begin() const
Definition: Node.cpp:170
const std::string & getModule() const
Return the name of the module in which the current node resides.
Definition: Node.cpp:298
ValVector< uint32_t > readBlock(const uint32_t &aSize) const
Read a block of unsigned data from a block of registers or a block-read port.
Definition: Node.cpp:632
bool hasNode(const std::string &aId) const
Definition: Node.cpp:411
static void blockSIGBUS()
A class which wraps a single word of data and marks whether or not it is valid.
Definition: ValMem.hpp:147
bool valid()
Return whether the Validated memory is marked as valid.
Definition: ValMem.cpp:77
A class which wraps a block of data and marks whether or not it is valid.
Definition: ValMem.hpp:273
const_iterator begin() const
If the memory has previously been marked as valid, return a const iterator to the beginning of the un...
Definition: ValMem.cpp:311
const T * data() const
Return the address of the underlying memory.
Definition: ValMem.cpp:287
bool valid()
Return whether the Validated memory is marked as valid.
Definition: ValMem.cpp:217
const T & at(std::size_t aIndex) const
If the memory has previously been marked as valid, give random access into memory.
Definition: ValMem.cpp:264
const_iterator end() const
If the memory has previously been marked as valid, return a const iterator to the end (one past last ...
Definition: ValMem.cpp:327
std::size_t size() const
Return the size of the underlying memory.
Definition: ValMem.cpp:280
A class which wraps a single word of data and marks whether or not it is valid.
Definition: ValMem.hpp:189
T value() const
Return the value of the validated memory with check on validity.
Definition: ValMem.cpp:141
bool valid()
Return whether the Validated memory is marked as valid.
Definition: ValMem.cpp:112
uint32_t test_convert_str_to_uint32(const std::string &uIntString)
Converts string argument to uint32_t, and returns this value. Used in tests to check that uint32 retu...
void wrap_enums(pybind11::module_ &)
bool test_check_uint32_argument(uint32_t aUInt, const py::bytes &uIntString)
Returns whether uint32 and string arguments represent the same nubmer. Used in tests to check that ui...
std::vector< T > copy_vector(const std::vector< T > &aVec)
Trivial function that returns copy of vector argument in order to test vector to/from list converters...
std::string convert_to_string(const uhal::ValWord< uint32_t > &valWord)
std::shared_ptr< uhal::ClientInterface > buildClient(const std::string &aId, const std::string &aURI)
Constructs a ClientInterface using the ClientFactory.
void wrap_version_and_build_info(pybind11::module_ &)
Definition: version.cpp:36
void wrap_test_functions(py::module_ &aModule)
Wraps functions that are only sed in unti tests. Puts them in "tests" sub-module.
uint32_t defs_NOMASK()
void wrap_logging_functions(pybind11::module_ &)
uhal::ValWord< uint32_t > get_dummy_ValWord(const uint32_t aValue, const bool aValid)
Returns dummy ValWord instance for testing.
void create_sigbus_buard()
const auto const_ref_return_policy
Default return value policy for const references returned attribute 'getter' methods.
std::vector< T > convert_string_to_vector(const std::string &aString)
Returns vector, generated from splitting string argument using "," as delimeter, and converting strin...
void wrap_exceptions(pybind11::module_ &)
Wraps all uHAL exceptions (i.e. creates corresponding Python classes, and regsiters appropriate excep...
Definition: exceptions.cpp:17
py::bytes hex_string(const uhal::ValWord< uint32_t > &valWord)
Returns hex string for ValWord<uint32_t> value.
const auto norm_ref_return_policy
Return value policy for internal references.
BlockReadWriteMode
define whether transactions target a single register, a block of registers, a block-read/write port o...
Definition: definitions.hpp:53
const uint32_t NOMASK
define what it means to have no mask
Definition: definitions.hpp:56
double measureFileWriteLatency(const std::string &aFilePath, uint32_t aBaseAddr, uint32_t aDepth, size_t aNrIterations, bool aVerbose)
Definition: tools.cpp:170
double measureReadLatency(ClientInterface &aClient, uint32_t aBaseAddr, uint32_t aDepth, size_t aNrIterations, bool aDispatchEachIteration, bool aVerbose)
Definition: tools.cpp:68
double measureFileReadLatency(const std::string &aFilePath, uint32_t aBaseAddr, uint32_t aDepth, size_t aNrIterations, bool aVerbose)
Definition: tools.cpp:145
double measureWriteLatency(ClientInterface &aClient, uint32_t aBaseAddr, uint32_t aDepth, size_t aNrIterations, bool aDispatchEachIteration, bool aVerbose)
Definition: tools.cpp:105
#define PYBIND11_MODULE(name, variable)
\rst This macro creates the entry point that will be invoked when the Python interpreter imports an e...
Definition: common.h:440
Struct containing wrapper functions for list-like indexing of ValVector<uint32_t> in python.
static std::vector< T > getSlice(const uhal::ValVector< T > &valVec, const py::slice aSlice)
static const T & getItem(const uhal::ValVector< T > &valVec, int i)