Skip to content

Commit 7bbd748

Browse files
ALF: Added partial return sequence for SCA_WRITE_SEQUENCE
1 parent ad7b8e2 commit 7bbd748

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

src/CommandLineUtilities/AliceLowlevelFrontend/AlfException.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ namespace roc {
1313
namespace CommandLineUtilities {
1414
namespace Alf {
1515

16-
//// RORC exception definitions
1716
struct AlfException : AliceO2::Common::Exception {};
17+
struct ScaException : AliceO2::Common::Exception {};
1818

1919
namespace ErrorInfo
2020
{

src/CommandLineUtilities/AliceLowlevelFrontend/ProgramAliceLowlevelFrontendServer.cxx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,19 +397,28 @@ class ProgramAliceLowlevelFrontendServer: public AliceO2::Common::Program
397397
boost::char_separator<char> sep(";", "", boost::drop_empty_tokens); // Drop ";" delimiters, keep none
398398
std::stringstream resultBuffer;
399399
auto sca = Sca(*bar2, bar2->getCardType());
400+
400401
for (std::string token : tokenizer(parameter, sep)) {
401402
// Walk through the tokens, these should be the pairs. The pairs are comma-separated, so we split those.
402403
std::vector<std::string> pair = split(token, ",");
403404
if (pair.size() != 2) {
404-
BOOST_THROW_EXCEPTION(AlfException() << ErrorInfo::Message("SCA command-data pair not formatted correctly"));
405+
BOOST_THROW_EXCEPTION(
406+
AlfException() << ErrorInfo::Message("SCA command-data pair not formatted correctly"));
405407
}
406408
auto command = convertHexString(pair[0]);
407409
auto data = convertHexString(pair[1]);
408-
sca.write(command, data);
409-
auto result = sca.read();
410-
getInfoLogger() << (b::format("cmd=0x%x data=0x%x result=0x%x") % command % data % result.data).str() << endm;
411-
resultBuffer << std::hex << result.data << ';';
410+
try {
411+
sca.write(command, data);
412+
auto result = sca.read();
413+
getInfoLogger() << (b::format("cmd=0x%x data=0x%x result=0x%x") % command % data % result.data).str() << endm;
414+
resultBuffer << std::hex << result.data << ';';
415+
} catch (const ScaException& e) {
416+
// If an SCA error occurs, we stop executing the sequence of commands and return the results as far as we got
417+
// them
418+
break;
419+
}
412420
}
421+
413422
auto result = resultBuffer.str();
414423
if (result.size() > 0) {
415424
result.pop_back(); // Pop the last ';'

src/CommandLineUtilities/AliceLowlevelFrontend/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ Write a sequence of values to the SCA
7272
~~~
7373
42;123;555
7474
~~~
75+
If an SCA error occurred, the sequence of return values will go up to that point.
76+
If another type of error occurred (such as a formatting error), it will return a failure string.
7577
7678
7779
#### SCA GPIO read

src/CommandLineUtilities/AliceLowlevelFrontend/Sca.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void Sca::checkError(uint32_t command)
100100

101101
for (int flag = 0; flag < 7; ++flag) {
102102
if (Utilities::getBit(command & 0xff, flag) == 1) {
103-
BOOST_THROW_EXCEPTION(AlfException() << ErrorInfo::Message(toString(flag)));
103+
BOOST_THROW_EXCEPTION(ScaException() << ErrorInfo::Message(toString(flag)));
104104
}
105105
}
106106
}
@@ -169,7 +169,7 @@ void Sca::waitOnBusyClear()
169169
return;
170170
}
171171
}
172-
BOOST_THROW_EXCEPTION(AlfException() << ErrorInfo::Message("Exceeded timeout on busy wait"));
172+
BOOST_THROW_EXCEPTION(ScaException() << ErrorInfo::Message("Exceeded timeout on busy wait"));
173173
}
174174

175175

0 commit comments

Comments
 (0)