grotius-cnc / hal-core

cnc and robot realtime controller. runs on a hal kernel module.
GNU General Public License v2.0
43 stars 20 forks source link

./runtest from ethercat #14

Closed jjrbfi closed 3 years ago

jjrbfi commented 3 years ago

When running ./runtest from ethercat directory after doing make and changing the ethercat-conf.xml to my actual configuration, I got:

pi@linuxcnc:/opt/hal-core/src/hal/components/ethercat $ ./runtest 
./runtest: line 4: /opt/hal-core/scripts/.: Is a directory
threads: already exists
/opt/hal-core/rtlib/./lcec_conf: error while loading shared libraries: libhalcore.so.0: cannot open shared object file: No such file or directory
Failed to register PDO entry: No such file or directory
LCEC: master 0 PDO entry registration failed
lcec: rtapi_app_main: Invalid argument (-22)
<commandline>:0: waitpid failed /usr/bin/rtapi_app lcec
<commandline>:0: /usr/bin/rtapi_app exited without becoming ready
<commandline>:0: insmod for lcec failed, returned -1
./runtest: line 15: =: No such file or directory
./runtest: line 16: =: No such file or directory
./runtest: line 17: =: No such file or directory
HAL: ERROR: function 'lcec.read-all' not found
<commandline>:0: addf failed
HAL: ERROR: function 'lcec.write-all' not found
<commandline>:0: addf failed
Loaded HAL Components:
ID      Type  Name                                            PID   State
    38  User  halcmd471                                         471 ready
     6  RT    __servo-thread                                        ready
     5  RT    __base-thread                                         ready
     4  RT    threads                                               ready

Component Pins:
Owner   Type  Dir         Value  Name
     5  s32   OUT             0  base-thread.time
     6  s32   OUT             0  servo-thread.time

Pin Aliases:
 Alias                                            Original Name

Signals:
Type          Value  Name     (linked to)

Parameters:
Owner   Type  Dir         Value  Name
     5  s32   RW              0  base-thread.tmax
     6  s32   RW              0  servo-thread.tmax

Parameter Aliases:
 Alias                                            Original Name

Exported Functions:
Owner   CodeAddr  Arg       FP   Users  Name

Realtime Threads:
     Period  FP     Name               (     Time, Max-Time )
     990000  YES          servo-thread (        0,        0 )
      30000  NO            base-thread (        0,        0 )

My ethercat-conf.conf

<masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="5">
<slave idx="0" type="EK1100"/>
<slave idx="1" type="EL1008"/>
<slave idx="2" type="EL1008"/>
<slave idx="3" type="EL1008"/>
<slave idx="4" type="EL1008"/>
<slave idx="5" type="EL2008"/>
<slave idx="6" type="EL2008"/>
<slave idx="7" type="EL7342"/>
<slave idx="8" type="EL7342"/>
<slave idx="9" type="EL9576"/>
<slave idx="10" type="EL6900">
  <modParam name="fsoeSlaveIdx" value="11"/>
  <modParam name="fsoeSlaveIdx" value="12"/>
</slave>
<slave idx="11" type="EL1904"/>
<slave idx="12" type="EL2904"/>
<slave idx="13" type="EL9505"/>
</master>
</masters>
grotius-cnc commented 3 years ago

ok just a moment

grotius-cnc commented 3 years ago

I changed the runtest file at line 4. My fault. Now in terminal do a : /opt/hal-core/scripts/halrun -U Then try it again.

jjrbfi commented 3 years ago

More less same:

Note: Using POSIX realtime
rtapi_shmem_new failed due to shmget(key=0xacb572c7): Invalid argument
lcec_conf: ERROR: couldn't allocate user/RT shared memory
lcec: dlopen: /opt/hal-core/rtlib/lcec.so: undefined symbol: lcec_el7031_init
<commandline>:0: waitpid failed /opt/hal-core/bin/rtapi_app lcec
<commandline>:0: /opt/hal-core/bin/rtapi_app exited without becoming ready
<commandline>:0: insmod for lcec failed, returned -1
./runtest: line 15: =: No such file or directory
./runtest: line 16: =: No such file or directory
./runtest: line 17: =: No such file or directory
HAL: ERROR: function 'lcec.read-all' not found
<commandline>:0: addf failed
HAL: ERROR: function 'lcec.write-all' not found
<commandline>:0: addf failed

I have to take a close look.

Here is the actual runtest file:

#!/usr/bin/bash

# Startup hal-core
cd /opt/hal-core/scripts/ && . ./rip-environment

cd /opt/hal-core/bin

halcmd stop
halcmd loadrt threads name1=base-thread fp1=0 period1=300000 name2=servo-thread period2=1000000

# Unix command to load the ethercat .xml config
/opt/hal-core/rtlib/./lcec_conf /opt/hal-core/rtlib/ethercat-conf.xml &
halcmd loadrt lcec

halcmd net ec-slaves-responding <= lcec.slaves-responding
halcmd net ec-link-up <= lcec.link-up
halcmd net ec-all-op <= lcec.all-op

halcmd addf lcec.read-all servo-thread
halcmd addf lcec.write-all servo-thread

halcmd start

halcmd show

# To clean the hal environment :
# $ /opt/hal-core$ /opt/linuxcnc/scripts/halrun -U

I will try to do again all from scratch and removing all old .so files. But I think you remove those few commits before.

grotius-cnc commented 3 years ago

I see you apptime period is different then base thread. Try to match it.

grotius-cnc commented 3 years ago

lcec_el7031_init I will check if this one is compiled within the lcec.so command..

jjrbfi commented 3 years ago

Yes I got same error right now

grotius-cnc commented 3 years ago

The 7031 It is not inlcuded here : https://github.com/grotius-cnc/hal-core/blob/main/src/hal/components/ethercat/make Can you include it, and recompile.

jjrbfi commented 3 years ago

Looks like is located just in those files:

Binary file lcec_main.o matches
lcec_el70x1.h:int lcec_el7031_init(int comp_id, struct lcec_slave *slave, ec_pdo_entry_reg_t *pdo_entry_regs);
Binary file lcec.so matches
lcec_el70x1.c:int lcec_el7031_init(int comp_id, struct lcec_slave *slave, ec_pdo_entry_reg_t *pdo_entry_regs) {
lcec_main.c:  { lcecSlaveTypeEL7031, LCEC_EL70x1_VID, LCEC_EL7031_PID, LCEC_EL70x1_PDOS, lcec_el7031_init},
jjrbfi commented 3 years ago

I have to go. I will continue tomorrow.

Thanks again for all! And great work you have made. :)

grotius-cnc commented 3 years ago

I can't remember, but was the 7031 already present in the source? or did you add it?

grotius-cnc commented 3 years ago

Ok. bybye see you !! Thanks.

grotius-cnc commented 3 years ago

Hi, just a tip. Start with only the buscoupler to test if your ethercat is working, then add the first slave in the xml etc. It is possible that your modified driver has a issue. To track that down. You could start with the original ethercat source code. If that works, replace it with the edited code etc.

Good luck !

jjrbfi commented 3 years ago

Hello, I just come to start here again. I couldn't yesterday. I will check the differences between your ethercat Drivers fork and the original once to test it.

Thanks!

Regards :)

jjrbfi commented 3 years ago

All working after added new drivers in make file. Already pushed all changes!

Thanks!