boardd: move main() to main.cc for test cases (#23564)

* move main() to main.cc

* move includes back
pull/23567/head
Dean Lee 2022-01-18 21:59:42 +08:00 committed by GitHub
parent f76328b426
commit 498d54be9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 17 deletions

View File

@ -88,6 +88,8 @@ selfdrive/boardd/.gitignore
selfdrive/boardd/SConscript
selfdrive/boardd/__init__.py
selfdrive/boardd/boardd.cc
selfdrive/boardd/boardd.h
selfdrive/boardd/main.cc
selfdrive/boardd/boardd.py
selfdrive/boardd/boardd_api_impl.pyx
selfdrive/boardd/can_list_to_can_capnp.cc

View File

@ -1,7 +1,7 @@
Import('env', 'envCython', 'common', 'cereal', 'messaging')
libs = ['usb-1.0', common, cereal, messaging, 'pthread', 'zmq', 'capnp', 'kj']
env.Program('boardd', ['boardd.cc', 'panda.cc', 'pigeon.cc'], LIBS=libs)
env.Program('boardd', ['main.cc', 'boardd.cc', 'panda.cc', 'pigeon.cc'], LIBS=libs)
env.Library('libcan_list_to_can_capnp', ['can_list_to_can_capnp.cc'])
envCython.Program('boardd_api_impl.so', 'boardd_api_impl.pyx', LIBS=["can_list_to_can_capnp", 'capnp', 'kj'] + envCython["LIBS"])

View File

@ -1,3 +1,5 @@
#include "selfdrive/boardd/boardd.h"
#include <sched.h>
#include <sys/cdefs.h>
#include <sys/resource.h>
@ -27,7 +29,6 @@
#include "selfdrive/common/util.h"
#include "selfdrive/hardware/hw.h"
#include "selfdrive/boardd/panda.h"
#include "selfdrive/boardd/pigeon.h"
// -- Multi-panda conventions --
@ -590,23 +591,12 @@ void pigeon_thread(Panda *panda) {
}
}
int main(int argc, char *argv[]) {
LOGW("starting boardd");
if (!Hardware::PC()) {
int err;
err = util::set_realtime_priority(54);
assert(err == 0);
err = util::set_core_affinity({Hardware::TICI() ? 4 : 3});
assert(err == 0);
}
LOGW("attempting to connect");
PubMaster pm({"pandaStates", "peripheralState"});
std::vector<std::string> serials(argv + 1, argv + argc);
void boardd_main_thread(std::vector<std::string> serials) {
if (serials.size() == 0) serials.push_back("");
PubMaster pm({"pandaStates", "peripheralState"});
LOGW("attempting to connect");
// connect to all provided serials
std::vector<Panda *> pandas;
for (int i = 0; i < serials.size() && !do_exit; /**/) {

View File

@ -0,0 +1,6 @@
#pragma once
#include "selfdrive/boardd/panda.h"
bool safety_setter_thread(std::vector<Panda *> pandas);
void boardd_main_thread(std::vector<std::string> serials);

View File

@ -0,0 +1,22 @@
#include <cassert>
#include "selfdrive/boardd/boardd.h"
#include "selfdrive/common/swaglog.h"
#include "selfdrive/common/util.h"
#include "selfdrive/hardware/hw.h"
int main(int argc, char *argv[]) {
LOGW("starting boardd");
if (!Hardware::PC()) {
int err;
err = util::set_realtime_priority(54);
assert(err == 0);
err = util::set_core_affinity({Hardware::TICI() ? 4 : 3});
assert(err == 0);
}
std::vector<std::string> serials(argv + 1, argv + argc);
boardd_main_thread(serials);
return 0;
}