Ethercat HAL driver

More
8 years 6 days ago #119428 by Nico2017
Replied by Nico2017 on topic Ethercat HAL driver
Hi,
doing ldd lcec.so
linux-gate.so.1 (0xb7783000)
liblinuxcnchal.so.0 => /usr/lib/liblinuxcnchal.so.0 (0xb7746000)
libethercat.so.1 => /usr/lib/i386-linux-gnu/libethercat.so.1 (0xb773b000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb76e4000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb752d000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb7524000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb7507000)
/lib/ld-linux.so.2 (0xb7785000)

I installed ethercat, using dpkg with github.com/sittner/ec-debianize as I am using debian as it is the OS suggested for linuxcnc. I did try the etherlab installation, building it, without much success as it does not document the file system architecture for debian, during the installation process.

So far I have managed to
-install debian Strech with latest RT prempt kernel : Linux plotter 4.9.0-8-rt-686-pae #1 SMP PREEMPT RT Debian 4.9.110-3+deb9u5 (2018-09-30) i686 GNU/Linux
-install linuxcnc, either 2.7.14 or 2.8.x
-install ethercat using sittner ec-debianize depot ( github.com/sittner/ec-debianize ). After building and installing, Ethercat master and ethercat slaves command work fine
-build and install linuxcnc-ethercat from github.com/sittner/linuxcnc-ethercat (make then sudo make install, or sudo make clean, make then sudo make install if I switch the linuxcnc version to update the kernel)

My problems are:
-when I try to run Linuxcnc 2.7.14 I have a permission denied on Ethercat0 as shown in
LINUXCNC - 2.7.14
Machine configuration directory is '/home/plotter/linuxcnc/configs/LAMGUI'
Machine configuration file is 'lam.ini'
Starting LinuxCNC...
Found file(REL): ./lam-v1.hal
Note: Using POSIX realtime
Failed to open /dev/EtherCAT0: Permission denied
LCEC: requesting master 0 (index 0) failed
lcec: rtapi_app_main: Invalid argument (-22)
./lam-v1.hal:2: waitpid failed /usr/bin/rtapi_app lcec
./lam-v1.hal:2: /usr/bin/rtapi_app exited without becoming ready
./lam-v1.hal:2: insmod for lcec failed, returned -1
Shutting down and cleaning up LinuxCNC...
Note: Using POSIX realtime
LinuxCNC terminated with an error. You can find more information in the log:
/home/plotter/linuxcnc_debug.txt
and
/home/plotter/linuxcnc_print.txt
as well as in the output of the shell command 'dmesg' and in the terminal

-when I build linuxcnc 2.8.x then install it I got
-LINUXCNC - 2.8.0~pre1
Machine configuration directory is '/home/plotter/linuxcnc/configs/LAMGUI'
Machine configuration file is 'lam.ini'
Starting LinuxCNC...
Found file(REL): ./lam-v1.hal
Note: Using POSIX realtime
lcec: dlopen: /usr/lib/linuxcnc/modules/lcec.so: undefined symbol: rtapi_mutex_get
./lam-v1.hal:2: waitpid failed /usr/bin/rtapi_app lcec
./lam-v1.hal:2: /usr/bin/rtapi_app exited without becoming ready
./lam-v1.hal:2: insmod for lcec failed, returned -1
Shutting down and cleaning up LinuxCNC...
Note: Using POSIX realtime
LinuxCNC terminated with an error. You can find more information in the log:
/home/plotter/linuxcnc_debug.txt
and
/home/plotter/linuxcnc_print.txt
as well as in the output of the shell command 'dmesg' and in the terminal

Any advice about how to make either 2.7 or 2.8 working with the ethercat and linuxcnc ethercat driver?
Cheers,

Nicolas

Please Log in or Create an account to join the conversation.

More
8 years 6 days ago - 8 years 6 days ago #119448 by Grotius
Replied by Grotius on topic Ethercat HAL driver
Hi Nico,

