关于can bus id 定义问题

公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

Tip / 登入 to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Translation_Bot
Community Manager
Community Manager
Community Manager

请问关于can bus 的msgObjid、 messageid、topMsgid、bottomMsgid 的解释是什么?

 

g_multican.canMsgObjConfig.msgObjId = (IfxMultican_MsgObjId)currentCanMessageObject;
g_multican.canMsgObjConfig.messageId = g_messageObjectConf[currentCanMessageObject].messageId;
g_multican.canMsgObjConfig.control.topMsgObjId = (2 * currentCanMessageObject) + SRC_EXTENDED_MO_OFFSET; 
g_multican.canMsgObjConfig.control.bottomMsgObjId = g_multican.canMsgObjConfig.control.topMsgObjId + 1;

 

 

smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/%E9%97%9C%E6%96%BCcan-bus-id-%E5%AE%9A%E7%BE%A9%E5%95%8F%E9%A1%8C/td-p/686411

0 点赞
1 解答
Translation_Bot
Community Manager
Community Manager
Community Manager

可以参考下面接收中断的使用方法,如果在中断里进行判断,不会有特别的延时。因为处理器速度远超过CAN总线的波特率。

/* Interrupt Service Routine (ISR) called once the RX interrupt has been generated.
 * Compares the content of the received CAN message with the content of the transmitted CAN message
 * and in case of success, turns on the LED2 to indicate successful CAN message reception.
 */
void canIsrRxHandler(void)
{
    IfxMultican_Status readStatus;

    /* Read the received CAN message and store the status of the operation */
    readStatus = IfxMultican_Can_MsgObj_readMessage(&g_multican.canDstMsgObj, &g_multican.rxMsg);

    /* If no new data has been received, report an error */
    if( !( readStatus & IfxMultican_Status_newData ) )
    {
        while(1)
        {
        }
    }

    /* If new data has been received but with one message lost, report an error */
    if( readStatus == IfxMultican_Status_newDataButOneLost )
    {
        while(1)
        {
        }
    }

    /* Finally, check if the received data matches with the transmitted one */
    if( ( g_multican.rxMsg.data[0] == g_multican.txMsg.data[0] ) &&
        ( g_multican.rxMsg.data[1] == g_multican.txMsg.data[1] ) &&
        ( g_multican.rxMsg.id == g_multican.txMsg.id ) )
    {
        /* Turn on the LED2 to indicate correctness of the received message */
        IfxPort_setPinLow(g_led.led2.port, g_led.led2.pinIndex);
    }
}

smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/%E9%97%9C%E6%96%BCcan-bus-id-%E5%AE%9A%E7%BE%A9%E5%95%8F%E9%A1%8C/m-p/686940

在原帖中查看解决方案

0 点赞
5 回复数
Translation_Bot
Community Manager
Community Manager
Community Manager

Kunqiao_L_0-1706673957597.pngKunqiao_L_1-1706673994056.png

可以参考下他们的注释

smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/%E9%97%9C%E6%96%BCcan-bus-id-%E5%AE%9A%E7%BE%A9%E5%95%8F%E9%A1%8C/m-p/686442

0 点赞
Translation_Bot
Community Manager
Community Manager
Community Manager

谢谢

另外请问msgObjid可以解释为邮箱吗?假设正确一个node可以设置0~255邮箱编号,发送与接收要如何对应呢?

假设发送方由编号1发出,请问要如何确认接收方的邮箱收到呢?

 

 

smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/%E9%97%9C%E6%96%BCcan-bus-id-%E5%AE%9A%E7%BE%A9%E5%95%8F%E9%A1%8C/m-p/686474

0 点赞
Translation_Bot
Community Manager
Community Manager
Community Manager

你好,

message object 应该叫做消息对象,是由一个消息邮箱组成。所以你也可以说他就是邮箱。

发送和接收是你自己来配置消息对象的。每个messageId配置到你的消息对象中。发送方通过将数据消息发送到一个或多个消息对象(Message Object)中来传输数据。接收方需要配置一个或多个消息对象来接收发送方发送的数据。当接收到数据后,接收方会将数据存储在相应的消息对象中。因此,要确认接收方是否收到了消息。

  1. 检查消息对象是否已被占用:在一个消息对象中,只能存储一个消息。如果接收方的消息对象已经被占用,则不能接收新的消息。因此,你需要检查相应的接收消息对象是否已被占用。

  2. 检查接收缓冲器是否有数据:当接收到数据后,接收方会将数据存储在相应的接收缓冲器中。你需要检查接收缓冲器中是否有数据,以确认接收方是否已经接收到数据。

  3. 检查接收缓冲器中的数据是否正确:接收到数据后,你需要检查接收缓冲器中的数据是否正确。如果数据正确,则可以确认接收方已经接收到数据。

可以参考这个示例程序一起看看

MULTICAN_1_KIT_TC275_LK

Kunqiao_L_0-1706681983182.png

 

smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/%E9%97%9C%E6%96%BCcan-bus-id-%E5%AE%9A%E7%BE%A9%E5%95%8F%E9%A1%8C/m-p/686638

0 点赞
Translation_Bot
Community Manager
Community Manager
Community Manager

谢谢回复

目前我遇到的问题,针对第一点,在检查消息对象是否已被占用,我参考范例,在检查消息对象是否已被占用,是以轮循的方式检查message Id 是否正确,导致时间上会没有那么及时,可能针对安全上会有疑虑。

请问是否有针对消息对象的register方便去确认,当接收到数据触发中断后,及时地确认哪一个消息对象被占用呢?

smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/%E9%97%9C%E6%96%BCcan-bus-id-%E5%AE%9A%E7%BE%A9%E5%95%8F%E9%A1%8C/m-p/686759

0 点赞
Translation_Bot
Community Manager
Community Manager
Community Manager

可以参考下面接收中断的使用方法,如果在中断里进行判断,不会有特别的延时。因为处理器速度远超过CAN总线的波特率。

/* Interrupt Service Routine (ISR) called once the RX interrupt has been generated.
 * Compares the content of the received CAN message with the content of the transmitted CAN message
 * and in case of success, turns on the LED2 to indicate successful CAN message reception.
 */
void canIsrRxHandler(void)
{
    IfxMultican_Status readStatus;

    /* Read the received CAN message and store the status of the operation */
    readStatus = IfxMultican_Can_MsgObj_readMessage(&g_multican.canDstMsgObj, &g_multican.rxMsg);

    /* If no new data has been received, report an error */
    if( !( readStatus & IfxMultican_Status_newData ) )
    {
        while(1)
        {
        }
    }

    /* If new data has been received but with one message lost, report an error */
    if( readStatus == IfxMultican_Status_newDataButOneLost )
    {
        while(1)
        {
        }
    }

    /* Finally, check if the received data matches with the transmitted one */
    if( ( g_multican.rxMsg.data[0] == g_multican.txMsg.data[0] ) &&
        ( g_multican.rxMsg.data[1] == g_multican.txMsg.data[1] ) &&
        ( g_multican.rxMsg.id == g_multican.txMsg.id ) )
    {
        /* Turn on the LED2 to indicate correctness of the received message */
        IfxPort_setPinLow(g_led.led2.port, g_led.led2.pinIndex);
    }
}

smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/AURIX/%E9%97%9C%E6%96%BCcan-bus-id-%E5%AE%9A%E7%BE%A9%E5%95%8F%E9%A1%8C/m-p/686940

0 点赞