Skip to content

Commit 0ed2bb4

Browse files
authored
Compatibility and other fixes for FRED
* Program arguments take precedence over env variables * 76-bit words for SWT operations * Uppercase DIM Service names
1 parent 7c657d8 commit 0ed2bb4

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

apps/ProgramAlf.cxx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,32 +60,32 @@ class ProgramAlf : public AliceO2::Common::Program
6060

6161
getLogger() << "ALF server initializations..." << endm;
6262

63-
if (const char* dimDnsNode = std::getenv("DIM_DNS_NODE")) {
63+
if (mOptions.dimDnsNode != "") {
64+
getLogger() << "Setting DIM_DNS_NODE from argument." << endm;
65+
getLogger() << "DIM_DNS_NODE=" << mOptions.dimDnsNode << endm;
66+
} else if (const char* dimDnsNode = std::getenv("DIM_DNS_NODE")) {
6467
getLogger() << "Picked up DIM_DMS_NODE from the environment." << endm;
6568
getLogger() << "DIM_DNS_NODE=" << dimDnsNode << endm;
66-
} else if (mOptions.dimDnsNode != "") {
67-
getLogger() << "DIM_DNS_NODE env variable not set. Setting it from argument." << endm;
68-
setenv("DIM_DNS_NODE", mOptions.dimDnsNode.c_str(), 1); // Don't be afraid to overwrite since we ended up here
69-
getLogger() << "DIM_DNS_NODE=" << std::getenv("DIM_DNS_NODE") << endm;
69+
mOptions.dimDnsNode = dimDnsNode;
7070
} else {
7171
BOOST_THROW_EXCEPTION(AlfException() << ErrorInfo::Message("DIM_DNS_NODE env variable not set, and no relevant argument provided.")); // InfoLogger and errors?
7272
}
7373

7474
int alfId;
7575

7676
if (const char* alfIdString = std::getenv("ALF_ID")) {
77+
getLogger() << "Setting ALF_ID from argument." << endm;
78+
alfId = mOptions.alfId;
79+
getLogger() << "ALF_ID=" << alfId << endm;
80+
} else {
7781
getLogger() << "Picked up ALF_ID from the environment." << endm;
7882
getLogger() << "ALF_ID=" << alfIdString << endm;
7983
alfId = atoi(alfIdString);
80-
} else {
81-
getLogger() << "ALF_ID env variable not set. Setting it from argument." << endm;
82-
alfId = mOptions.alfId;
83-
getLogger() << "ALF_ID=" << alfId << endm;
84-
/* Do I need to set the env var for ALF_ID? */
8584
}
8685

86+
8787
getLogger() << "Starting the DIM Server" << endm;
88-
DimServer::setDnsNode("localhost", 2505);
88+
DimServer::setDnsNode(mOptions.dimDnsNode.c_str(), 2505);
8989
DimServer::start(alfId == -1 ? "ALF" : ("ALF" + std::to_string(alfId)).c_str());
9090

9191
AlfServer alfServer = AlfServer();

src/AlfServer.cxx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Sca::CommandData AlfServer::stringToScaPair(std::string stringPair)
112112
return commandData;
113113
}
114114

115-
/// Converts a 96-bit hex number string
115+
/// Converts a 76-bit hex number string
116116
std::pair<SwtWord, Swt::Operation> AlfServer::stringToSwtPair(const std::string stringPair)
117117
{
118118
std::vector<std::string> swtPair = Util::split(stringPair, pairSeparator());
@@ -129,17 +129,17 @@ std::pair<SwtWord, Swt::Operation> AlfServer::stringToSwtPair(const std::string
129129
hexString.erase(i, leadingHex.size());
130130
}
131131

132-
if (hexString.length() > 20) {
133-
BOOST_THROW_EXCEPTION(std::out_of_range("Parameter does not fit in 96-bit unsigned int"));
132+
if (hexString.length() > 19) {
133+
BOOST_THROW_EXCEPTION(std::out_of_range("Parameter does not fit in 76-bit unsigned int"));
134134
}
135135

136136
std::stringstream ss;
137-
ss << std::setw(20) << std::setfill('0') << hexString;
137+
ss << std::setw(19) << std::setfill('0') << hexString;
138138

139139
SwtWord word;
140-
word.setHigh(std::stoul(ss.str().substr(0, 4), NULL, 16));
141-
word.setMed(std::stoul(ss.str().substr(4, 8), NULL, 16));
142-
word.setLow(std::stoul(ss.str().substr(12, 8), NULL, 16));
140+
word.setHigh(std::stoul(ss.str().substr(0, 3), NULL, 16));
141+
word.setMed(std::stoul(ss.str().substr(3, 8), NULL, 16));
142+
word.setLow(std::stoul(ss.str().substr(11, 8), NULL, 16));
143143

144144
Swt::Operation operation;
145145

src/DimServices/ServiceNames.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ DEFSERVICENAME(icGbtI2cWrite, "IC_GBT_I2C_write")
3838
std::string ServiceNames::format(std::string name) const
3939
{
4040
if (mAlfId != "-1")
41-
return ((boost::format("ALF%1%/serial_%2%/link_%3%/%4%") % mAlfId % mSerial % mLink % name)).str();
41+
return ((boost::format("ALF%1%/SERIAL_%2%/LINK_%3%/%4%") % mAlfId % mSerial % mLink % name)).str();
4242
else
43-
return ((boost::format("ALF/serial_%1%/link_%2%/%3%") % mSerial % mLink % name)).str();
43+
return ((boost::format("ALF/SERIAL_%1%/LINK_%2%/%3%") % mSerial % mLink % name)).str();
4444
}
4545

4646
} // namespace Alf

src/Swt/SwtWord.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ uint16_t SwtWord::getHigh() const
9595

9696
std::ostream& operator<<(std::ostream& output, const SwtWord& swtWord)
9797
{
98-
output << "0x" << std::setfill('0') << std::hex << std::setw(4) << swtWord.getHigh()
98+
output << "0x" << std::setfill('0') << std::hex << std::setw(3) << swtWord.getHigh()
9999
<< std::setfill('0') << std::setw(8) << swtWord.getMed() << std::setfill('0') << std::setw(8) << swtWord.getLow();
100100
return output;
101101
}

0 commit comments

Comments
 (0)