From cc417d4c0ce6b2de20785217311be726fa0c3298 Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Mon, 10 Jun 2019 09:23:02 +0200 Subject: [PATCH] Add PO2SO hook including context, fixes #230 --- soem/ethercatconfig.c | 4 ++++ soem/ethercatmain.h | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/soem/ethercatconfig.c b/soem/ethercatconfig.c index 08a6ab0..6fb8ad6 100644 --- a/soem/ethercatconfig.c +++ b/soem/ethercatconfig.c @@ -645,6 +645,10 @@ static int ecx_map_coe_soe(ecx_contextt *context, uint16 slave, int thread_n) { context->slavelist[slave].PO2SOconfig(slave); } + if (context->slavelist[slave].PO2SOconfigx) /* only if registered */ + { + context->slavelist[slave].PO2SOconfigx(context, slave); + } /* if slave not found in configlist find IO mapping in slave self */ if (!context->slavelist[slave].configindex) { diff --git a/soem/ethercatmain.h b/soem/ethercatmain.h index 3c39674..42ad54b 100644 --- a/soem/ethercatmain.h +++ b/soem/ethercatmain.h @@ -100,6 +100,8 @@ PACKED_END #define EC_SMENABLEMASK 0xfffeffff +typedef struct ecx_context ecx_contextt; + /** for list of ethercat slaves detected */ typedef struct ec_slave { @@ -225,8 +227,10 @@ typedef struct ec_slave uint8 FMMUunused; /** Boolean for tracking whether the slave is (not) responding, not used/set by the SOEM library */ boolean islost; - /** registered configuration function PO->SO */ + /** registered configuration function PO->SO, (DEPRECATED)*/ int (*PO2SOconfig)(uint16 slave); + /** registered configuration function PO->SO */ + int (*PO2SOconfigx)(ecx_contextt * context, uint16 slave); /** readable name */ char name[EC_MAXNAME + 1]; } ec_slavet; @@ -377,7 +381,6 @@ typedef struct PACKED ec_PDOdesc PACKED_END /** Context structure , referenced by all ecx functions*/ -typedef struct ecx_context ecx_contextt; struct ecx_context { /** port reference, may include red_port */