From 1f6b820a9619507b8bf6c3a099a19b167e5b7781 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 6 Sep 2020 21:30:14 -0400 Subject: [PATCH] microRusEFI used as Body Control Module BCM BCU --- firmware/hw_layer/drivers/can/can_hw.cpp | 4 ++-- firmware/hw_layer/drivers/can/can_msg_tx.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/firmware/hw_layer/drivers/can/can_hw.cpp b/firmware/hw_layer/drivers/can/can_hw.cpp index dd9bd2507e..1c8fe1b0aa 100644 --- a/firmware/hw_layer/drivers/can/can_hw.cpp +++ b/firmware/hw_layer/drivers/can/can_hw.cpp @@ -28,8 +28,8 @@ EXTERN_ENGINE; static int canReadCounter = 0; -static int canWriteOk = 0; -static int canWriteNotOk = 0; +int canWriteOk = 0; +int canWriteNotOk = 0; static bool isCanEnabled = false; static LoggingWithStorage logger("CAN driver"); diff --git a/firmware/hw_layer/drivers/can/can_msg_tx.cpp b/firmware/hw_layer/drivers/can/can_msg_tx.cpp index 4ed20e37b2..8c8984555c 100644 --- a/firmware/hw_layer/drivers/can/can_msg_tx.cpp +++ b/firmware/hw_layer/drivers/can/can_msg_tx.cpp @@ -17,6 +17,9 @@ EXTERN_CONFIG extern LoggingWithStorage sharedLogger; +extern int canWriteOk; +extern int canWriteNotOk; + /*static*/ CANDriver* CanTxMessage::s_device = nullptr; /*static*/ void CanTxMessage::setDevice(CANDriver* device) { @@ -48,7 +51,12 @@ CanTxMessage::~CanTxMessage() { } // 100 ms timeout - canTransmit(device, CAN_ANY_MAILBOX, &m_frame, TIME_MS2I(100)); + msg_t msg = canTransmit(device, CAN_ANY_MAILBOX, &m_frame, TIME_MS2I(100)); + if (msg == MSG_OK) { + canWriteOk++; + } else { + canWriteNotOk++; + } } uint8_t& CanTxMessage::operator[](size_t index) {