我使用的igh-ethercat-master版本是stable-1.6,git clone https://gitlab.com/etherlab.org/ethercat.git进行下载。先按照下面这两个个博客进行preempt-rt和igh-ethercat-master配置, 网页链接分别为:https://blog.csdn.net/Already8888/article/details/136230445和https://blog.csdn.net/qq_34539334/article/details/116152956。preempt-rt版本就按照博客中的来就行,不必要非得和ubuntu20.04的uname -r进行对齐。一般情况下,笔记本电脑上ubuntu系统都已经安装了网卡驱动,ifconfig查看就行。

出现Failed to obtain number of masters: Failed to open master device /dev/EtherCAT0: No such file or directory问题之后,执行下面的5步,一定要重启:

1- sudo modprobe ec_master

2- sudo chmod +x /etc/init.d/ethercat.sh

3- sudo update-rc.d ethercat.sh defaults

4- sudo /etc/init.d/ethercat restart

5- ethercat master

然后成功打印如下:

Master0

Phase: Idle

Active: no

Slaves: 0

Ethernet devices:

Main: b4:67:06:23:de:89 (attached)

Link: UP

Tx frames: 391

Tx bytes: 23460

Rx frames: 0

Rx bytes: 0

Tx errors: 0

Tx frame rate [1/s]: 122 32 6

Tx rate [KByte/s]: 7.1 1.9 0.3

Rx frame rate [1/s]: 0 0 0

Rx rate [KByte/s]: 0.0 0.0 0.0

Common:

Tx frames: 391

一些其他的控制指令:

sudo /etc/init.d/ethercat start  # For init.d based distro,开启主站

sudo /etc/init.d/ethercat stop  # 关闭主站

sudo /etc/init.d/ethercat restart  # 重启主站

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