|
|
|
@ -208,14 +208,14 @@ void can_send_thread(std::vector<Panda *> pandas, bool fake_send) { |
|
|
|
|
util::set_thread_name("boardd_can_send"); |
|
|
|
|
|
|
|
|
|
AlignedBuffer aligned_buf; |
|
|
|
|
Context * context = Context::create(); |
|
|
|
|
SubSocket * subscriber = SubSocket::create(context, "sendcan"); |
|
|
|
|
std::unique_ptr<Context> context(Context::create()); |
|
|
|
|
std::unique_ptr<SubSocket> subscriber(SubSocket::create(context.get(), "sendcan")); |
|
|
|
|
assert(subscriber != NULL); |
|
|
|
|
subscriber->setTimeout(100); |
|
|
|
|
|
|
|
|
|
// run as fast as messages come in
|
|
|
|
|
while (!do_exit && check_all_connected(pandas)) { |
|
|
|
|
Message * msg = subscriber->receive(); |
|
|
|
|
std::unique_ptr<Message> msg(subscriber->receive()); |
|
|
|
|
if (!msg) { |
|
|
|
|
if (errno == EINTR) { |
|
|
|
|
do_exit = true; |
|
|
|
@ -223,23 +223,16 @@ void can_send_thread(std::vector<Panda *> pandas, bool fake_send) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
capnp::FlatArrayMessageReader cmsg(aligned_buf.align(msg)); |
|
|
|
|
capnp::FlatArrayMessageReader cmsg(aligned_buf.align(msg.get())); |
|
|
|
|
cereal::Event::Reader event = cmsg.getRoot<cereal::Event>(); |
|
|
|
|
|
|
|
|
|
//Dont send if older than 1 second
|
|
|
|
|
if (nanos_since_boot() - event.getLogMonoTime() < 1e9) { |
|
|
|
|
if (!fake_send) { |
|
|
|
|
for (const auto& panda : pandas) { |
|
|
|
|
panda->can_send(event.getSendcan()); |
|
|
|
|
} |
|
|
|
|
if ((nanos_since_boot() - event.getLogMonoTime() < 1e9) && !fake_send) { |
|
|
|
|
for (const auto& panda : pandas) { |
|
|
|
|
panda->can_send(event.getSendcan()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
delete msg; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
delete subscriber; |
|
|
|
|
delete context; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void can_recv_thread(std::vector<Panda *> pandas) { |
|
|
|
@ -552,7 +545,7 @@ void pigeon_thread(Panda *panda) { |
|
|
|
|
PubMaster pm({"ubloxRaw"}); |
|
|
|
|
bool ignition_last = false; |
|
|
|
|
|
|
|
|
|
Pigeon *pigeon = Hardware::TICI() ? Pigeon::connect("/dev/ttyHS0") : Pigeon::connect(panda); |
|
|
|
|
std::unique_ptr<Pigeon> pigeon(Hardware::TICI() ? Pigeon::connect("/dev/ttyHS0") : Pigeon::connect(panda)); |
|
|
|
|
|
|
|
|
|
std::unordered_map<char, uint64_t> last_recv_time; |
|
|
|
|
std::unordered_map<char, int64_t> cls_max_dt = { |
|
|
|
@ -620,8 +613,6 @@ void pigeon_thread(Panda *panda) { |
|
|
|
|
// 10ms - 100 Hz
|
|
|
|
|
util::sleep_for(10); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
delete pigeon; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) { |
|
|
|
|