ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
Accessing numeric-addressed registers without a map file

During firmware development one might need to access registers without having a map file.

This is only supported by backends based on the NumericAddressedBackend: the PcieBackend, the RebotBackend and the DummyBackend. The access can be realised through specifying the register address and length in a special register name. Inside the C++ code, the NumericAddress::BAR constant can be used. This notation can be used in any context where a RegisterPath name is expected. Outside C++, e.g. when using the command line tools, a "#" character has to be used instead of the BAR constant, e.g.: #/0/32*4

// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
// SPDX-License-Identifier: LGPL-3.0-or-later
#include <ChimeraTK/Device.h>
#include <ChimeraTK/NumericAddress.h>
#include <iostream>
/*
* When you are doing numerical addressing you usually don't have a map file
* yet. You directly open the device (pcie for instance) with the URI syntax
* which you usually put into the dmap file. In this example, the map file is
* only needed to tell the dummy what to simulate. In the code the map file
* information is not used since the numeric address is directly written in the
* code. Otherwise, the example is identical to "basic.cpp". Look there for
* additional documentation.
*/
int main() {
/*
* If you have the mtcadummy driver installed you can also use a pci device:
* myDevice("(pci:pcieunidummys6)");
*
* Note: The dummy always needs a map file to know the size of the address
* space to emulate.
*/
ChimeraTK::Device myDevice("(dummy?map=my_device.map)");
myDevice.open();
/*
* Here, the register is accessed by its numeric address through a special
* register path name. The first component is a constant defining that a
* numeric address will follow ("BAR"). The second component is the bar number
* (here 0), the third component is the address in bytes (here 32) and the
* optional register length in bytes (here 4, which is the default). This
* address matches the address of the register
* TEMPERATURE_CONTROLLER.SET_POINT in the map file.
*
* When using numeric addresses directly, no fixed point conversion is
* performed.
*/
myDevice.getScalarRegisterAccessor<int>(ChimeraTK::numeric_address::BAR() / 0 / 32 * 4);
temperatureSetPoint.read();
std::cout << "Current temperature set point is " << temperatureSetPoint << std::endl;
temperatureSetPoint += 15;
std::cout << "Temperature set point changed to " << temperatureSetPoint << std::endl;
temperatureSetPoint.write();
myDevice.close();
return 0;
}
int main()
Class allows to read/write registers from device.
Definition Device.h:39
Accessor class to read and write scalar registers transparently by using the accessor object like a v...
bool write(ChimeraTK::VersionNumber versionNumber={})
Write the data to device.
void read()
Read the data from the device.
RegisterPath BAR()
The numeric_address::BAR() function can be used to directly access registers by numeric addresses,...