From 918a6bad977d20a2abba17485d0b73e7bc75ea90 Mon Sep 17 00:00:00 2001 From: Mikael Heden Date: Fri, 18 Dec 2015 16:04:19 +0100 Subject: [PATCH] DC: change to EtherCAT epoch --- soem/ethercatdc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/soem/ethercatdc.c b/soem/ethercatdc.c index 98ccbf47..f3883d0c 100644 --- a/soem/ethercatdc.c +++ b/soem/ethercatdc.c @@ -292,8 +292,10 @@ boolean ecx_configdc(ecx_contextt *context) context->slavelist[0].hasdc = FALSE; context->grouplist[0].hasdc = FALSE; ht = 0; - mastertime = osal_current_time(); + ecx_BWR(context->port, 0, ECT_REG_DCTIME0, sizeof(ht), &ht, EC_TIMEOUTRET); /* latch DCrecvTimeA of all slaves */ + mastertime = osal_current_time(); + mastertime.sec -= 946684800UL; /* EtherCAT uses 2000-01-01 as epoch start instead of 1970-01-01 */ mastertime64 = (((uint64)mastertime.sec * 1000000) + (uint64)mastertime.usec) * 1000; for (i = 1; i <= *(context->slavecount); i++) {