Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethernet over ecat #60

Merged
merged 11 commits into from
Jul 6, 2021
Merged

Ethernet over ecat #60

merged 11 commits into from
Jul 6, 2021

Conversation

XzuluX
Copy link
Contributor

@XzuluX XzuluX commented Mar 31, 2021

Implemented EoE support in order to tunnel ethernet frames through EtherCAT. For this purpose a virtual network device is used (in linux: TAP device). Data written to the virtual network device is forwarded to an Ethernet-Switchport slave (e.g.: Beckhoff EL6601). The Ethernet-Switchport directs the frames to the target. The received data from Ethernet-Switchport slave is written to the TAP interface which injects the data to the network stack.

Virtual network device was only implemented for linux. To keep the master open for extensions the virtDev sub project was introduced. To add virtual device support (network / serial ...) for other platforms the default stub.c implementation, which does nothing, could be replaced with platform dependent code.

It was necessary to modify ScanDevices in order to get EL6601 reliably into PRE OP state.

Added implementation for serial (RS485) handshake communication (Bechhoff EL6021) to serial.h/c.
Added code to create virtual master / slave terminal pair, so any application can connect to a pseudoterminal slave in order to communicate with serial EtherCAT slave in both dircetions.

@Apollo3zehn
Copy link
Owner

Thanks for the PR! This time I will need a little bit longer for review. I think I have a EL6601 terminal available to test it.

@Apollo3zehn
Copy link
Owner

Apollo3zehn commented Jul 6, 2021

I have now gone through the PR and everything I could test works as expected (except one issue which is maybe caused by SOEM). So thanks again for your PR, it is really helpful.

I have only very minor changes which I will apply before merge, I hope you don't mind.

I would like to document here my test results. I did my tests with a EL6601 on a Windows system, so I was not able to test the TAP adapter part on Linux but I have checked the code and found nothing to disagree.

The test setup was: PC (NIC 1) -> EK1100 -> EL6601 (with 1 Ethernet Port) -> PC (NIC 2)

Test results:

  • SendEthernet: success
  • ReceiveEthernet: success (I get one EoE message per received frame with correct lengths. When EL6601 buffer overruns, the lengths do not match anymore but that is unrelated to this PR.)
  • SetEthernetIpSettings: success (here, SOEM may have a small bug, EoE: ecx_EOEsetIp returns false altough it succeeded (with EL6601) OpenEtherCATsociety/SOEM#529)
  • GetEthernetIpSettings: failed. Wireshark says something like "unknown EoE type" and the EL6601 does not send any response to this request. I don't think it is a fault from this PR or SOEM and instead think that the Wireshark filter may be outdated and the EL6601 firmware also. But I am not 100% sure. According to the EtherCAT specs, the frame type set by SOEM is correct and should be known.

After reboot and without calling SetEthernetIpSettings, a device connected to the EL6601 gets its default IP address assigned (169...). According to the spec ("ETG1000 Ecat AL Protocols", Table 85), to enable DHCP, it should be enough do the following:
"If the Master sends Set IP Parameter Request with IP Address '0.0.0.0' the slave should send an DHCP_DISCOVER to get an IP Address. If the slave does not support DHCP it should response with Result 'DHCP' not supported.

Both does not work, i.e. the EL6601 is not sending any DHCP_DISCOVER messages when setting the IP to 0.0.0.0 and it also does not respond with "DHCP not supported".

The datasheet of the EL6601, which is in my opinion not following the specs, contains the following about the TwinCAT EoE settings page: "die Checkbox 'DHCP' ist nicht zu benutzen - die Checkbox 'IP-Address' aktiviert die DHCP/BootP-Funktion in der EL66xx."

If I use the DHCP check box, TwinCAT only sets the MAC address of the EL6601 and according to the spec the slave should either accept it and enable the DHCP client or respond with "DHCP not supported". So the documentation of EL6601 is right, the button "DHCP" should not be used, but that does not fit to the EtherCAT specs.

Finally, when configuring the EL6601 correctly with IP, subnet mask, gateway, dns etc .. then according to the documentation, the EL6601 should serve as an DHCP server to a single device connected to the EL6601's RJ45 port. This works:

Unbenannt2

@Apollo3zehn Apollo3zehn merged commit 4c36909 into Apollo3zehn:dev Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants