[Pkg-running-devel] [antpm] 35/41: ant: improve debuggability
Kristof Ralovich
ralovich-guest at moszumanska.debian.org
Tue Feb 23 21:46:47 UTC 2016
This is an automated email from the git hooks/post-receive script.
ralovich-guest pushed a commit to branch upstream
in repository antpm.
commit 334073b5a96a59d2cbdf6a7c6542283a143d1ef4
Author: RALOVICH, Kristof <tade60 at freemail.hu>
Date: Sun Feb 21 20:10:24 2016 +0100
ant: improve debuggability
---
src/AntChannel.cpp | 6 ++++++
src/AntMessenger.cpp | 27 ++++++++++++++++++---------
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/src/AntChannel.cpp b/src/AntChannel.cpp
index 5bd5b2a..a46875a 100644
--- a/src/AntChannel.cpp
+++ b/src/AntChannel.cpp
@@ -104,11 +104,13 @@ AntListenerBase::waitForMsg(AntMessage* m, const size_t timeout_ms)
{
if(m) *m = *m_msgResp;
m_msgResp.reset();
+ //lprintf(LOG_DBG3, "waitForMsg [0] already arrived\n");
return true;
}
if(!m_cndResp.timed_wait(lock, boost::posix_time::milliseconds(timeout_ms)))
{
// false means, timeout was reached
+ //lprintf(LOG_DBG3, "waitForMsg [1] timeout\n");
return false;
}
// true means, either notification OR spurious wakeup!!
@@ -117,8 +119,10 @@ AntListenerBase::waitForMsg(AntMessage* m, const size_t timeout_ms)
{
if(m) *m=*m_msgResp;//copy
m_msgResp.reset();
+ //lprintf(LOG_DBG3, "waitForMsg [2] received within time\n");
return true;
}
+ //lprintf(LOG_DBG3, "waitForMsg [3] spurious wakeup w/o arrival\n");
return false;
}
@@ -169,7 +173,9 @@ AntRespListener::waitForResponse(uint8_t& respVal, const size_t timeout_ms)
{
AntMessage resp;
if(!waitForMsg(&resp, timeout_ms))
+ {
return false;
+ }
respVal = resp.getPayloadRef()[2];
return true;
}
diff --git a/src/AntMessenger.cpp b/src/AntMessenger.cpp
index 5105d04..840e8f7 100644
--- a/src/AntMessenger.cpp
+++ b/src/AntMessenger.cpp
@@ -870,7 +870,13 @@ bool
AntMessenger::sendCommand(uchar mesg, uchar *inbuf, uchar len, const size_t timeout_ms)
{
AntMessage m;
- return m.assemble(mesg, inbuf, len) && sendCommand(m, timeout_ms);
+ if(!m.assemble(mesg, inbuf, len))
+ {
+ lprintf(antpm::LOG_ERR, "assembly failed\n");
+ return false;
+ }
+
+ return sendCommand(m, timeout_ms);
}
@@ -888,14 +894,17 @@ AntMessenger::sendCommand(AntMessage &m, const size_t timeout_ms)
const uint8_t chan = m.getPayloadRef()[0];
AntChannel& pc = chs[chan];
AntRespListener respList(pc, m.getMsgId());
- //pc.addRespListener(&respList);
+ assert(rv);
uint8_t respVal;
- rv = rv&& respList.waitForResponse(respVal, timeout_ms);
-
- //pc.rmRespListener(&respList);
+ rv = respList.waitForResponse(respVal, timeout_ms);
+ if(!rv)
+ {
+ lprintf(antpm::LOG_ERR, "waitForResponse failed\n");
+ return false;
+ }
- return rv;
+ return true;
}
// request a message from peer
@@ -1039,7 +1048,7 @@ AntMessenger::assemblePackets(std::list<uchar>& q)
}
}
- //fprintf(loggerc(), "%d interpreted\n", nInterpreted);
+ //lprintf(LOG_INF, "%d interpreted\n", nInterpreted);
return true;
}
@@ -1051,7 +1060,7 @@ AntMessenger::onMessage(std::vector<AntMessage> v)
{
//TODO: don't presort here, but call onMsg for all incoming packets
- //fprintf(loggerc(), "%d\n", int(v.size()));
+ //lprintf(antpm::LOG_DBG3, "%d\n", int(v.size()));
for(size_t i = 0; i < v.size(); i++)
{
AntMessage& m(v[i]);
@@ -1171,9 +1180,9 @@ AntMessenger::th_messageHandler()
uchar buf[128];
size_t bytesRead=0;
bool rv = m_io->readBlocking(reinterpret_cast<char*>(buf), sizeof(buf), bytesRead);
+ //printf("rv=%d, bytesRead=%d\n", (int)rv, (int)bytesRead); fflush(stdout);
if(rv)
{
- //printf("rv=%d, bytesRead=%d\n", (int)rv, (int)bytesRead); fflush(stdout);
for(size_t i=0; i<bytesRead; i++)
{
q.push_back(buf[i]);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-running/antpm.git
More information about the Pkg-running-devel
mailing list