pull/32103/head
Shane Smiskol 3 months ago
parent 429613be24
commit 2bb138610e
  1. 2
      common/util.h
  2. 33
      selfdrive/pandad/pandad.cc

@ -4,6 +4,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <iostream>
#include <algorithm> #include <algorithm>
#include <atomic> #include <atomic>
#include <chrono> #include <chrono>
@ -129,6 +130,7 @@ private:
power_failure = (sig == SIGPWR); power_failure = (sig == SIGPWR);
#endif #endif
signal = sig; signal = sig;
std::cout << "!!!!!!!!!!! Caught signal " << sig << " !!!!!!!!!!!" << std::flush;
do_exit = true; do_exit = true;
} }
inline static std::atomic<bool> do_exit = false; inline static std::atomic<bool> do_exit = false;

@ -99,17 +99,18 @@ void can_send_thread(std::vector<Panda *> pandas, bool fake_send) {
capnp::FlatArrayMessageReader cmsg(aligned_buf.align(msg.get())); capnp::FlatArrayMessageReader cmsg(aligned_buf.align(msg.get()));
cereal::Event::Reader event = cmsg.getRoot<cereal::Event>(); cereal::Event::Reader event = cmsg.getRoot<cereal::Event>();
(void)event;
// Don't send if older than 1 second // Don't send if older than 1 second
if ((nanos_since_boot() - event.getLogMonoTime() < 1e9) && !fake_send) { // if ((nanos_since_boot() - event.getLogMonoTime() < 1e9) && !fake_send) {
for (const auto& panda : pandas) { // for (const auto& panda : pandas) {
LOGT("sending sendcan to panda: %s", (panda->hw_serial()).c_str()); //// LOGT("sending sendcan to panda: %s", (panda->hw_serial()).c_str());
panda->can_send(event.getSendcan()); //// panda->can_send(event.getSendcan());
LOGT("sendcan sent to panda: %s", (panda->hw_serial()).c_str()); //// LOGT("sendcan sent to panda: %s", (panda->hw_serial()).c_str());
} // }
} else { // } else {
LOGE("sendcan too old to send: %" PRIu64 ", %" PRIu64, nanos_since_boot(), event.getLogMonoTime()); // LOGE("sendcan too old to send: %" PRIu64 ", %" PRIu64, nanos_since_boot(), event.getLogMonoTime());
} // }
} }
} }
@ -426,6 +427,12 @@ void pandad_run(std::vector<Panda *> &pandas) {
// Start the CAN send thread // Start the CAN send thread
std::thread send_thread(can_send_thread, pandas, fake_send); std::thread send_thread(can_send_thread, pandas, fake_send);
while (!do_exit) {
util::sleep_for(100);
}
send_thread.join();
exit(0);
RateKeeper rk("pandad", 100); RateKeeper rk("pandad", 100);
SubMaster sm({"selfdriveState"}); SubMaster sm({"selfdriveState"});
PubMaster pm({"can", "pandaStates", "peripheralState"}); PubMaster pm({"can", "pandaStates", "peripheralState"});
@ -475,10 +482,10 @@ void pandad_main_thread(std::vector<std::string> serials) {
if (serials.size() == 0) { if (serials.size() == 0) {
serials = Panda::list(); serials = Panda::list();
if (serials.size() == 0) { // if (serials.size() == 0) {
LOGW("no pandas found, exiting"); // LOGW("no pandas found, exiting");
return; // return;
} // }
} }
std::string serials_str; std::string serials_str;

Loading…
Cancel
Save