Skip to content

Commit 743762b

Browse files
committed
[alf] Add service to reset CRORC channels
1 parent a8ebf15 commit 743762b

File tree

7 files changed

+65
-1
lines changed

7 files changed

+65
-1
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,17 @@ It extends the `SCA_SEQUENCE` to add the following functionality:
226226
* DIM input `0xf00d\n0x0000f00d, 0x0000beef\n0x0000f00d`
227227
* DIM output `0xcafe\n0\n0xbeef\n`
228228

229+
##### RESET_CARD
230+
* Parameters:
231+
* empty
232+
233+
* Returns:
234+
* empty
235+
236+
* Example:
237+
* DIM input ` `
238+
* DIM output ` `
239+
229240
## Slow Control library
230241
ALF can also be used as a C++ library to access the Slow Control interface of the CRU. The three available interfaces (IC, SCA & SWT) can be accessed through single operations, or sequences of operations.
231242

apps/AlfClient.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class AlfClient : public AliceO2::Common::Program
6969
"Hostname of node running the ALF server(required)");
7070
options.add_options()("crorc",
7171
po::bool_switch(&mOptions.crorc)->default_value(false),
72-
"Flag enabling the test of the crorc (exclusive)");
72+
"Flag enabling the test of the crorc (exclusive - includes card reset!)");
7373
options.add_options()("ic",
7474
po::bool_switch(&mOptions.ic)->default_value(false),
7575
"Flag enabling the ic tests");
@@ -139,12 +139,15 @@ class AlfClient : public AliceO2::Common::Program
139139
if (mOptions.crorc) {
140140
link.cardType = roc::CardType::Crorc;
141141
RegisterSequenceRpc registerSequence(names.registerSequence());
142+
ResetCardRpc resetCard(names.resetCard());
142143
auto regOut = registerSequence.write({ std::make_pair("0x19c", ""),
143144
std::make_pair("0xa0", ""),
144145
std::make_pair("0x1f0", ""),
145146
std::make_pair("0x1f0", "0x00080000"),
146147
std::make_pair("0x1f0", "") });
147148
std::cout << "[REGISTER SEQUENCE] output: " << regOut << std::endl;
149+
auto resetCardOut = resetCard.write("alf_client_test");
150+
std::cout << "[RESET CARD] output: " << resetCardOut << std::endl;
148151

149152
return;
150153
}

src/AlfClient.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,30 @@ class LlaSessionStopRpc : DimRpcInfoWrapper
358358
}
359359
};
360360

361+
class ResetCardRpc : DimRpcInfoWrapper
362+
{
363+
public:
364+
ResetCardRpc(const std::string& serviceName)
365+
: DimRpcInfoWrapper(serviceName)
366+
{
367+
}
368+
369+
std::string write(const std::string& buffer)
370+
{
371+
setString(buffer);
372+
std::string ret;
373+
try {
374+
ret = getString();
375+
} catch (const AlfException& e) {
376+
if (kDebugLogging) {
377+
Logger::get() << "ResetCard: " << boost::diagnostic_information(e, true) << LogErrorDevel << endm;
378+
}
379+
return errString;
380+
}
381+
return ret;
382+
}
383+
};
384+
361385
} // namespace alf
362386
} // namespace o2
363387

src/AlfServer.cxx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#include "Logger.h"
2626
#include "Util.h"
2727

28+
#include "ReadoutCard/ChannelFactory.h"
29+
#include "ReadoutCard/Exception.h"
30+
2831
namespace o2
2932
{
3033
namespace alf
@@ -190,6 +193,24 @@ std::string AlfServer::llaSessionStop(const std::string& /*parameter*/, roc::Ser
190193
return "";
191194
}
192195

196+
std::string AlfServer::resetCard(const std::string& /*parameter*/, AlfLink link)
197+
{
198+
// Reset the CRORC DMA channel
199+
auto params = roc::Parameters::makeParameters(link.serialId, link.linkId);
200+
params.setBufferParameters(o2::roc::buffer_parameters::Null());
201+
params.setFirmwareCheckEnabled(false);
202+
std::shared_ptr<roc::DmaChannelInterface> dmaChannel;
203+
try {
204+
dmaChannel = roc::ChannelFactory().getDmaChannel(params);
205+
} catch (const roc::LockException& e) {
206+
BOOST_THROW_EXCEPTION(
207+
AlfException() << ErrorInfo::Message("Another process is holding the channel lock (cannot reset)"));
208+
}
209+
dmaChannel->resetChannel(roc::ResetLevel::InternalSiu);
210+
211+
return "";
212+
}
213+
193214
roc::PatternPlayer::Info AlfServer::parseStringToPatternPlayerInfo(const std::vector<std::string> parameters)
194215
{
195216
roc::PatternPlayer::Info ppInfo;
@@ -610,6 +631,8 @@ void AlfServer::makeRpcServers(std::vector<AlfLink> links, bool sequentialRpcs)
610631
// Register Sequence
611632
servers.push_back(makeServer(names.registerSequenceLink(),
612633
[bar](auto parameter) { return registerBlobWrite(parameter, bar); }));
634+
servers.push_back(makeServer(names.resetCard(),
635+
[link, this](auto parameter) { return resetCard(parameter, link); }));
613636
}
614637
}
615638
}

src/AlfServer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class AlfServer
6060
static std::string registerBlobWrite(const std::string& parameter, std::shared_ptr<roc::BarInterface>, bool isCru = false);
6161
std::string llaSessionStart(const std::string& parameter, roc::SerialId serialId);
6262
std::string llaSessionStop(const std::string& parameter, roc::SerialId serialId);
63+
std::string resetCard(const std::string& parameter, AlfLink link);
6364

6465
static std::vector<uint32_t> stringToRegisterPair(const std::string stringPair);
6566
static std::pair<Sca::Operation, Sca::Data> stringToScaPair(const std::string stringPair);

src/DimServices/ServiceNames.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ DEFLINKSERVICENAME(scaMftPsuSequence, "SCA_MFT_PSU_SEQUENCE")
4848
DEFLINKSERVICENAME(swtSequence, "SWT_SEQUENCE")
4949
DEFLINKSERVICENAME(icSequence, "IC_SEQUENCE")
5050
DEFLINKSERVICENAME(icGbtI2cWrite, "IC_GBT_I2C_WRITE")
51+
DEFLINKSERVICENAME(resetCard, "RESET_CARD")
5152

5253
std::string ServiceNames::formatLink(std::string name) const
5354
{

src/DimServices/ServiceNames.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class ServiceNames
4545
std::string registerSequenceLink() const;
4646
std::string llaSessionStart() const;
4747
std::string llaSessionStop() const;
48+
std::string resetCard() const;
4849

4950
private:
5051
std::string formatLink(std::string name) const;

0 commit comments

Comments
 (0)