Skip to content

Commit 6e49b26

Browse files
Add error handling to SCA publish
1 parent fb47a09 commit 6e49b26

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/CommandLineUtilities/AliceLowlevelFrontend/ProgramAliceLowlevelFrontendServer.cxx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,21 @@ class PublisherRegistry
184184
}
185185
},
186186
[&](const ServiceDescription::ScaSequence& type){
187+
std::fill(registerValues.begin(), registerValues.end(), 0); // Reset array in case of aborts
187188
auto sca = Sca(channel, channel.getCardType());
188189
for (size_t i = 0; i < type.commandDataPairs.size(); ++i) {
189-
const auto& pair = type.commandDataPairs[i];
190-
sca.write(pair);
191-
auto result = sca.read();
192-
registerValues[i*2] = result.command;
193-
registerValues[i*2 + 1] = result.data;
190+
try {
191+
const auto& pair = type.commandDataPairs[i];
192+
sca.write(pair);
193+
auto result = sca.read();
194+
registerValues[i*2] = result.command;
195+
registerValues[i*2 + 1] = result.data;
196+
} catch (const ScaException &e) {
197+
// If an SCA error occurs, we stop executing the sequence of commands and set the error value
198+
registerValues[i*2] = 0xffffffff;
199+
registerValues[i*2 + 1] = 0xffffffff;
200+
break;
201+
}
194202
}
195203
}
196204
);

src/CommandLineUtilities/AliceLowlevelFrontend/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ Values are published as array of 32 bit unsigned integers.
3636

3737
#### Publish SCA
3838
Starts a service under a DNS name, that executes and publishes the results of the given SCA write sequence at the
39-
specified interval. Values are published as array of 32 bit unsigned integers.
39+
specified interval. Values are published as array of 32 bit unsigned integers.
40+
If an error occurred, the corresponding result will be set to 0xffffffff and the rest of the sequence is aborted.
4041
* Service type: RPC call
4142
* Service name: PUBLISH_SCA_START
4243
* Parameters: DNS name to publish at, comma-separated register addresses, interval in seconds

0 commit comments

Comments
 (0)