我用的是STM32F407的开发板,有两路CAN总线,我将两条CAN总线的端子连接起来,想让CAN1发送信号给CAN2,但是并没有成功,发送端卡死在了_can_int_tx()…
发送帧和接收帧的设置是直接抄的官方的参考文档
发送端
msg_can.id = 0x78; /* ID 为 0x78 */
msg_can.ide = RT_CAN_STDID; /* 标准格式 */
msg_can.rtr = RT_CAN_DTR; /* 数据帧 */
msg_can.len = 8; /* 数据长度为 8 */
/* 待发送的 8 字节数据 */
msg_can.data[0] = 'c';
msg_can.data[1] = 'a';
msg_can.data[2] = 'n';
msg_can.data[3] = 's';
msg_can.data[4] = 't';
msg_can.data[5] = 'a';
msg_can.data[6] = 'r';
msg_can.data[7] = '\0';
// send a msg
rt_kprintf("can_send data: %s\r\n", msg_can.data);
rt_sem_release(can_sem[1]);
ret = rt_device_write(can[0], 0, &msg_can, sizeof(msg_can));
接收端
ret = rt_sem_take(can_sem[1], RT_WAITING_FOREVER);
if (ret != -RT_ETIMEOUT) {
rt_kprintf("rt_sem_t -- ret = %d\r\n", ret);
// can test -- set filter
#ifdef RT_CAN_USING_HDR
struct rt_can_filter_item items[5] = {
RT_CAN_FILTER_ITEM_INIT(0x100, 0, 0, 1, 0x700, RT_NULL,RT_NULL), /* std,match ID:0x100~0x1ff,hdr 为-1,设置默认过滤表 */
RT_CAN_FILTER_ITEM_INIT(0x300, 0, 0, 1, 0x700, RT_NULL,RT_NULL), /* std,match ID:0x300~0x3ff,hdr 为 - 1 */
RT_CAN_FILTER_ITEM_INIT(0x211, 0, 0, 1, 0x7ff, RT_NULL,RT_NULL), /* std,match ID:0x211,hdr 为 - 1 */
RT_CAN_FILTER_STD_INIT(0x486, RT_NULL,RT_NULL), /* std,match ID:0x486,hdr 为 - 1 */
{0x555,0,0,1,0x7ff,7,} /* std,match ID:0x555,hdr 为 7,指定设置 7 号过滤表 */
#endif
};
我不知道该怎么解决了
问题找到了,引脚的问题…