Skip to content

Commit 4c04299

Browse files
committed
[dma] Add a firmware check for the DMA channels
1 parent ba5bf11 commit 4c04299

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

include/ReadoutCard/Parameters.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ class Parameters
122122
/// Type for the GBT enabled parameter
123123
using GbtEnabledType = bool;
124124

125+
/// Type for the GBT enabled parameter
126+
using FirmwareCheckEnabledType = bool;
127+
125128
/// Type for the ONU address parameter
126129
using OnuAddressType = Hex::type;
127130

@@ -203,6 +206,14 @@ class Parameters
203206
/// \return Reference to this object for chaining calls
204207
auto setGbtEnabled(GbtEnabledType value) -> Parameters&;
205208

209+
/// Sets the FirmwareCheckEnabled parameter
210+
///
211+
/// If enabled the Firmware check is enforced.
212+
///
213+
/// \param value The value to set
214+
/// \return Reference to this object for chaining calls
215+
auto setFirmwareCheckEnabled(FirmwareCheckEnabledType value) -> Parameters&;
216+
206217
/// Sets the UserLogicEnabled parameter
207218
///
208219
/// If enabled the User Logic is used.
@@ -395,6 +406,10 @@ class Parameters
395406
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
396407
auto getGbtEnabled() const -> boost::optional<GbtEnabledType>;
397408

409+
/// Gets the FirmwareCheckEnabled parameter
410+
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
411+
auto getFirmwareCheckEnabled() const -> boost::optional<FirmwareCheckEnabledType>;
412+
398413
/// Gets the UserLogicEnabled parameter
399414
/// \return The value wrapped in an optional if it is present, or an empty optional if it was not
400415
auto getUserLogicEnabled() const -> boost::optional<UserLogicEnabledType>;
@@ -488,6 +503,11 @@ class Parameters
488503
/// \return The value
489504
auto getGbtEnabledRequired() const -> GbtEnabledType;
490505

506+
/// Gets the FirmwareCheckEnabled parameter
507+
/// \exception ParameterException The parameter was not present
508+
/// \return The value
509+
auto getFirmwareCheckEnabledRequired() const -> FirmwareCheckEnabledType;
510+
491511
/// Gets the UserLogicEnabled parameter
492512
/// \exception ParameterException The parameter was not present
493513
/// \return The value

src/CommandLineUtilities/ProgramDmaBench.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ class ProgramDmaBench : public Program
201201
options.add_options()("to-file-bin",
202202
po::value<std::string>(&mOptions.fileOutputPathBin),
203203
"Read out to given file in binary format (only contains raw data from pages)");
204+
options.add_options()("bypass-fw-check",
205+
po::bool_switch(&mOptions.bypassFirmwareCheck),
206+
"Flag to bypass the firmware checker");
204207
}
205208

206209
virtual void run(const po::variables_map& map)
@@ -223,6 +226,7 @@ class ProgramDmaBench : public Program
223226
auto params = Parameters::makeParameters(cardId, mOptions.dmaChannel);
224227
params.setDmaPageSize(mOptions.dmaPageSize);
225228
params.setDataSource(DataSource::fromString(mOptions.dataSourceString));
229+
params.setFirmwareCheckEnabled(!mOptions.bypassFirmwareCheck);
226230

227231
mDataSource = params.getDataSourceRequired();
228232

@@ -1105,6 +1109,7 @@ class ProgramDmaBench : public Program
11051109
size_t maxRdhPacketCounter;
11061110
bool stbrd = false;
11071111
bool byteCountEnabled = false;
1112+
bool bypassFirmwareCheck = false;
11081113
} mOptions;
11091114

11101115
/// The DMA channel

src/DmaChannelBase.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
//#include "ChannelPaths.h"
2121
#include "Common/System.h"
2222
#include "Pda/Util.h"
23+
#include "ReadoutCard/FirmwareChecker.h"
2324
#include "Utilities/SmartPointer.h"
2425
#include "Visitor.h"
2526

@@ -59,6 +60,13 @@ DmaChannelBase::DmaChannelBase(CardDescriptor cardDescriptor, Parameters& parame
5960
// Check the channel number is allowed
6061
checkChannelNumber(allowedChannels);
6162

63+
// Check that the firmware is compatible with the software
64+
auto parameters2 = parameters;
65+
parameters2.setChannelNumber(2);
66+
if (parameters.getFirmwareCheckEnabled().get_value_or(true)) {
67+
FirmwareChecker().checkFirmwareCompatibility(parameters2);
68+
}
69+
6270
// Do some basic Parameters validity checks
6371
//checkParameters(parameters);
6472

src/Parameters.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ _PARAMETER_FUNCTIONS(LinkLoopbackEnabled, "link_loopback_enabled")
133133
_PARAMETER_FUNCTIONS(PonUpstreamEnabled, "pon_upstream_enabled")
134134
_PARAMETER_FUNCTIONS(DynamicOffsetEnabled, "dynamic_offset_enabled")
135135
_PARAMETER_FUNCTIONS(GbtEnabled, "gbt_enabled")
136+
_PARAMETER_FUNCTIONS(FirmwareCheckEnabled, "firmware_check_enabled")
136137
_PARAMETER_FUNCTIONS(UserLogicEnabled, "user_logic_enabled")
137138
_PARAMETER_FUNCTIONS(OnuAddress, "onu_address")
138139
_PARAMETER_FUNCTIONS(StbrdEnabled, "stbrd_enabled")

0 commit comments

Comments
 (0)