Failed to open /dev/EtherCAT0: Permission denied,


Is the file EtherCAT0 in your dev directory on C drive?
I made a empty file EtherCAT0 and placed this in C:dev/

I hope this helps you a little bit.
Last edit: 8 years 6 days ago by Grotius.

Please Log in or Create an account to join the conversation.

More
8 years 5 days ago - 8 years 5 days ago #119494 by Grotius
Replied by Grotius on topic Ethercat HAL driver
Hi,

I have a general question about the Ethercat.comp file used with Linuxcnc.
Here is a sample of 2 found ethercat.comp file's

Version 1. wiki.linuxcnc.org/cgi-bin/wiki.pl?Contri...EtherCAT_Digital_I_O
Version 2. wiki.linuxcnc.org/cgi-bin/wiki.pl?Etherlab

Version 1:
Warning: Spoiler!


Version 2:
Warning: Spoiler!


If you want to compile the ethercat.comp file with latest version of linuxcnc it will not compile.
It has to do with librarie's, and much more. Okey a lot to solve in the component code.

Find out the error code's yourself : sudo halcompile --install ethercat.comp

My idea is to start working on a new ethercat.comp file.
If we get one good ehercat.comp file, that would also a very good Ethercat start option for today's linuxcnc user's i think.
A example : integrating ethercat in a custom made linuxcnc version is now a bit of a problem. In my opinion that is not documented before.

Here is my start of the new component, it compiles without issues :
Warning: Spoiler!
Last edit: 8 years 5 days ago by Grotius.

Please Log in or Create an account to join the conversation.

More
8 years 3 days ago - 7 years 11 months ago #119562 by Nico2017
Replied by Nico2017 on topic Ethercat HAL driver
Hi @Grotius,
it does actually help.
The /dev/Ethercat0 was already there but with some restrained permission so after a sudo chmod a+rwx Ethercat0, the linuxcnc 2.7 and linuxcnc 2.8 were able to carry on.The only issue is I have to do that everytime I log in as the permission seems not to be saved for some reason. Any idea about how I could make the permission permanent?

Edit: to make the /dev/EtherCAT0 usage permanent just do sudo adduser $USER ethercat, and/or sudo adduser root ethercat then you have to reboot (see post askubuntu.com/questions/373096/how-do-i-...ssions-for-dev-ttys0 for a similar case.)

However it did show another error for linuxcnc 2.8, which I believe is link to an error seen on the make of the linuxcnc-ethercat.

Using the linuxcnc-ethercat last commit:
commit b02252a79d11f1c9dd5884bac1a53743b3818d39
Merge: 22bcaa9 333dec5
Author: Sascha Ittner <sascha.ittner@modusoft.de>
Date: Fri Aug 17 16:37:32 2018 +0200

Merge pull request #60 from sittner/add-fsoe-support

Add fsoe support

I obtain
LINUXCNC - 2.8.0~pre1
Machine configuration directory is '/home/laminator/linuxcnc/configs/LAMGUI'
Machine configuration file is 'lam.ini'
Starting LinuxCNC...
Found file(REL): ./lam-v1.hal
Note: Using POSIX realtime
lcec: dlopen: /usr/lib/linuxcnc/modules/lcec.so: undefined symbol: rtapi_mutex_get
./lam-v1.hal:2: waitpid failed /usr/bin/rtapi_app lcec
./lam-v1.hal:2: /usr/bin/rtapi_app exited without becoming ready
./lam-v1.hal:2: insmod for lcec failed, returned -1
Shutting down and cleaning up LinuxCNC...
Note: Using POSIX realtime
LinuxCNC terminated with an error. You can find more information in the log:
/home/laminator/linuxcnc_debug.txt
and
/home/laminator/linuxcnc_print.txt
as well as in the output of the shell command 'dmesg' and in the terminal

Using the linuxcnc-ethercat commit:
commit 7b1e4bb0bb0b5886486b98fc2511b2333402ad0d
Author: Sascha Ittner <sascha@wicky.rb.modusoft.lan>
Date: Sat Mar 10 10:03:44 2018 +0100

