Hi @DanNguyenDuy
I edited my code as below:
void CanIf_Init(void)
{
uint32 u32Idx = 0U;
Std_ReturnType RetVal = E_OK;
static uint8 dummyData[8] = {0,1,2,3,4,5,6,7};
static Flexcan_Ip_DataInfoType TestMsgForm = {
.data_length = 8u,
.msg_id_type = FLEXCAN_MSG_ID_EXT,
.is_polling = true,
#if (FLEXCAN_IP_FEATURE_HAS_FD == STD_ON)
.fd_enable = CAN_IF_FD_EN,
.fd_padding = 0xcc,
#endif
.is_remote = false,
};
CanIf_QueueInit(&CanMsgQueue); /* My own queue, using for restore Can message */
/* Initilize Can driver */
Can_43_FLEXCAN_Init(&Can_43_FLEXCAN_Config_VS_0);
/* Init FlexCan0 Transceiver */
CanIf_TJA1153_Init(0, \
Can_43_FLEXCANConf_CanHardwareObject_CanHardwareObject_4, \
85U, \
84U);
RetVal = Can_43_FLEXCAN_SetControllerMode(Can_43_FLEXCANConf_CanController_CanController_0, CAN_CS_STARTED);
if(RetVal != E_OK)
{
DEBUG_PRINT("Can_43_FLEXCAN_SetControllerMode for FlexCan0 failed, Reason: %u \r\n", RetVal);
}
/* Init FlexCan4 Transceiver */
CanIf_TJA1153_Init(0, \
Can_43_FLEXCANConf_CanHardwareObject_CanHardwareObject_5, \
111U, \
109U);
RetVal = Can_43_FLEXCAN_SetControllerMode(Can_43_FLEXCANConf_CanController_CanController_1, CAN_CS_STARTED);
if(RetVal != E_OK)
{
DEBUG_PRINT("Can_43_FLEXCAN_SetControllerMode for FlexCan4 failed, Reason: %u \r\n", RetVal);
}
/* Use Can_43_FLEXCAN_Write to send via FlexCan0 */
RetVal = CanIf_Send(0, Can_43_FLEXCANConf_CanHardwareObject_CanHardwareObject_4, &TestMsgForm, 1U, dummyData);
if(E_OK != RetVal)
{
DEBUG_PRINT("CanIf_Send for FlexCan0 failed, Reason: %u \r\n", RetVal);
}
/* Use Can_43_FLEXCAN_Write to send via FlexCan4 */
RetVal = CanIf_Send(0, Can_43_FLEXCANConf_CanHardwareObject_CanHardwareObject_5, &TestMsgForm, 2U, dummyData);
if(E_OK != RetVal)
{
DEBUG_PRINT("CanIf_Send for FlexCan0 failed, Reason: %u \r\n", RetVal);
}
/* Use FlexCAN_Ip_SendBlocking to send via FlexCan0 */
RetVal = FlexCAN_Ip_SendBlocking(0, 14, &TestMsgForm, 2U, dummyData, 100);
if(E_OK != RetVal)
{
DEBUG_PRINT("FlexCAN_Ip_SendBlocking for FlexCan0 failed, Reason: %u \r\n", RetVal);
}
/* Use FlexCAN_Ip_SendBlocking to send via FlexCan4 */
RetVal = FlexCAN_Ip_SendBlocking(1, 2, &TestMsgForm, 2U, dummyData, 100);
if(E_OK != RetVal)
{
DEBUG_PRINT("FlexCAN_Ip_SendBlocking for FlexCan0 failed, Reason: %u \r\n", RetVal);
}
}
Std_ReturnType CanIf_Send(uint8 CanController, Can_HwHandleType CanTxHandler, const Flexcan_Ip_DataInfoType *pMsgInfo, uint32 u32MsgId, uint8 *pu8Data)
{
Std_ReturnType RetVal = E_OK;
Can_PduType CanMsg;
uint8 u8Timeout = 10U;
CanMsg.id = u32MsgId;
CanMsg.length = pMsgInfo->data_length;
CanMsg.sdu = pu8Data;
CanMsg.swPduHandle = 123;
u8TxConfirmed = (uint8)FALSE;
RetVal = Can_43_FLEXCAN_Write(CanTxHandler, &CanMsg);
if(E_OK == RetVal)
{
while((u8TxConfirmed == (uint8)FALSE) && (u8Timeout != 0))
{
Can_43_FLEXCAN_MainFunction_Write();
CanIf_DummyDelay(100);
u8Timeout--;
}
if((u8TxConfirmed == (uint8)TRUE) && (u8Timeout == 0U))
{
/* Failed to transmit Can msg */
RetVal = E_NOT_OK;
DEBUG_PRINT("[%s:%d] Timeout to transmit Can msg\r\n",__FUNCTION__,__LINE__);
}
else
{
DEBUG_PRINT("[%s:%d] Transmit done, timeout: %u\r\n",__FUNCTION__,__LINE__,u8Timeout);
}
}
else
{
DEBUG_PRINT("[%s:%d] Can_43_FLEXCAN_Write failed reason: %u\r\n",__FUNCTION__,__LINE__, RetVal);
}
return RetVal;
}
and the result is:

If i use the function Can_43_FLEXCAN_Write to send can msg, both FlexCan0/4 works
But when i use FlexCAN_Ip_SendBlocking to send msg, only FlexCan0 works, even though i used MbIndex:2 for FlexCan4, And you can check the last 2 line in the result pic, when i passed MbIndex:2 to FlexCAN_Ip_SendBlocking, the u32MaxMbNum is not 3 but 0.
Is this a bug or i'm using FlexCAN_Ip_SendBlocking in the wrong way?