Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include address when raising timeout exception #17

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions include/crazyflie_cpp/Crazyflie.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,15 @@ class Crazyflie
return reinterpret_cast<const R*>(m_batchRequests[index].ack.data);
}

void throwTimeout()
{
std::stringstream message;
int lastbyte = 0xFF & m_address;
message << "timeout for Crazyflie " << std::hex << m_address
<< " (last byte " << std::dec << lastbyte << ")";
throw std::runtime_error(message.str().c_str());
}

private:
struct logInfo {
uint8_t len;
Expand Down
14 changes: 7 additions & 7 deletions src/Crazyflie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ void Crazyflie::writeFlash(
// auto end = std::chrono::system_clock::now();
// std::chrono::duration<double> elapsedSeconds = end-start;
// if (elapsedSeconds.count() > 1.0) {
// throw std::runtime_error("timeout");
// throwTimeout();
// }
// }
offset += requestedSize;
Expand Down Expand Up @@ -501,7 +501,7 @@ void Crazyflie::writeFlash(
sendPacketOrTimeout(req, false);
++tries;
if (tries > 5) {
throw std::runtime_error("timeout");
throwTimeout();
}
}
}
Expand Down Expand Up @@ -1033,7 +1033,7 @@ bool Crazyflie::sendPacketInternal(
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsedSeconds = end-start;
if (elapsedSeconds.count() > timeout) {
throw std::runtime_error("timeout");
throwTimeout();
}
}
}
Expand Down Expand Up @@ -1302,7 +1302,7 @@ void Crazyflie::handleRequests(
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsedSeconds = end-start;
if (elapsedSeconds.count() > timeout) {
throw std::runtime_error("timeout");
throwTimeout();
}
// std::cout << "send req " << requestIdx << std::endl;
} while (!ack.ack);
Expand All @@ -1318,7 +1318,7 @@ void Crazyflie::handleRequests(
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsedSeconds = end-start;
if (elapsedSeconds.count() > timeout) {
throw std::runtime_error("timeout");
throwTimeout();
}
// std::cout << "send ping " << m_numRequestsEnqueued << std::endl;
}
Expand All @@ -1334,7 +1334,7 @@ void Crazyflie::handleRequests(
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsedSeconds = end-start;
if (elapsedSeconds.count() > timeout) {
throw std::runtime_error("timeout");
throwTimeout();
}
}
}
Expand All @@ -1354,7 +1354,7 @@ void Crazyflie::handleRequests(
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsedSeconds = end-start;
if (elapsedSeconds.count() > timeout) {
throw std::runtime_error("timeout");
throwTimeout();
}
}

Expand Down