在etherlab官网上的ethercat IGH协议最高版本只到1.5.2,并且只支持linux2.x,3.x内核。对于现在普遍的ubuntu 16.4以上以及debian9以上的Linux发行版来说,都是linux4.x内核,网上的朋友如果参照几年前的帖子进行安装的话,在编译时会出现一系列棘手的BUG,导致走上排解BUG的不归路。
首先,在sourceforge上下载IGH stable-1.5版本,这个是支持linux4.x内核的。附上网址。
https://sourceforge.net/p/etherlabmaster/code/ci/stable-1.5/tree/
点击DownloadSnapshot进行压缩包下载
重命名为简短一点的名字 etherlab-stable1.5.zip
然后按照以下步骤配置,编译,安装即可
1、首先下载所需要的依赖
sudo apt install autoconf automake libtool net-tools
sudo apt-get install linux-headers-$(uname -r)
2、进行编译安装
unzip etherlab-stable1.5.zip
cd ~/etherlab-stable1.5 //注:这个文件夹为解压后重命名的文件夹,原来的名字太长不好记。
./bootstrap
./configure --enable-cycles --enable-hrtimer --enable-8139too=no
make all modules
sudo make modules_install install
sudo depmod
sudo ln -fs /usr/local/etc/init.d/ethercat /etc/init.d/
sudo mkdir /etc/sysconfig
sudo ln -fs /usr/local/etc/sysconfig/ethercat /etc/sysconfig/
sudo -i
echo KERNEL==\"EtherCAT[0-9]*\", MODE=\"0664\" > /etc/udev/rules.d/99-EtherCAT.rules
注意:与1.5.2版本不同,stable-1.5版本已将安装目录/opt/etherlab改为/usr/local
3、进行网络配置
edit /etc/sysconfig/ethercat
MASTER0_DEVICE=”00:0c:29:b4:aa:66” //注:此为ifconfig命令显示的网卡地址,安装时应该为自己的
DEVICE_MODULES=”generic”
4、启动测试
debian@debian:~$ ethercat
Please specify a command!
Usage: ethercat <COMMAND> [OPTIONS] [ARGUMENTS]
Commands (can be abbreviated):
alias Write alias addresses.
config Show slave configurations.
crc CRC error register diagnosis.
cstruct Generate slave PDO information in C language.
data Output binary domain process data.
debug Set the master's debug level.
domains Show configured domains.
download Write an SDO entry to a slave.
eoe Display Ethernet over EtherCAT statictics.
foe_read Read a file from a slave via FoE.
foe_write Store a file on a slave via FoE.
graph Output the bus topology as a graph.
master Show master and Ethernet device information.
pdos List Sync managers, PDO assignment and mapping.
reg_read Output a slave's register contents.
reg_write Write data to a slave's registers.
rescan Rescan the bus.
sdos List SDO dictionaries.
sii_read Output a slave's SII contents.
sii_write Write SII contents to a slave.
slaves Display slaves on the bus.
soe_read Read an SoE IDN from a slave.
soe_write Write an SoE IDN to a slave.
states Request application-layer states.
upload Read an SDO entry from a slave.
version Show version information.
xml Generate slave information XML.
Global options:
--master -m <master> Comma separated list of masters
to select, ranges are allowed.
Examples: '1,3', '5-7,9', '-3'.
Default: '-' (all).
--force -f Force a command.
--quiet -q Output less information.
--verbose -v Output more information.
--help -h Show this help.
Numerical values can be specified either with decimal (no
prefix), octal (prefix '0') or hexadecimal (prefix '0x') base.
Call 'ethercat <COMMAND> --help' for command-specific help.
Send bug reports to fp@igh-essen.com.
表示安装完成,可以接上从站进行测试。
注:若在安装过程中遇到其他问题,可参考我的其他笔记进行解决。