Skip to content

Commit

Permalink
[sca] Append svl to connect and reset operations
Browse files Browse the repository at this point in the history
  • Loading branch information
kostorr committed Nov 12, 2020
1 parent 74f3a33 commit acc0901
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ The services are DIM RPC services. Every RPC is called with a string and expects
* Operations may be:
* An SCA command and data pair (e.g. `0x0000f00d,0x0000cafe`)
* A wait operation (e.g. `30,wait`) in ms, defaults to 3
* An SCA connect operation (e.g. `connect`)
* An SCA reset operation (`reset`)
* An SCA supervisory level connect operation (e.g. `svl_connect`)
* An SCA supervisory level reset operation (`svl_reset`)
* An SC global reset operation (`sc_reset`)
* An instruction to execute the sequence atomically (`lock` - needs to lead the sequence)
* Returns:
* Sequence of SCA output as follows:
* SCA command and SCA read pairs
* Wait confirmations with time waited
* Connect confirmations made up of a "connect" string
* No entries for `reset`, `sc_reset`, and `lock` directives
* Connect confirmations made up of a "svl_connect" string
* No entries for `svl_reset`, `sc_reset`, and `lock` directives

* Example:
* DIM input: `0x00000010,0x00000011\n3\n0x000000020,0x00000021`
Expand Down
4 changes: 2 additions & 2 deletions apps/AlfClient.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ class AlfClient : public AliceO2::Common::Program

if (mOptions.sca) {
auto scaOut = scaSequence.write({ std::make_pair("", "sc_reset"),
std::make_pair("", "reset"),
std::make_pair("", "connect"),
std::make_pair("", "svl_reset"),
std::make_pair("", "svl_connect"),
std::make_pair("1000", "wait"),
std::make_pair("0x00010002", "0xff000000"),
std::make_pair("0x00020004", "0xff000000"),
Expand Down
16 changes: 8 additions & 8 deletions apps/AlfLibClient.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class AlfLibClient : public AliceO2::Common::Program

std::cout << "Running simple SCA operations" << std::endl;
try {
sca.reset();
sca.connect();
sca.svlReset();
sca.svlConnect();
auto scaOut = sca.executeCommand({ 0x00010002, 0xff000000 });
std::cout << scaOut.command << " " << scaOut.data << std::endl;
} catch (const ScaException& e) {
Expand All @@ -82,8 +82,8 @@ class AlfLibClient : public AliceO2::Common::Program
std::vector<std::pair<Sca::Operation, Sca::Data>> ops;
sca.setChannel(1);
ops.push_back({ Sca::Operation::SCReset, {} });
ops.push_back({ Sca::Operation::Reset, {} });
ops.push_back({ Sca::Operation::Connect, {} });
ops.push_back({ Sca::Operation::SVLReset, {} });
ops.push_back({ Sca::Operation::SVLConnect, {} });
ops.push_back({ Sca::Operation::Command, Sca::CommandData{ 0x00100002, 0xff000000 } });
ops.push_back({ Sca::Operation::Command, Sca::CommandData{ 0x00100003, 0xff000000 } });
ops.push_back({ Sca::Operation::Wait, 100 });
Expand All @@ -94,12 +94,12 @@ class AlfLibClient : public AliceO2::Common::Program
std::cout << "Command: " << boost::get<Sca::CommandData>(out.second) << std::endl;
} else if (out.first == Sca::Operation::Wait) {
std::cout << "Wait: " << std::dec << boost::get<Sca::WaitTime>(out.second) << std::endl;
} else if (out.first == Sca::Operation::Reset) {
std::cout << "Reset" << std::endl;
} else if (out.first == Sca::Operation::SVLReset) {
std::cout << "SVL Reset" << std::endl;
} else if (out.first == Sca::Operation::SCReset) {
std::cout << "SC Reset" << std::endl;
} else if (out.first == Sca::Operation::Connect) {
std::cout << "Connect " << std::endl;
} else if (out.first == Sca::Operation::SVLConnect) {
std::cout << "SVL Connect " << std::endl;
} else if (out.first == Sca::Operation::Error) {
std::cout << "Error: " << boost::get<std::string>(out.second) << std::endl;
} else {
Expand Down
8 changes: 4 additions & 4 deletions include/Alf/Sca.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class Sca
enum Operation { Command,
Wait,
SCReset,
Reset,
Connect,
SVLReset,
SVLConnect,
Error,
Lock };

Expand Down Expand Up @@ -84,10 +84,10 @@ class Sca
void scReset();

/// Executes an SCA reset
void reset();
void svlReset();

/// Executes an SCA connect
void connect();
void svlConnect();

/// Executes an SCA command
/// \param commandData SCA command, data pair
Expand Down
18 changes: 9 additions & 9 deletions src/AlfServer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -296,23 +296,23 @@ std::pair<Sca::Operation, Sca::Data> AlfServer::stringToScaPair(const std::strin
} catch (const std::exception& e) {
BOOST_THROW_EXCEPTION(SwtException() << ErrorInfo::Message("SCA Wait Time provided cannot be converted to int"));
}
} else if (scaPair[scaPair.size() - 1] == "reset") {
operation = Sca::Operation::Reset;
} else if (scaPair[scaPair.size() - 1] == "svl_reset") {
operation = Sca::Operation::SVLReset;
if (scaPair.size() != 1) {
BOOST_THROW_EXCEPTION(
AlfException() << ErrorInfo::Message("Too many arguments for RESET operation"));
AlfException() << ErrorInfo::Message("Too many arguments for SVL RESET operation"));
}
} else if (scaPair[scaPair.size() - 1] == "sc_reset") {
operation = Sca::Operation::SCReset;
} else if (scaPair[scaPair.size() - 1] == "svl_connect") {
operation = Sca::Operation::SVLConnect;
if (scaPair.size() != 1) {
BOOST_THROW_EXCEPTION(
AlfException() << ErrorInfo::Message("Too many arguments for SC RESET operation"));
AlfException() << ErrorInfo::Message("Too many arguments for SVL CONNECT operation"));
}
} else if (scaPair[scaPair.size() - 1] == "connect") {
operation = Sca::Operation::Connect;
} else if (scaPair[scaPair.size() - 1] == "sc_reset") {
operation = Sca::Operation::SCReset;
if (scaPair.size() != 1) {
BOOST_THROW_EXCEPTION(
AlfException() << ErrorInfo::Message("Too many arguments for CONNECT operation"));
AlfException() << ErrorInfo::Message("Too many arguments for SC RESET operation"));
}
} else { // regular sca command
operation = Sca::Operation::Command;
Expand Down
30 changes: 15 additions & 15 deletions src/Sca.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ void Sca::scReset()
barWrite(sc_regs::SC_RESET.index, 0x0); //void cmd to sync clocks
}

