boardd: set can and pandaState valid flags (#20899)
* boardd: set can and pandaState valid flags * add event * bump cereal * consistencyalbatross
parent
4b7ea0a032
commit
e694f0b4d6
2
cereal
2
cereal
|
@ -1 +1 @@
|
|||
Subproject commit 2acf89ed6fb6444dce2bc738739270bdf6ccb5e4
|
||||
Subproject commit 4ecee78a761c5421a5a677aa802175ca19527426
|
|
@ -358,7 +358,10 @@ void panda_state_thread(bool spoofing_started) {
|
|||
|
||||
// build msg
|
||||
MessageBuilder msg;
|
||||
auto ps = msg.initEvent().initPandaState();
|
||||
auto evt = msg.initEvent();
|
||||
evt.setValid(panda->comms_healthy);
|
||||
|
||||
auto ps = evt.initPandaState();
|
||||
ps.setUptime(pandaState.uptime);
|
||||
|
||||
if (Hardware::TICI()) {
|
||||
|
|
|
@ -152,6 +152,7 @@ int Panda::usb_bulk_read(unsigned char endpoint, unsigned char* data, int length
|
|||
if (err == LIBUSB_ERROR_TIMEOUT) {
|
||||
break; // timeout is okay to exit, recv still happened
|
||||
} else if (err == LIBUSB_ERROR_OVERFLOW) {
|
||||
comms_healthy = false;
|
||||
LOGE_100("overflow got 0x%x", transferred);
|
||||
} else if (err != 0) {
|
||||
handle_usb_issue(err, __func__);
|
||||
|
@ -296,9 +297,11 @@ int Panda::can_receive(kj::Array<capnp::word>& out_buf) {
|
|||
|
||||
size_t num_msg = recv / 0x10;
|
||||
MessageBuilder msg;
|
||||
auto canData = msg.initEvent().initCan(num_msg);
|
||||
auto evt = msg.initEvent();
|
||||
evt.setValid(comms_healthy);
|
||||
|
||||
// populate message
|
||||
auto canData = evt.initCan(num_msg);
|
||||
for (int i = 0; i < num_msg; i++) {
|
||||
if (data[i*4] & 4) {
|
||||
// extended
|
||||
|
|
|
@ -54,6 +54,7 @@ class Panda {
|
|||
~Panda();
|
||||
|
||||
std::atomic<bool> connected = true;
|
||||
std::atomic<bool> comms_healthy = true;
|
||||
cereal::PandaState::PandaType hw_type = cereal::PandaState::PandaType::UNKNOWN;
|
||||
bool has_rtc = false;
|
||||
|
||||
|
|
|
@ -225,6 +225,8 @@ class Controls:
|
|||
|
||||
if len(self.sm['radarState'].radarErrors):
|
||||
self.events.add(EventName.radarFault)
|
||||
elif not self.sm.valid["pandaState"]:
|
||||
self.events.add(EventName.usbError)
|
||||
elif not self.sm.all_alive_and_valid():
|
||||
self.events.add(EventName.commIssue)
|
||||
if not self.logged_comm_issue:
|
||||
|
|
|
@ -672,6 +672,12 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo
|
|||
ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Controls Mismatch"),
|
||||
},
|
||||
|
||||
EventName.usbError: {
|
||||
ET.SOFT_DISABLE: SoftDisableAlert("USB Error: Reboot Your Device"),
|
||||
ET.PERMANENT: NormalPermanentAlert("USB Error: Reboot Your Device", ""),
|
||||
ET.NO_ENTRY: NoEntryAlert("USB Error: Reboot Your Device"),
|
||||
},
|
||||
|
||||
EventName.canError: {
|
||||
ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("CAN Error: Check Connections"),
|
||||
ET.PERMANENT: Alert(
|
||||
|
|
Loading…
Reference in New Issue