CAN transmit acknowledged even though no receiving node.
I want to set up error handling for my CAN messages, and I wanted to start with errors from sending messages to IDs not on the CAN bus net. However, every message I send is acknowledged. There is only stm32 chip set up on the net and the rest are currently TMC Pandrive motors.
I am sending messages to individual motors with different IDs without issue - they're received and the motors react accordingly.
So I am not sure how or why these messages to other CAN IDs are acknowledged.
Below is the code I use in my CAN interface file.
#include <CANInterface.h>
CAN_RxHeaderTypeDef rxHeader;
CAN_TxHeaderTypeDef txHeader;
std::vector<uint8_t> canRX(7, 0);
CAN_FilterTypeDef canfil;
uint32_t canMailbox;
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan1) {
std::vector<char> sendBuf(60, 0);
uint8_t bufLen = sprintf(sendBuf.data(), "response triggered\r\n");
HAL_UART_Transmit(&huart5, (uint8_t *)sendBuf.data(), bufLen, 200);
HAL_CAN_GetRxMessage(hcan1, CAN_RX_FIFO0, &rxHeader, canRX.data());
}
void sendCANMessage(uint8_t component, std::vector<uint8_t> canMessage) {
txHeader.StdId = component;
HAL_StatusTypeDef status = HAL_CAN_AddTxMessage(&hcan1, &txHeader, canMessage.data(), &canMailbox);
std::vector<char> sendBuf(60, 0);
uint8_t bufLen = sprintf(sendBuf.data(), "status: %d\r\n", status);
HAL_UART_Transmit(&huart5, (uint8_t *)sendBuf.data(), bufLen, 200);
}
void CANSetup() {
txHeader.DLC = 7;
txHeader.StdId = 0x02;
txHeader.IDE = CAN_ID_STD;
txHeader.RTR = CAN_RTR_DATA;
txHeader.TransmitGlobalTime = DISABLE;
canfil.FilterFIFOAssignment = CAN_FILTER_FIFO0;
canfil.FilterIdHigh = (1 << 5);
canfil.FilterIdLow = 0;
canfil.FilterMaskIdHigh = 0;
canfil.FilterMaskIdLow = 0;
canfil.FilterScale = CAN_FILTERSCALE_16BIT;
canfil.FilterBank = 14;
canfil.SlaveStartFilterBank = 0;
canfil.FilterActivation = ENABLE;
HAL_CAN_ConfigFilter(&hcan1, &canfil);
HAL_CAN_Start(&hcan1);
HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING);
}

