Skip to content

Commit f6e4ec3

Browse files
ALF: Support comments in SCA_WRITE_SEQUENCE
1 parent 518ac0f commit f6e4ec3

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

src/CommandLineUtilities/AliceLowlevelFrontend/ProgramAliceLowlevelFrontendClient.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ class ProgramAliceLowlevelFrontendClient: public Program
106106
cout << " " << result << '\n';
107107
}
108108

109+
{
110+
cout << "Writing blob with comments..." << endl;
111+
std::string result = scaWriteSequence.write("# Hello!\n11,22\n33,44\n# Bye!");
112+
cout << "Done!" << endl;
113+
cout << "Got result: \n";
114+
cout << " " << result << '\n';
115+
}
116+
109117
while (false)//!isSigInt())
110118
{
111119
cout << "-------------------------------------\n";

src/CommandLineUtilities/AliceLowlevelFrontend/ProgramAliceLowlevelFrontendServer.cxx

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -398,23 +398,30 @@ class ProgramAliceLowlevelFrontendServer: public AliceO2::Common::Program
398398
auto sca = Sca(*bar2, bar2->getCardType());
399399

400400
for (std::string token : tokenizer(parameter, sep)) {
401-
// Walk through the tokens, these should be the pairs. The pairs are comma-separated, so we split those.
402-
std::vector<std::string> pair = split(token, ",");
403-
if (pair.size() != 2) {
404-
BOOST_THROW_EXCEPTION(
405-
AlfException() << ErrorInfo::Message("SCA command-data pair not formatted correctly"));
406-
}
407-
auto command = convertHexString(pair[0]);
408-
auto data = convertHexString(pair[1]);
409-
try {
410-
sca.write(command, data);
411-
auto result = sca.read();
412-
getInfoLogger() << (b::format("cmd=0x%x data=0x%x result=0x%x") % command % data % result.data).str() << endm;
413-
resultBuffer << std::hex << result.data << '\n';
414-
} catch (const ScaException& e) {
415-
// If an SCA error occurs, we stop executing the sequence of commands and return the results as far as we got
416-
// them
417-
break;
401+
// Walk through the tokens, these should be the pairs (or comments).
402+
if (token.find('#') == 0) {
403+
// We have a comment, skip this token
404+
continue;
405+
} else {
406+
// The pairs are comma-separated, so we split them.
407+
std::vector<std::string> pair = split(token, ",");
408+
if (pair.size() != 2) {
409+
BOOST_THROW_EXCEPTION(
410+
AlfException() << ErrorInfo::Message("SCA command-data pair not formatted correctly"));
411+
}
412+
auto command = convertHexString(pair[0]);
413+
auto data = convertHexString(pair[1]);
414+
try {
415+
sca.write(command, data);
416+
auto result = sca.read();
417+
getInfoLogger() << (b::format("cmd=0x%x data=0x%x result=0x%x") % command % data % result.data).str()
418+
<< endm;
419+
resultBuffer << std::hex << result.data << '\n';
420+
} catch (const ScaException &e) {
421+
// If an SCA error occurs, we stop executing the sequence of commands and return the results as far as we got
422+
// them
423+
break;
424+
}
418425
}
419426
}
420427

src/CommandLineUtilities/AliceLowlevelFrontend/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ A basic write to the SCA
5454
#### SCA write sequence
5555
Write a sequence of values to the SCA
5656
* Service type: RPC call
57-
* Service name: SCA_SEQUENCE_WRITE
57+
* Service name: SCA_WRITE_SEQUENCE
5858
* Parameters: A sequence of pairs of SCA command and data. The pairs are separated by newline, the command and data by
5959
comma:
6060
~~~
@@ -64,6 +64,10 @@ Write a sequence of values to the SCA
6464
~~~
6565
"10,11\n20,21\n30,31"
6666
~~~
67+
Comment lines are allowed, they must start with a `#`. For example:
68+
~~~
69+
"# Hello!\n11,22\n33,44\n# Bye!"
70+
~~~
6771
* Return: A sequence of SCA read return values corresponding to the commands from the input sequence:
6872
~~~
6973
"[value 0]\n[value 1]\n[etc.]"

0 commit comments

Comments
 (0)