Commit 16b3e7b0 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by Laurent Claustre
Browse files

Frelon16: increase serial timeout for slow commands:

* ConfigHD & BinHorz
* Do not wait if delay in ack is longer than foreseen Sleep time
parent ae5e1090
......@@ -64,6 +64,7 @@ extern RegListType SignedRegList;
typedef std::map<Reg, double> RegDoubleMapType;
extern RegDoubleMapType RegSleepMap;
extern RegDoubleMapType RegTimeoutMap;
extern const int MaxRegVal;
......
......@@ -75,6 +75,7 @@ extern RegListType SignedRegList;
typedef std::map<Reg, double> RegDoubleMapType;
extern RegDoubleMapType RegSleepMap;
extern RegDoubleMapType RegTimeoutMap;
*/
const int MaxRegVal;
......
......@@ -126,14 +126,21 @@ static Reg SignedRegCList[] = {
};
RegListType lima::Frelon::SignedRegList(C_LIST_ITERS(SignedRegCList));
typedef pair<Reg, double> RegSleepPair;
static const RegSleepPair RegSleepCList[] = {
RegSleepPair(ConfigHD, 2.0),
RegSleepPair(BinHorz, 2.0),
RegSleepPair(LookUpTable, 2.0),
typedef pair<Reg, double> RegDoublePair;
static const RegDoublePair RegSleepCList[] = {
RegDoublePair(ConfigHD, 2.0),
RegDoublePair(BinHorz, 2.0),
RegDoublePair(LookUpTable, 2.0),
};
RegDoubleMapType lima::Frelon::RegSleepMap(C_LIST_ITERS(RegSleepCList));
static const RegDoublePair RegTimeoutCList[] = {
RegDoublePair(ConfigHD, 10.0),
RegDoublePair(BinHorz, 10.0),
};
RegDoubleMapType lima::Frelon::RegTimeoutMap(C_LIST_ITERS(RegTimeoutCList));
const int lima::Frelon::MaxRegVal = (1 << 16) - 1;
typedef pair<Cmd, string> CmdPair;
......
......@@ -31,7 +31,7 @@ using namespace std;
const double SerialLine::TimeoutSingle = 0.5;
const double SerialLine::TimeoutNormal = 2.0;
const double SerialLine::TimeoutMultiLine = 3.0;
const double SerialLine::TimeoutReset = 10.0;
const double SerialLine::TimeoutReset = 15.0;
SerialLine::SerialLine(Espia::SerialLine& espia_ser_line)
......@@ -229,17 +229,28 @@ void SerialLine::readSingleLine(string& buffer, int max_len, double timeout)
return;
}
if ((m_curr_op == DoReset) && (timeout == TimeoutDefault))
timeout = TimeoutReset;
if (timeout == TimeoutDefault) {
if (m_curr_op == DoReset) {
timeout = TimeoutReset;
} else if (m_curr_op == WriteReg) {
RegDoubleMapType::const_iterator it;
it = RegTimeoutMap.find(m_curr_reg);
if (it != RegTimeoutMap.end())
timeout = it->second;
}
}
Timestamp t0 = Timestamp::now();
do {
m_espia_ser_line.readLine(buffer, max_len, timeout);
} while ((m_curr_op == DoReset) && (buffer != "!OK\r\n"));
double ack_delay = Timestamp::now() - t0;
decodeFmtResp(buffer, m_curr_fmt_resp);
if (m_curr_op == WriteReg) {
double sleep_time = getRegSleepTime(m_curr_reg);
if (sleep_time > 0) {
if ((sleep_time > 0) && (ack_delay < sleep_time)) {
DEB_TRACE() << "Sleeping " << sleep_time << " s after "
<< "changing " << RegStrMap[m_curr_reg];
Sleep(sleep_time);
......
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