From ae3a7837bb393679dda753cc2d3b731c683f9d9e Mon Sep 17 00:00:00 2001 From: Andrey Gusakov Date: Thu, 6 Feb 2025 12:25:29 +0300 Subject: [PATCH] can_msg_tx, can_rx: use 1-based CAN indexing for error/verbose messages --- firmware/controllers/can/can_rx.cpp | 4 ++-- firmware/hw_layer/drivers/can/can_msg_tx.cpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/firmware/controllers/can/can_rx.cpp b/firmware/controllers/can/can_rx.cpp index 6bf51b422b..c138c6d7f5 100644 --- a/firmware/controllers/can/can_rx.cpp +++ b/firmware/controllers/can/can_rx.cpp @@ -35,7 +35,7 @@ static void printPacket(const size_t busIndex, const CANRxFrame &rx) { if (CAN_ISX(rx)) { // print extended IDs in hex only efiPrintf("CAN%d RX: ID %07x DLC %d: %02x %02x %02x %02x %02x %02x %02x %02x", - busIndex, + busIndex + 1, id, rx.DLC, rx.data8[0], rx.data8[1], rx.data8[2], rx.data8[3], @@ -43,7 +43,7 @@ static void printPacket(const size_t busIndex, const CANRxFrame &rx) { } else { // internet people use both hex and decimal to discuss packed IDs, for usability it's better to print both right here efiPrintf("CAN%d RX: ID %03x(%d) DLC %d: %02x %02x %02x %02x %02x %02x %02x %02x", - busIndex, + busIndex + 1, id, id, // once in hex, once in dec rx.DLC, rx.data8[0], rx.data8[1], rx.data8[2], rx.data8[3], diff --git a/firmware/hw_layer/drivers/can/can_msg_tx.cpp b/firmware/hw_layer/drivers/can/can_msg_tx.cpp index abbdce926b..a1a1f29e48 100644 --- a/firmware/hw_layer/drivers/can/can_msg_tx.cpp +++ b/firmware/hw_layer/drivers/can/can_msg_tx.cpp @@ -64,9 +64,9 @@ CanTxMessage::~CanTxMessage() { txCanBuffer.put(m_frame); #if EFI_UNIT_TEST - printf("%s Sending CAN bus%d message: ID=%x/l=%x %x %x %x %x %x %x %x %x \n", + printf("%s Sending CAN%d message: ID=%x/l=%x %x %x %x %x %x %x %x %x \n", getCanCategory(category), - busIndex, + busIndex + 1, #ifndef STM32H7XX (unsigned int)((m_frame.IDE == CAN_IDE_EXT) ? CAN_EID(m_frame) : CAN_SID(m_frame)), #else @@ -84,7 +84,7 @@ CanTxMessage::~CanTxMessage() { auto device = s_devices[busIndex]; if (!device) { - criticalError("Send: CAN device not configured busIndex=%d", busIndex); + criticalError("Send: CAN%d device not configured", busIndex + 1); return; } @@ -92,13 +92,13 @@ CanTxMessage::~CanTxMessage() { return; } - bool verboseCan0 = engineConfiguration->verboseCan && busIndex == 0; - bool verboseCan1 = engineConfiguration->verboseCan2 && busIndex == 1; + bool verboseCan0 = engineConfiguration->verboseCan && busIndex == 0; + bool verboseCan1 = engineConfiguration->verboseCan2 && busIndex == 1; if (verboseCan0 || verboseCan1) { - efiPrintf("%s Sending CAN bus%d message: ID=%x/l=%x %x %x %x %x %x %x %x %x", - getCanCategory(category), - busIndex, + efiPrintf("%s Sending CAN%d message: ID=%x/l=%x %x %x %x %x %x %x %x %x", + getCanCategory(category), + busIndex + 1, #ifndef STM32H7XX (unsigned int)((m_frame.IDE == CAN_IDE_EXT) ? CAN_EID(m_frame) : CAN_SID(m_frame)), #else