Commit 564ed30e authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by Laurent Claustre
Browse files

SerialLine: support slow cmd Reload and store Reset trace log

parent 8554c0af
......@@ -49,6 +49,7 @@ class SerialLine : public HwSerialLine
};
typedef std::map<MsgPart, std::string> MsgPartStrMapType;
typedef std::vector<std::string> StrList;
static const double TimeoutSingle, TimeoutNormal, TimeoutMultiLine,
TimeoutReset;
......@@ -98,6 +99,8 @@ class SerialLine : public HwSerialLine
void setCacheActive(bool cache_act);
void getCacheActive(bool& cache_act);
void getResetTraceLog(StrList& reset_trace_log);
private:
enum RegOp {
None, DoCmd, ReadReg, WriteReg, DoReset, MultiRead
......@@ -153,9 +156,11 @@ class SerialLine : public HwSerialLine
bool m_cache_act;
RegOp m_curr_op;
Reg m_curr_reg;
Cmd m_curr_cmd;
bool m_curr_cache;
std::string m_curr_resp;
std::string m_curr_fmt_resp;
StrList m_reset_trace_log;
};
inline void SerialLine::readRegister(Reg reg, int& val)
......
......@@ -44,6 +44,7 @@ class SerialLine : HwSerialLine
};
// typedef std::map<MsgPart, std::string> MsgPartStrMapType;
// typedef std::vector<std::string> StrList;
// static const double TimeoutSingle, TimeoutNormal, TimeoutMultiLine,
// TimeoutReset;
......@@ -101,6 +102,7 @@ class SerialLine : HwSerialLine
void setCacheActive(bool cache_act);
void getCacheActive(bool& cache_act /Out/);
void getResetTraceLog(std::vector<std::string>& reset_trace_log /Out/);
};
......
......@@ -91,8 +91,9 @@ void SerialLine::writeCmd(const string& buffer, bool no_wait)
if (cmd == CmdStrMap[Reset]) {
m_curr_op = DoReset;
DEB_TRACE() << "DoReset: clearing reg cache";
DEB_TRACE() << "DoReset: clearing reg cache and reset trace";
m_reg_cache.clear();
m_reset_trace_log.clear();
} else {
MultiLineCmdStrMapType::const_iterator it, end;
end = MultiLineCmdStrMap.end();
......@@ -154,8 +155,11 @@ void SerialLine::writeCmd(const string& buffer, bool no_wait)
}
}
if (m_curr_op == None)
if (m_curr_op == None) {
m_curr_op = DoCmd;
CmdStrMapType::const_iterator it = FindMapValue(CmdStrMap, cmd);
m_curr_cmd = (it != CmdStrMap.end()) ? it->first : Reset;
}
DEB_TRACE() << DEB_VAR1(m_curr_op);
......@@ -230,7 +234,8 @@ void SerialLine::readSingleLine(string& buffer, int max_len, double timeout)
}
if (timeout == TimeoutDefault) {
if (m_curr_op == DoReset) {
bool slow_cmd = ((m_curr_op == DoCmd) && (m_curr_cmd == Reload));
if ((m_curr_op == DoReset) || slow_cmd) {
timeout = TimeoutReset;
} else if (m_curr_op == WriteReg) {
RegDoubleMapType::const_iterator it;
......@@ -241,9 +246,15 @@ void SerialLine::readSingleLine(string& buffer, int max_len, double timeout)
}
Timestamp t0 = Timestamp::now();
bool reset_trace;
do {
m_espia_ser_line.readLine(buffer, max_len, timeout);
} while ((m_curr_op == DoReset) && (buffer != "!OK\r\n"));
reset_trace = ((m_curr_op == DoReset) && (buffer != "!OK\r\n"));
if (reset_trace) {
std::string s = buffer.substr(0, buffer.size() - 2);
m_reset_trace_log.push_back(s);
}
} while (reset_trace);
double ack_delay = Timestamp::now() - t0;
decodeFmtResp(buffer, m_curr_fmt_resp);
......@@ -549,6 +560,14 @@ void SerialLine::getCacheActive(bool& cache_act)
DEB_RETURN() << DEB_VAR1(cache_act);
}
void SerialLine::getResetTraceLog(StrList& reset_trace_log)
{
DEB_MEMBER_FUNCT();
AutoMutex l = lock(AutoMutex::Locked);
reset_trace_log = m_reset_trace_log;
DEB_RETURN() << DEB_VAR1(reset_trace_log);
}
void SerialLine::writeRegister(Reg reg, int val)
{
DEB_MEMBER_FUNCT();
......
......@@ -153,6 +153,13 @@ class Frelon(PyTango.Device_4Impl):
serial = model.getSerialNb()
attr.set_value("%d" % serial)
def read_reset_trace_log(self,attr):
cam = _FrelonAcq.getFrelonCamera()
ser_line = cam.getSerialLine()
reset_trace_log = ser_line.getResetTraceLog()
attr.set_value(reset_trace_log)
class FrelonClass(PyTango.DeviceClass):
class_property_list = {}
......@@ -227,6 +234,10 @@ class FrelonClass(PyTango.DeviceClass):
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ]],
'reset_trace_log' :
[[PyTango.DevString,
PyTango.SPECTRUM,
PyTango.READ, 65535]],
}
def __init__(self,name) :
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment