本篇测评由优秀测评者“qinyunti”提供。 前言本文介绍【米尔MYD-YG2LX开发板】在工控领域的应用,实现基于SOEM的EtherCAT主站。开发环境基于WSL2。
下载代码git clone [url]https://github.com/OpenEtherCATsociety/SOEM[/url]
PC端
编译
cd SOEM/
export CC=gcc
mkdir build_pc
cd build_pc/
cmake .. - lhj@lhj:~/SOEM/build_pc$ cmake ..
- -- The C compiler identification is GNU 9.4.0
- -- Check for working C compiler: /usr/bin/gcc
- -- Check for working C compiler: /usr/bin/gcc -- works
- -- Detecting C compiler ABI info
- -- Detecting C compiler ABI info - done
- -- Detecting C compile features
- -- Detecting C compile features - done
- -- OS is linux
- -- LIB_DIR: lib
- -- Configuring done
- -- Generating done
- -- Build files have been written to: /home/lhj/SOEM/build_pc
- lhj@lhj:~/SOEM/build_pc$
复制代码
make - lhj@lhj:~/SOEM/build_pc$ make
- Scanning dependencies of target soem
- [ 4%] Building C object CMakeFiles/soem.dir/soem/ethercatbase.c.o
- [ 9%] Building C object CMakeFiles/soem.dir/soem/ethercatcoe.c.o
- [ 14%] Building C object CMakeFiles/soem.dir/soem/ethercatconfig.c.o
- [ 19%] Building C object CMakeFiles/soem.dir/soem/ethercatdc.c.o
- [ 23%] Building C object CMakeFiles/soem.dir/soem/ethercateoe.c.o
- [ 28%] Building C object CMakeFiles/soem.dir/soem/ethercatfoe.c.o
- [ 33%] Building C object CMakeFiles/soem.dir/soem/ethercatmain.c.o
- [ 38%] Building C object CMakeFiles/soem.dir/soem/ethercatprint.c.o
- [ 42%] Building C object CMakeFiles/soem.dir/soem/ethercatsoe.c.o
- [ 47%] Building C object CMakeFiles/soem.dir/osal/linux/osal.c.o
- [ 52%] Building C object CMakeFiles/soem.dir/oshw/linux/nicdrv.c.o
- [ 57%] Building C object CMakeFiles/soem.dir/oshw/linux/oshw.c.o
- [ 61%] Linking C static library libsoem.a
- [ 61%] Built target soem
- Scanning dependencies of target simple_ng
- [ 66%] Building C object test/simple_ng/CMakeFiles/simple_ng.dir/simple_ng.c.o
- [ 71%] Linking C executable simple_ng
- [ 71%] Built target simple_ng
- Scanning dependencies of target slaveinfo
- [ 76%] Building C object test/linux/slaveinfo/CMakeFiles/slaveinfo.dir/slaveinfo.c.o
- [ 80%] Linking C executable slaveinfo
- [ 80%] Built target slaveinfo
- Scanning dependencies of target eepromtool
- [ 85%] Building C object test/linux/eepromtool/CMakeFiles/eepromtool.dir/eepromtool.c.o
- [ 90%] Linking C executable eepromtool
- [ 90%] Built target eepromtool
- Scanning dependencies of target simple_test
- [ 95%] Building C object test/linux/simple_test/CMakeFiles/simple_test.dir/simple_test.c.o
- [100%] Linking C executable simple_test
- [100%] Built target simple_test
- lhj@lhj:~/SOEM/build_pc$
复制代码
部署
生成的文件如下
其中libsoem.a为库文件
test/linux/下的
simple_test,slaveinfo,eepromtool为测试Demo。
make - lhj@lhj:~/SOEM/build$ make
- Scanning dependencies of target soem
- [ 4%] Building C object CMakeFiles/soem.dir/soem/ethercatbase.c.o
- [ 9%] Building C object CMakeFiles/soem.dir/soem/ethercatcoe.c.o
- [ 14%] Building C object CMakeFiles/soem.dir/soem/ethercatconfig.c.o
- [ 19%] Building C object CMakeFiles/soem.dir/soem/ethercatdc.c.o
- [ 23%] Building C object CMakeFiles/soem.dir/soem/ethercateoe.c.o
- [ 28%] Building C object CMakeFiles/soem.dir/soem/ethercatfoe.c.o
- [ 33%] Building C object CMakeFiles/soem.dir/soem/ethercatmain.c.o
- [ 38%] Building C object CMakeFiles/soem.dir/soem/ethercatprint.c.o
- [ 42%] Building C object CMakeFiles/soem.dir/soem/ethercatsoe.c.o
- [ 47%] Building C object CMakeFiles/soem.dir/osal/linux/osal.c.o
- [ 52%] Building C object CMakeFiles/soem.dir/oshw/linux/nicdrv.c.o
- [ 57%] Building C object CMakeFiles/soem.dir/oshw/linux/oshw.c.o
- [ 61%] Linking C static library libsoem.a
- [ 61%] Built target soem
- Scanning dependencies of target simple_ng
- [ 66%] Building C object test/simple_ng/CMakeFiles/simple_ng.dir/simple_ng.c.o
- [ 71%] Linking C executable simple_ng
- [ 71%] Built target simple_ng
- Scanning dependencies of target slaveinfo
- [ 76%] Building C object test/linux/slaveinfo/CMakeFiles/slaveinfo.dir/slaveinfo.c.o
- [ 80%] Linking C executable slaveinfo
- [ 80%] Built target slaveinfo
- Scanning dependencies of target eepromtool
- [ 85%] Building C object test/linux/eepromtool/CMakeFiles/eepromtool.dir/eepromtool.c.o
- [ 90%] Linking C executable eepromtool
- [ 90%] Built target eepromtool
- Scanning dependencies of target simple_test
- [ 95%] Building C object test/linux/simple_test/CMakeFiles/simple_test.dir/simple_test.c.o
- [100%] Linking C executable simple_test
- [100%] Built target simple_test
- lhj@lhj:~/SOEM/build$
复制代码
部署
cp libsoem.a /mnt/d
cp test/linux/simple_test/simple_test /mnt/d
cp test/linux/slaveinfo/slaveinfo /mnt/d
将上述文件rz导入开发板
chmod +x simple_test slaveinfo
运行
- root@myir-yg2lx:~# ./slaveinfo eth0
- SOEM (Simple Open EtherCAT Master)
- Slaveinfo
- Starting slaveinfo
- ec_init on eth0 succeeded.
- No slaves found!
- End slaveinfo, close socket
- End program
复制代码- root@myir-yg2lx:~# ./simple_test eth0
- SOEM (Simple Open EtherCAT Master)
- Simple test
- Starting simple test
- ec_init on eth0 succeeded.
- No slaves found!
- End simple test, close socket
- End program
- root@myir-yg2lx:~#
复制代码
总结
本开发板接口资源丰富,性能强,特别适合工控领域的应用,比如作为EtherCAT主站。由于没有从站,所以暂时未能演示和从站通讯的功能。
|