use linuxcnc's Makefile.modinc to build RT component

I obtain:

LINUXCNC - 2.8.0~pre1
Machine configuration directory is '/home/laminator/linuxcnc/configs/LAMGUI'
Machine configuration file is 'lam.ini'
Starting LinuxCNC...
Found file(REL): ./lam-v1.hal
Note: Using POSIX realtime
lcec: dlopen: /usr/lib/linuxcnc/modules/lcec.so: undefined symbol: ecrt_slave_config_sdo
./lam-v1.hal:2: waitpid failed /usr/bin/rtapi_app lcec
./lam-v1.hal:2: /usr/bin/rtapi_app exited without becoming ready
./lam-v1.hal:2: insmod for lcec failed, returned -1
Shutting down and cleaning up LinuxCNC...
Note: Using POSIX realtime
LinuxCNC terminated with an error. You can find more information in the log:
/home/laminator/linuxcnc_debug.txt
and
/home/laminator/linuxcnc_print.txt
as well as in the output of the shell command 'dmesg' and in the terminal

I believe this is related to the last post on github.com/sittner/linuxcnc-ethercat/issues/57 > and github.com/sittner/linuxcnc-ethercat/issues/61

Any idea how to avoid this error?

Thanks a lot for the help,
Nicolas
Last edit: 7 years 11 months ago by Nico2017. Reason: More precise answer

Please Log in or Create an account to join the conversation.

More
8 years 3 days ago - 8 years 3 days ago #119566 by Grotius
Replied by Grotius on topic Ethercat HAL driver
Okey guy's,

I have some news. Struggling with include files in hal.
Done some test's. I needed the "/opt/etherlab/include/ecrt.h" to work with linuxcnc hal. In hal we can couple a lot of stuff.
Nothing happened and linuxcnc refused to load dlopen .....
So i start from zero with a sucesfull test to that directory, to print some info.
Next thing will be integrating a bigger file.

in postgui.hal
Code:
loadrt ethercat addf ethercat servo-thread

ethercat component, ethercat.comp :
(compiled in terminal by : sudo halcompile --install ethercat.comp)
Code:
component ethercat"ethercat"; description """ Test Component """; author "Grotius CNC Machines, started Oktober 2018"; license "GPL"; option singleton yes; //Input hal connection : pin in bit Testpin_in "Enable this component"; //Output hal connection : pin out bit Testpin_out "Connect to user gui led"; function _; ;; #include <stdio.h> #include "/opt/etherlab/include/external_file.h" typedef enum { INIT, SELECT} state_T; state_T state = INIT; FUNCTION(_) { switch(state){ case INIT: state = SELECT; break; case SELECT: // do something with the include file function_print(); break; } }

The external_file.h is located in directory : /opt/etherlab/include/external_file.h

The file below is : external_file.h (it is a short file, only containing a function with a print message, for fun, function is in fact : () )
Inside the function we say only print some info :
Code:
#include<stdio.h> int function_print() { printf("external file print"); return 0; }

Output in linuxcnc terminal :


So i think this is a first start to use Ethercat to Linuxcnc hal for me.
Attachments:
Last edit: 8 years 3 days ago by Grotius.

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago #120133 by gbcwbz
Replied by gbcwbz on topic Ethercat HAL driver
Hi Nicolas,

Please refer to IgH Master 1.5.2 Documentation Chapter 9.5

The device nodes will be created with mode 0660 and group root by default. If “nor-
mal” users shall have reading access, a udev rule file (for example /etc/udev/rules.d/99-
EtherCAT.rules) has to be created with the following contents:

Code:
KERNEL ==" EtherCAT [0 -9]*" , MODE ="0664"


Then you can use that device as non-root user.

Regards
Bryan
The following user(s) said Thank You: Nico2017

Please Log in or Create an account to join the conversation.

Time to create page: 0.531 seconds
Powered by Kunena Forum