Linux中EtherCAT主站执行过程

在上层申请主站,完成各种主从站的配置项之后,通过ecrt_master_activate函数调用激活整个EtherCAT总线,ecrt_master_activate函数最主要的工作还是完成状态机的启动。

ecrt_master_activate通过kthread_run创建和运行一个内核进程,该内核进程一直在后台运行下面这个进程函数,这就是ecrt_master_activate完成的主要工作。

接下来EtherCAT的运行主要由内核进程函数执行,只要函数kthread_stop没有被调用,内核线程始终在while (!kthread_should_stop())循环中执行主从站的状态机

/** Master kernel thread function for OPERATION phase.
 */
static int ec_master_operation_thread(void *priv_data)
{
    ec_master_t *master = (ec_master_t *) priv_data;
    ec_slave_t *slave = NULL;
    int fsm_exec;

    EC_MASTER_DBG(master, 1, "Operation thread running"
            " with fsm interval = %u us, max data size=%zu\n",
            master->send_interval, master->max_queue_size);

    while (!kthread_should_stop()) {/*kthread_stop()调用的时候should_stop被置位,跳出while语句退出内核线程*/ 
    /*内核线程使用while语句不断检查主从站的状态机, 很多数据处理和要发送
  • 2
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值