void Sca::reset()
void Sca::svlReset()
{
barWrite(sc_regs::SCA_WR_CTRL.index, 0x1);
barWrite(sc_regs::SCA_WR_CTRL.index, 0x0);
}

void Sca::connect()
void Sca::svlConnect()
{
barWrite(sc_regs::SCA_WR_CTRL.index, 0x2);
barWrite(sc_regs::SCA_WR_CTRL.index, 0x0);
Expand Down Expand Up @@ -298,15 +298,15 @@ std::vector<std::pair<Sca::Operation, Sca::Data>> Sca::executeSequence(const std
}
std::this_thread::sleep_for(std::chrono::milliseconds(waitTime));
ret.push_back({ operation, waitTime });
} else if (operation == Operation::Reset) {
reset();
ret.push_back({ Operation::Reset, {} });
} else if (operation == Operation::SVLReset) {
svlReset();
ret.push_back({ Operation::SVLReset, {} });
} else if (operation == Operation::SCReset) {
scReset();
ret.push_back({ Operation::SCReset, {} });
} else if (operation == Operation::Connect) {
connect();
ret.push_back({ Operation::Connect, {} });
} else if (operation == Operation::SVLConnect) {
svlConnect();
ret.push_back({ Operation::SVLConnect, {} });
} else {
BOOST_THROW_EXCEPTION(ScaException() << ErrorInfo::Message("SCA operation type unknown"));
}
Expand All @@ -318,12 +318,12 @@ std::vector<std::pair<Sca::Operation, Sca::Data>> Sca::executeSequence(const std
meaningfulMessage = (boost::format("SCA_SEQUENCE cmd=0x%08x data=0x%08x serialId=%s link=%d error='%s'") % boost::get<CommandData>(data).command % boost::get<CommandData>(data).data % mLink.serialId % mLink.linkId % e.what()).str();
} else if (operation == Operation::Wait) {
meaningfulMessage = (boost::format("SCA_SEQUENCE WAIT waitTime=%d serialId=%s link=%d error='%s'") % boost::get<WaitTime>(data) % mLink.serialId % mLink.linkId % e.what()).str();
} else if (operation == Operation::Reset) {
meaningfulMessage = (boost::format("SCA_SEQUENCE RESET serialId=%s link=%d error='%s'") % mLink.serialId % mLink.linkId % e.what()).str();
} else if (operation == Operation::SVLReset) {
meaningfulMessage = (boost::format("SCA_SEQUENCE SVL RESET serialId=%s link=%d error='%s'") % mLink.serialId % mLink.linkId % e.what()).str();
} else if (operation == Operation::SCReset) {
meaningfulMessage = (boost::format("SCA_SEQUENCE SC RESET serialId=%s link=%d error='%s'") % mLink.serialId % mLink.linkId % e.what()).str();
} else if (operation == Operation::Connect) {
meaningfulMessage = (boost::format("SCA_SEQUENCE CONNECT serialId=%s link=%d error='%s'") % mLink.serialId % mLink.linkId % e.what()).str();
} else if (operation == Operation::SVLConnect) {
meaningfulMessage = (boost::format("SCA_SEQUENCE SVL CONNECT serialId=%s link=%d error='%s'") % mLink.serialId % mLink.linkId % e.what()).str();
} else {
meaningfulMessage = (boost::format("SCA_SEQUENCE UNKNOWN serialId=%s link=%d error='%s'") % mLink.serialId % mLink.linkId % e.what()).str();
}
Expand Down Expand Up @@ -352,10 +352,10 @@ std::string Sca::writeSequence(const std::vector<std::pair<Operation, Data>>& op
resultBuffer << data << "\n"; // "[cmd],[data]\n"
} else if (operation == Operation::Wait) {
resultBuffer << std::dec << data << "\n"; // "[time]\n"
} else if (operation == Operation::Reset || operation == Operation::SCReset) {
} else if (operation == Operation::SVLReset || operation == Operation::SCReset) {
/* DO NOTHING */
} else if (operation == Operation::Connect) {
resultBuffer << "connect\n"; // echo
} else if (operation == Operation::SVLConnect) {
resultBuffer << "svl_connect\n"; // echo
} else if (operation == Operation::Error) {
resultBuffer << data; // "[error_msg]"
Logger::get().err() << data << endm;
Expand Down

0 comments on commit acc0901

Please sign in to comment.