Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Codesys Linux SL - Setup of EoE

shaunvdm
2021-08-26
2021-12-06
  • shaunvdm

    shaunvdm - 2021-08-26

    Hi,

    Where can i find information related to setup of ethernet over ethercat.
    Anything special to setup on Linux?

    Regards

     
  • eschwellinger

    eschwellinger - 2021-08-27

    Hi,
    basically you need to use a tap device to do it:

    set up tap0 device

    /sbin/ip tuntap add tap0 mode tap
    /sbin/ip link set tap0 up
    /sbin/ip addr add 192.168.2.1/24 dev tap0

    maybe you need to add a route additional
    echo 1 >/proc/sys/net/ipv4/ip_forward' ...

     
    πŸ‘
    1
  • shaunvdm

    shaunvdm - 2021-11-04

    Hi Edwin,

    Herewith a solution that works to enable the EoE on debian linux.

    Step 1
    Edit the network settings
    nano /etc/network/interfaces

    add the following:

    auto tap0
    iface tap0 inet manual
    
    pre-up ip tuntap add tap0 mode tap user root  # or use a different user profile. 
    up ip link set dev tap0 up
    post-up /usr/local/sbin/enablebr0.sh  # script to enable the br0 bridge
    post-down ip link set dev tap0 down
    down ip link set dev tap0 down
    

    Save the file then

    Make the enablebr0.sh script

    nano /usr/local/sbin/enablebr0.sh
    Contents of script---- Where enp1s0 put your network adaptor name / where the 192.168.0.99/16 put your desired ip address.

    add the following:

    ip link add br0 type bridge
    ip link set tap0 master br0
    ip link set enp1s0 master br0
    ip link set dev br0 up
    ip addr add 192.168.0.99/16 dev br0
    

    Save the script. Remember to make it executable (chmod +x /usr/local/sbin/enablebr0.sh)

    Hope this helps someone.

     

    Last edit: shaunvdm 2021-11-04
  • eschwellinger

    eschwellinger - 2021-11-05

    many thanks for this.

     
  • mrupf

    mrupf - 2021-11-29

    Hi,

    Got lost on this explanation on which IP and adapter goes where.

    In my setting the:
    - EoE device has the IP 192.168.10.10 -> this is what I put into the enablebr0.sh (192.168.10.10/24)
    - EtherCat runs on eth0 -> this is the adapter for enp1s0?
    - eth0 has a IP configured to be 192.168.10.1
    - eth1 has a IP configured to be 192.168.0.50. This is where the PC is connected to the raspberry PI.
    - on my PC I have a route to 192.168.10.0 MASK 255.255.255.0

    With this I'm able to ping 192.168.10.1.

    If I add the tun/tap (accodring to shaunvdm) I'm able to ping 192.168.10.10, but even with EtherCat not running. So I guess I've gone wrong somewhere, as I just ping the br0 bridge.

    Any hints on where I'm going wrong?

     
  • shaunvdm

    shaunvdm - 2021-12-05

    Hi,

    Yes you got this totally mixed up.

    Your EoE address range must be the same as the programming port NOT Ethercat as this uses alias and not IP addresses.

    So in short

    Change the Enablebr0.sh to the programming port address ie 192.168.0.50/16. (In the Network interfaces set the eth1 to manual similar to the tap port (auto eth1 iface eth1 inet manual)
    (This bridge connection replaces your normal Eth1 definition to enable a bridge between Tap and physical interface to Ethercat)

    In Codesys make sure you use the EoE on the 192.168.0.XXX range for the drives or whatever you want to talk to over Ethercat with ethernet protocol.

    No routing required besides the information i provided in my post.

    Let me know....

     
  • mrupf

    mrupf - 2021-12-06

    That clears a lot! Thanks.

    I used 192.168.0.51/24 in the enablebr0.sh.
    This to have a difference between the origin eth1 ip address and the /24 to have the same subnet (255.255.255.0).
    With /16 (255.255.0.0) I had issue on reaching 192.168.0.50. Guess due to missmatch in subnet settings.

    Anyway with this it now runs smooth!
    Two different device EoE parallel and EtherCat (48Byte PDO's to the two slaves) with 4ms.

     

    Last edit: mrupf 2021-12-06

Log in to post a comment.