[etherlab-dev] EtherCAT Mailbox Gateway Server patch

Graeme Foot Graeme.Foot at touchcut.com
Fri Jul 19 07:57:06 CEST 2019


Hi,

I have attached a patch to implement an EtherCAT Mailbox Gateway server.  Florian you may be interested in this as it is on the EtherLab TODO list.

The server provides for UDP and up to 16 TCP connections.  The the UDP and TCP connections are not multi-threaded.

It is based on the specification:
https://www.ethercat.org/memberarea/download/ETG8200_V1i0i0_G_R_MailboxGateway.pdf

It is designed to be used with tools such as:
https://download.beckhoff.com/download/document/automation/twinsafe/twinsafe_loader_en.pdf

Note: the TwinSAFE Loader is a new program that allows you to apply TwinSAFE programs to your TwinSAFE modules without having the modules connected to TwinCAT.  You are still required to use TwinCAT to create the safety programs.  Last I looked there was no download link for the TwinSAFE loader as it is new and Beckhoff are still deciding on licensing, but I got a copy from our local rep.


The server is built on top of the GavinL Etherlab master patchset 20171108.  It integrates into the multiple mailbox protocol patches functionality.  Mailbox datagrams from the Mailbox Gateway server are recognized due to the Mailbox Header address not matching the datagram ADP address.

The server is a user space program named "ethercat_mbg" loosly based on the "ethercat" user space tool (MBG stands for Mailbox Gateway).  The program can be run as a foreground or background task depending on whether you want to run it temporarily or as a daemon.  There is no security incorporated into the protocol so the server will give full access to the slave mailboxes while it is running.  The mailbox gateway listens on port 0x88A4 (34980) should you want to firewall the port.


The Mailbox Gateway protocol requires the EtherCAT master to provide a Master Object Dictionary as specified by ETG.5001.3 (Modular Device Profile Part 3: Fieldbus Gateway Profile Specifications), Annex A:
https://www.ethercat.org/memberarea/download/ETG5001_3_V0i1i2_S_D_MDP_Gateways.pdf

I have implemented all of the optional items, along with A.2.1.3 Diagnosis Data (index 0xAnnn) which is supposed to be optional but seems to be required by the TwinSAFE loader.  I'm not massively happy with the master object dictionary function (ec_master_obj_dict()) as it is handling all of the index:subindex requests in the one function.  However it shouldn't really grow unless someone wants to implement the optional items.

A few things to note:
1) Items 0x8nnn:02 and 0x8nnn:03 of the master object dictionary return 16 and 32 character fixed length strings (respectively) with the extra characters nulled out.  In theory you should be able to return the exact length of the string (as is done by slaves) but the TwinSAFE Loader program seems to require null terminated strings.  The 16 and 32 characters come from matching the returned data from TwinCAT.
2) Item 0x8nnn:04 should return the slave Modular Device Profile.  This information is not available in the slaves SII or from any of the standard SDO indexes (should the slave support SDO access).  It only seems to be available from the slaves ESI xml files which the EtherLab master does not use.  I have hardcoded the standard simple slave Modular Device Profile number of 0x1389 (5001).
3) Item 0x8nnn has a gap in the sub indexes.  At the moment if one of the unspecified sub indexes is requested (9 - 32) I am returning a Subindex does not exist error.  Does anyone know if this is correct, or whether I should return some other value?


I have only tested ethercat_mbg with the TwinSAFE_Loader --list function so far.  It correctly lists an EL6910 TwinSAFE PLC module.  It also sucessfully interacts with slave mailboxes.  I have not done any further testing with the TwinSAFE_Loader yet as I have another project I need to spend some time on.

Gavin, I'm sending this patch now as it looks like you are working on updating your patchset.  I've added this patch as an optional feature (features/mailbox-gateway) with an --enable-mbg build option defaulting to true.  If more people see it as worthwhile it might be worth adding as a base patch.



Regards,


Graeme Foot

Kinetic Engineering Design Ltd.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20190719/d873f0f5/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mailbox-gateway.patch
Type: application/octet-stream
Size: 135887 bytes
Desc: 0001-mailbox-gateway.patch
URL: <http://lists.etherlab.org/pipermail/etherlab-dev/attachments/20190719/d873f0f5/attachment-0001.obj>


More information about the etherlab-dev mailing list