This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] LP-AM243:EtherCAT 从设备的回调函数何时调用?

Guru**** 2382480 points
Other Parts Discussed in Thread: LP-AM243
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1520962/lp-am243-when-is-the-callback-function-of-an-ethercat-slave-device-called

器件型号:LP-AM243

工具/软件:

你好

我正在使用 LP-AM243电路板评估 EtherCAT 从站堆栈

SDK 版本为 ind_comms_sdk_am243x_09_02_00_08

示例工程使用 EtherCAT 从属设备中的401_Simple。

我注册了用于注册处理数据缓冲区的回调函数、并参考"缓冲区处理 API"一章注册了用户应用回调函数。

InputPD 预读回调:appPreSeqInputPD ()
OutputPD 写前回调:appPreSeqOutputPD ()
加载回调后的 InputPD:appPostSeqInputPD ()
加载回调后的 OutputPD:appPostSeqOutputPD ()
用户应用程序回调: EC_SLV_APP_SS_applicationRun ()

我的问题是、如果我如上所述注册回调函数、那么回调函数的调用顺序是否得到如下保证?

1.帧接收
↓μ s
2. appPreSeqInputPD()
↓μ s
3. appPostSeqInputPD()
↓μ s
4. EC_SLV_APP_SS_applicationRun ()
↓μ s
5. appPreSeqOutputPD ()
↓μ s
6. appPostSeqOutputPD ()

当管理用于进程数据缓冲的标志时,我们担心如果调用回调的顺序与预期不同,例如在 EC_SLV_APP_SS_applicationRun ()之前调用 appPreSeqOutputPD (),则标志管理序列将被中断。

以下是回调函数注册过程的自定义源代码的摘录、供参考。

// InputPD pre-read callback function registration
error = EC_API_SLV_cbRegisterPreSeqInputPDBuffer(
    pApplicationInstance_p->ptEcSlvApi,
    (EC_API_SLV_CBPreSeqInputPD_t)appPreSeqInputPD,
    pApplicationInstance_p
);
if (error != EC_API_eERR_NONE)
{
    OSAL_printf("Register PreSeqInputPD Error code: 0x%08x\r\n", error);
    /* @cppcheck_justify{misra-c2012-15.1} goto is used to assure single point of exit */
    /* cppcheck-suppress misra-c2012-15.1 */
    goto Exit;
}
OSAL_printf("Register PreSeqInputPD Callback\r\n");

// OutputPD pre-write callback function registration
error = EC_API_SLV_cbRegisterPreSeqOutputPDBuffer(
    pApplicationInstance_p->ptEcSlvApi,
    (EC_API_SLV_CBPreSeqOutputPD_t)appPreSeqOutputPD,
    pApplicationInstance_p
);
if (error != EC_API_eERR_NONE)
{
    OSAL_printf("Register PreSeqOutputPD Error code: 0x%08x\r\n", error);
    /* @cppcheck_justify{misra-c2012-15.1} goto is used to assure single point of exit */
    /* cppcheck-suppress misra-c2012-15.1 */
    goto Exit;
}
OSAL_printf("Register PreSeqOutputPD Callback\r\n");

// InputPD Loading Callback Function Registration
error = EC_API_SLV_cbRegisterPostSeqInputPDBuffer(
    pApplicationInstance_p->ptEcSlvApi,
    (EC_API_SLV_CBPostSeqInputPD_t)appPostSeqInputPD,
    pApplicationInstance_p
);
if (error != EC_API_eERR_NONE)
{
    OSAL_printf("Register PostSeqInputPD Error code: 0x%08x\r\n", error);
    /* @cppcheck_justify{misra-c2012-15.1} goto is used to assure single point of exit */
    /* cppcheck-suppress misra-c2012-15.1 */
    goto Exit;
}
OSAL_printf("Register PostSeqInputPD Callback\r\n");

// Register callback function after writing to OutputPD
error = EC_API_SLV_cbRegisterPostSeqOutputPDBuffer(
    pApplicationInstance_p->ptEcSlvApi,
    (EC_API_SLV_CBPostSeqOutputPD_t)appPostSeqOutputPD,
    pApplicationInstance_p
);
if (error != EC_API_eERR_NONE)
{
    OSAL_printf("Register PostSeqOutputPD Error code: 0x%08x\r\n", error);
    /* @cppcheck_justify{misra-c2012-15.1} goto is used to assure single point of exit */
    /* cppcheck-suppress misra-c2012-15.1 */
    goto Exit;
}

// Register callback function User ApplicationRun
EC_API_SLV_cbRegisterUserApplicationRun(
    pApplicationInstance_p->ptEcSlvApi,
    EC_SLV_APP_SS_applicationRun,
    pApplicationInstance_p
);
if (error != EC_API_eERR_NONE)
{
    OSAL_printf("Register EC_SLV_APP_SS_applicationRun Error code: 0x%08x\r\n", error);
    /* @cppcheck_justify{misra-c2012-15.1} goto is used to assure single point of exit */
    /* cppcheck-suppress misra-c2012-15.1 */
    goto Exit;
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好:

    回调执行序列如下所示。

    1.帧接收
    ↓μ s
    2. appPreSeqOutputPD ()
    ↓μ s
    3. appPostSeqOutputPD ()
    ↓μ s
    4. EC_SLV_APP_SS_applicationRun ()
    ↓μ s
    5. appPreSeqInputPD()
    ↓μ s
    6. appPostSeqInputPD()

    此致、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    感谢您的答复。

    我再次检查并发现我的顺序不正确、完全符合您的建议。

    我会再次检查的。

    关于此序列、是否有一种序列顺序相反的情况、例如、当 ESM 处于 OP 状态和5状态时。 在3之前调用 appPreSeqInputPD()。 在一个周期内调用 appPostSeqOutputPD()?

    由于你的 SlaveStack 是作为一个库提供的,我没有办法确认序列是保证的,所以我问这个问题。

    提前感谢您。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好:

    对于 EtherCAT 规范中指定的各种同步模式、序列为 PDO 输出映射>应用> PDO 输入映射。 因此、上述指定的序列在所有同步模式中都应有效。  

    此致、