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

cross mob
DevinHuang
Level 3
Level 3
Distributor - Weikeng(GC)
100 sign-ins 10 replies posted 5 replies posted

請問關於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;

 

 

1 解決方案
Di_W
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 100 likes received

可以参考下面接收中断的使用方法,如果在中断里进行判断,不会有特别的延时。因为处理器速度远超过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);
    }
}

在原始文章中檢視解決方案

0
5 回應
Kunqiao_L
Moderator
Moderator
Moderator
First comment on blog First like given 25 likes received

Kunqiao_L_0-1706673957597.pngKunqiao_L_1-1706673994056.png

可以参考下他们的注释

0
DevinHuang
Level 3
Level 3
Distributor - Weikeng(GC)
100 sign-ins 10 replies posted 5 replies posted

謝謝

另外請問msgObjid可以解釋為郵箱嗎?假設正確一個node可以設置0~255郵箱編號,發送與接收要如何對應呢?

假設發送方由編號1發出,請問要如何確認接收方的郵箱收到呢?

 

 

0
Kunqiao_L
Moderator
Moderator
Moderator
First comment on blog First like given 25 likes received

你好,

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

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

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

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

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

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

MULTICAN_1_KIT_TC275_LK 

Kunqiao_L_0-1706681983182.png

 

0
DevinHuang
Level 3
Level 3
Distributor - Weikeng(GC)
100 sign-ins 10 replies posted 5 replies posted

謝謝回復

目前我遇到的問題,針對第一點,在检查消息对象是否已被占用,我參考範例,在检查消息对象是否已被占用,是以輪循的方式檢查message Id 是否正確,導致時間上會沒有那麼及時,可能針對安全上會有疑慮。

請問是否有針對消息对象的register方便去確認,當接收到数据觸發中斷后,及時地確認哪一個消息对象被佔用呢?

0
Di_W
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 100 likes received

可以参考下面接收中断的使用方法,如果在中断里进行判断,不会有特别的延时。因为处理器速度远超过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);
    }
}
0