Revert "EoE and Distributed clock fixes"

This commit is contained in:
nakarlsson 2020-08-18 14:56:16 +02:00 committed by GitHub
parent 08d480cf82
commit bb82fc33d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 16 deletions

View File

@ -270,7 +270,7 @@ boolean ecx_configdc(ecx_contextt *context)
ecx_BWR(context->port, 0, ECT_REG_DCTIME0, sizeof(ht), &ht, EC_TIMEOUTRET); /* latch DCrecvTimeA of all slaves */ ecx_BWR(context->port, 0, ECT_REG_DCTIME0, sizeof(ht), &ht, EC_TIMEOUTRET); /* latch DCrecvTimeA of all slaves */
mastertime = osal_current_time(); mastertime = osal_current_time();
mastertime.sec -= 946684800UL; /* EtherCAT uses 2000-01-01 as epoch start instead of 1970-01-01 */ mastertime.sec -= 946684800UL; /* EtherCAT uses 2000-01-01 as epoch start instead of 1970-01-01 */
mastertime64 = (((uint64)mastertime.sec * 1000000000) + (uint64)mastertime.usec) * 1000; mastertime64 = (((uint64)mastertime.sec * 1000000) + (uint64)mastertime.usec) * 1000;
for (i = 1; i <= *(context->slavecount); i++) for (i = 1; i <= *(context->slavecount); i++)
{ {
context->slavelist[i].consumedports = context->slavelist[i].activeports; context->slavelist[i].consumedports = context->slavelist[i].activeports;

View File

@ -94,43 +94,45 @@ int ecx_EOEsetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
EOE_HDR_LAST_FRAGMENT); EOE_HDR_LAST_FRAGMENT);
EOEp->frameinfo2 = 0; EOEp->frameinfo2 = 0;
/* The EoE frame will include "empty" IP/DNS entries, makes wireshark happy.
* Specification say they are optional, TwinCAT include empty entries.
*/
if (ipparam->mac_set) if (ipparam->mac_set)
{ {
flags |= EOE_PARAM_MAC_INCLUDE; flags |= EOE_PARAM_MAC_INCLUDE;
memcpy(&EOEp->data[data_offset], ipparam->mac.addr, EOE_ETHADDR_LENGTH); memcpy(&EOEp->data[data_offset], ipparam->mac.addr, EOE_ETHADDR_LENGTH);
data_offset += EOE_ETHADDR_LENGTH;
} }
data_offset += EOE_ETHADDR_LENGTH;
if (ipparam->ip_set) if (ipparam->ip_set)
{ {
flags |= EOE_PARAM_IP_INCLUDE; flags |= EOE_PARAM_IP_INCLUDE;
EOE_ip_uint32_to_byte(&ipparam->ip, &EOEp->data[data_offset]); EOE_ip_uint32_to_byte(&ipparam->ip, &EOEp->data[data_offset]);
data_offset += EOE_IP4_LENGTH;
} }
data_offset += 4;
if (ipparam->subnet_set) if (ipparam->subnet_set)
{ {
flags |= EOE_PARAM_SUBNET_IP_INCLUDE; flags |= EOE_PARAM_SUBNET_IP_INCLUDE;
EOE_ip_uint32_to_byte(&ipparam->subnet, &EOEp->data[data_offset]); EOE_ip_uint32_to_byte(&ipparam->subnet, &EOEp->data[data_offset]);
data_offset += EOE_IP4_LENGTH;
} }
data_offset += 4;
if (ipparam->default_gateway_set) if (ipparam->default_gateway_set)
{ {
flags |= EOE_PARAM_DEFAULT_GATEWAY_INCLUDE; flags |= EOE_PARAM_DEFAULT_GATEWAY_INCLUDE;
EOE_ip_uint32_to_byte(&ipparam->default_gateway, &EOEp->data[data_offset]); EOE_ip_uint32_to_byte(&ipparam->default_gateway, &EOEp->data[data_offset]);
data_offset += EOE_IP4_LENGTH;
} }
data_offset += 4;
if (ipparam->dns_ip_set) if (ipparam->dns_ip_set)
{ {
flags |= EOE_PARAM_DNS_IP_INCLUDE; flags |= EOE_PARAM_DNS_IP_INCLUDE;
EOE_ip_uint32_to_byte(&ipparam->dns_ip, &EOEp->data[data_offset]); EOE_ip_uint32_to_byte(&ipparam->dns_ip, &EOEp->data[data_offset]);
data_offset += EOE_IP4_LENGTH;
} }
data_offset += 4;
if (ipparam->dns_name_set) if (ipparam->dns_name_set)
{ {
/* TwinCAT include EOE_DNS_NAME_LENGTH chars even if name is shorter */
flags |= EOE_PARAM_DNS_NAME_INCLUDE; flags |= EOE_PARAM_DNS_NAME_INCLUDE;
memcpy(&EOEp->data[data_offset], (void *)ipparam->dns_name, EOE_DNS_NAME_LENGTH); memcpy(&EOEp->data[data_offset], (void *)ipparam->dns_name, EOE_DNS_NAME_LENGTH);
data_offset += EOE_DNS_NAME_LENGTH;
} }
data_offset += EOE_DNS_NAME_LENGTH;
EOEp->mbxheader.length = htoes(EOE_PARAM_OFFSET + data_offset); EOEp->mbxheader.length = htoes(EOE_PARAM_OFFSET + data_offset);
EOEp->data[0] = flags; EOEp->data[0] = flags;
@ -229,6 +231,10 @@ int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
} }
else else
{ {
/* The EoE frame will include "empty" IP/DNS entries, makes
* wireshark happy. Specification say they are optional, TwinCAT
* include empty entries.
*/
flags = aEOEp->data[0]; flags = aEOEp->data[0];
if (flags & EOE_PARAM_MAC_INCLUDE) if (flags & EOE_PARAM_MAC_INCLUDE)
{ {
@ -236,36 +242,36 @@ int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
&aEOEp->data[data_offset], &aEOEp->data[data_offset],
EOE_ETHADDR_LENGTH); EOE_ETHADDR_LENGTH);
ipparam->mac_set = 1; ipparam->mac_set = 1;
data_offset += EOE_ETHADDR_LENGTH;
} }
data_offset += EOE_ETHADDR_LENGTH;
if (flags & EOE_PARAM_IP_INCLUDE) if (flags & EOE_PARAM_IP_INCLUDE)
{ {
EOE_ip_byte_to_uint32(&aEOEp->data[data_offset], EOE_ip_byte_to_uint32(&aEOEp->data[data_offset],
&ipparam->ip); &ipparam->ip);
ipparam->ip_set = 1; ipparam->ip_set = 1;
data_offset += EOE_IP4_LENGTH;
} }
data_offset += 4;
if (flags & EOE_PARAM_SUBNET_IP_INCLUDE) if (flags & EOE_PARAM_SUBNET_IP_INCLUDE)
{ {
EOE_ip_byte_to_uint32(&aEOEp->data[data_offset], EOE_ip_byte_to_uint32(&aEOEp->data[data_offset],
&ipparam->subnet); &ipparam->subnet);
ipparam->subnet_set = 1; ipparam->subnet_set = 1;
data_offset += EOE_IP4_LENGTH;
} }
data_offset += 4;
if (flags & EOE_PARAM_DEFAULT_GATEWAY_INCLUDE) if (flags & EOE_PARAM_DEFAULT_GATEWAY_INCLUDE)
{ {
EOE_ip_byte_to_uint32(&aEOEp->data[data_offset], EOE_ip_byte_to_uint32(&aEOEp->data[data_offset],
&ipparam->default_gateway); &ipparam->default_gateway);
ipparam->default_gateway_set = 1; ipparam->default_gateway_set = 1;
data_offset += EOE_IP4_LENGTH;
} }
data_offset += 4;
if (flags & EOE_PARAM_DNS_IP_INCLUDE) if (flags & EOE_PARAM_DNS_IP_INCLUDE)
{ {
EOE_ip_byte_to_uint32(&aEOEp->data[data_offset], EOE_ip_byte_to_uint32(&aEOEp->data[data_offset],
&ipparam->dns_ip); &ipparam->dns_ip);
ipparam->dns_ip_set = 1; ipparam->dns_ip_set = 1;
data_offset += EOE_IP4_LENGTH;
} }
data_offset += 4;
if (flags & EOE_PARAM_DNS_NAME_INCLUDE) if (flags & EOE_PARAM_DNS_NAME_INCLUDE)
{ {
uint16_t dns_len; uint16_t dns_len;
@ -280,8 +286,8 @@ int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
/* Assume ZERO terminated string */ /* Assume ZERO terminated string */
memcpy(ipparam->dns_name, &aEOEp->data[data_offset], dns_len); memcpy(ipparam->dns_name, &aEOEp->data[data_offset], dns_len);
ipparam->dns_name_set = 1; ipparam->dns_name_set = 1;
data_offset += EOE_DNS_NAME_LENGTH;
} }
data_offset += EOE_DNS_NAME_LENGTH;
/* Something os not correct, flag the error */ /* Something os not correct, flag the error */
if(data_offset > eoedatasize) if(data_offset > eoedatasize)
{ {

View File

@ -22,8 +22,6 @@ extern "C"
#define EOE_DNS_NAME_LENGTH 32 #define EOE_DNS_NAME_LENGTH 32
/** Ethernet address length not including VLAN */ /** Ethernet address length not including VLAN */
#define EOE_ETHADDR_LENGTH 6 #define EOE_ETHADDR_LENGTH 6
/** IPv4 address length */
#define EOE_IP4_LENGTH sizeof(uint32_t)
#define EOE_MAKEU32(a,b,c,d) (((uint32_t)((a) & 0xff) << 24) | \ #define EOE_MAKEU32(a,b,c,d) (((uint32_t)((a) & 0xff) << 24) | \
((uint32_t)((b) & 0xff) << 16) | \ ((uint32_t)((b) & 0xff) << 16) | \