<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif; ">
<div>Hi All,</div>
<div><br>
</div>
<div>I am having some issues with CoE on my Copley Accelnet controllers. CoE reads seem to be working fine, but CoE writes work sometimes, but most of the time they do not. So, first the setup.</div>
<div><br>
</div>
<div>Linux imcs-ecat-450 3.2.21-xenomai-2.6.2.1 #1 SMP PREEMPT Fri Oct 18 14:13:46 CDT 2013 x86_64 GNU/Linux</div>
<div>Realtek NIC</div>
<div>Etherlab is latest in 1.5 stable branch</div>
<div>Running in user land</div>
<div>78 ethercat slaves, 24 of which are single axis copley controllers. The rest are Beckhoff I/O.</div>
<div><br>
</div>
<div>The operations to the Copley I am testing are get/set acceleration and velocity. The get operations work reliably. The last message in the dmseg dump below is displayed when the write fails, which is most of the time. What's weird is once the write
operations start working, they keep working. </div>
<div><br>
</div>
<div>
<div>[14785.862445] EtherCAT: Requesting master 0...</div>
<div>[14785.862453] EtherCAT: Successfully requested master 0.</div>
<div>[14786.023965] EtherCAT 0: Domain0: Logical address 0x00000000, 163 byte, expected working counter 24.</div>
<div>[14786.023969] EtherCAT 0: Datagram domain0-0-main: Logical offset 0x00000000, 163 byte, type LRW.</div>
<div>[14786.023973] EtherCAT 0: Domain1: Logical address 0x000000a3, 19 byte, expected working counter 11.</div>
<div>[14786.023976] EtherCAT 0: Datagram domain1-163-main: Logical offset 0x000000a3, 19 byte, type LRW.</div>
<div>[14786.023980] EtherCAT 0: Domain2: Logical address 0x000000b6, 13 byte, expected working counter 9.</div>
<div>[14786.023982] EtherCAT 0: Datagram domain2-182-main: Logical offset 0x000000b6, 13 byte, type LRW.</div>
<div>[14786.023986] EtherCAT 0: Domain3: Logical address 0x000000c3, 49 byte, expected working counter 11.</div>
<div>[14786.023988] EtherCAT 0: Datagram domain3-195-main: Logical offset 0x000000c3, 49 byte, type LRW.</div>
<div>[14786.023991] EtherCAT 0: Domain4: Logical address 0x000000f4, 60 byte, expected working counter 8.</div>
<div>[14786.023994] EtherCAT 0: Datagram domain4-244-main: Logical offset 0x000000f4, 60 byte, type LRW.</div>
<div>[14786.023997] EtherCAT 0: Domain5: Logical address 0x00000130, 84 byte, expected working counter 12.</div>
<div>[14786.024000] EtherCAT 0: Datagram domain5-304-main: Logical offset 0x00000130, 84 byte, type LWR.</div>
<div>[14786.024003] EtherCAT 0: Domain6: Logical address 0x00000184, 84 byte, expected working counter 12.</div>
<div>[14786.024006] EtherCAT 0: Datagram domain6-388-main: Logical offset 0x00000184, 84 byte, type LRD.</div>
<div>[14786.024009] EtherCAT 0: Domain7: Logical address 0x000001d8, 84 byte, expected working counter 12.</div>
<div>[14786.024012] EtherCAT 0: Datagram domain7-472-main: Logical offset 0x000001d8, 84 byte, type LWR.</div>
<div>[14786.024015] EtherCAT 0: Domain8: Logical address 0x0000022c, 84 byte, expected working counter 12.</div>
<div>[14786.024018] EtherCAT 0: Datagram domain8-556-main: Logical offset 0x0000022c, 84 byte, type LRD.</div>
<div>[14786.024021] EtherCAT 0: Domain9: Logical address 0x00000280, 49 byte, expected working counter 7.</div>
<div>[14786.024032] EtherCAT 0: Datagram domain9-640-main: Logical offset 0x00000280, 49 byte, type LWR.</div>
<div>[14786.024036] EtherCAT 0: Domain10: Logical address 0x000002b1, 49 byte, expected working counter 7.</div>
<div>[14786.024038] EtherCAT 0: Datagram domain10-689-main: Logical offset 0x000002b1, 49 byte, type LRD.</div>
<div>[14786.024041] EtherCAT 0: Domain11: Logical address 0x000002e2, 7 byte, expected working counter 1.</div>
<div>[14786.024044] EtherCAT 0: Datagram domain11-738-main: Logical offset 0x000002e2, 7 byte, type LWR.</div>
<div>[14786.024047] EtherCAT 0: Domain12: Logical address 0x000002e9, 7 byte, expected working counter 1.</div>
<div>[14786.024049] EtherCAT 0: Datagram domain12-745-main: Logical offset 0x000002e9, 7 byte, type LRD.</div>
<div>[14786.024063] EtherCAT 0: Master thread exited.</div>
<div>[14786.024066] EtherCAT 0: Starting EtherCAT-OP thread.</div>
<div>[14786.025804] EtherCAT WARNING 0: No app_time received up to now, but master already active.</div>
<div>[14786.033014] EtherCAT 0: Domain 0: Working counter changed to 1/24.</div>
<div>[14786.388934] EtherCAT 0: Domain 5: Working counter changed to 1/12.</div>
<div>[14786.388938] EtherCAT 0: Domain 6: Working counter changed to 1/12.</div>
<div>[14786.834689] EtherCAT 0: Domain 1: Working counter changed to 1/11.</div>
<div>[14786.960483] EtherCAT 0: Domain 7: Working counter changed to 1/12.</div>
<div>[14786.960982] EtherCAT 0: Domain 8: Working counter changed to 1/12.</div>
<div>[14787.032363] EtherCAT 0: Domain 0: 18 working counter changes - now 24/24.</div>
<div>[14787.387777] EtherCAT 0: Domain 5: 11 working counter changes - now 12/12.</div>
<div>[14787.387781] EtherCAT 0: Domain 6: 11 working counter changes - now 12/12.</div>
<div>[14787.440695] EtherCAT 0: Domain 9: Working counter changed to 1/7.</div>
<div>[14787.440698] EtherCAT 0: Domain 10: Working counter changed to 1/7.</div>
<div>[14787.685284] EtherCAT 0: Domain 2: Working counter changed to 1/9.</div>
<div>[14787.779137] EtherCAT 0: Domain 11: Working counter changed to 1/1.</div>
<div>[14787.779140] EtherCAT 0: Domain 12: Working counter changed to 1/1.</div>
<div>[14787.786119] EtherCAT 0: Domain 3: Working counter changed to 1/11.</div>
<div>[14787.834040] EtherCAT 0: Domain 1: 5 working counter changes - now 11/11.</div>
<div>[14787.880966] EtherCAT 0: Domain 4: Working counter changed to 1/8.</div>
<div>[14787.959831] EtherCAT 0: Domain 7: 11 working counter changes - now 12/12.</div>
<div>[14787.959834] EtherCAT 0: Domain 8: 11 working counter changes - now 12/12.</div>
<div>[14787.970600] EtherCAT 0: Slave states on main device: OP.</div>
<div>[14788.440065] EtherCAT 0: Domain 9: 6 working counter changes - now 7/7.</div>
<div>[14788.440068] EtherCAT 0: Domain 10: 6 working counter changes - now 7/7.</div>
<div>[14788.684660] EtherCAT 0: Domain 2: 6 working counter changes - now 9/9.</div>
<div>[14788.785493] EtherCAT 0: Domain 3: 7 working counter changes - now 11/11.</div>
<div>[14788.880334] EtherCAT 0: Domain 4: 5 working counter changes - now 8/8.</div>
<div>[14816.612788] EtherCAT ERROR 0-25: Timeout after 1000 ms while waiting for SDO 0x6083:0 download response.</div>
<div><br>
</div>
</div>
<div>Below is the function which does the CoE processing. </div>
<div><br>
</div>
<div>struct SDORecord {</div>
<div>
<div> ec_sdo_request_t* sdo;</div>
<div> ec_direction_t direction;</div>
<div> bool inProgress;</div>
<div> bool ioError;</div>
<div> bool persistent; // Never removed from execution list</div>
<div> void* data;</div>
<div> EtherCATMaster::TECDataType<span class="Apple-tab-span" style="white-space:pre">
</span> dataType;</div>
<div> RT_SEM<span class="Apple-tab-span" style="white-space:pre"> </span>completeSignal;</div>
<div> SDORecord* nextExec;</div>
<div> };</div>
</div>
<div><br>
</div>
<div>
<div>void CopleyEcatDrive::processCoE()</div>
<div>{</div>
<div> SDORecord* p = SDOExecutionList;</div>
<div> SDORecord* next;</div>
<div> ec_request_state_t reqState;</div>
<div> while (p != NULL) {</div>
<div> next = p->nextExec;</div>
<div> reqState = ecrt_sdo_request_state(p->sdo);</div>
<div> if (p->inProgress == false && reqState != EC_REQUEST_BUSY) {</div>
<div> p->inProgress = true;</div>
<div> if (p->direction == EC_DIR_INPUT) {</div>
<div> rt_printf("Read SDO received: addr:0x%x\n", p);</div>
<div> ecrt_sdo_request_read(p->sdo);</div>
<div> } else if (p->direction == EC_DIR_OUTPUT) {</div>
<div> rt_printf("Write SDO received: addr:0x%x\n", p);</div>
<div> switch (p->dataType) {</div>
<div> case EtherCATMaster::EC_DATATYPE_SHORT:</div>
<div> EC_WRITE_S8(ecrt_sdo_request_data(p->sdo), *reinterpret_cast<int8_t*>(p->data));</div>
<div> break;</div>
<div> case EtherCATMaster::EC_DATATYPE_USHORT:</div>
<div> EC_WRITE_U8(ecrt_sdo_request_data(p->sdo), *reinterpret_cast<uint8_t*>(p->data));</div>
<div> break;</div>
<div> case EtherCATMaster::EC_DATATYPE_INT:</div>
<div> EC_WRITE_S16(ecrt_sdo_request_data(p->sdo), *reinterpret_cast<int16_t*>(p->data));</div>
<div> break;</div>
<div> case EtherCATMaster::EC_DATATYPE_UINT:</div>
<div> EC_WRITE_U16(ecrt_sdo_request_data(p->sdo), *reinterpret_cast<uint16_t*>(p->data));</div>
<div> break;</div>
<div> case EtherCATMaster::EC_DATATYPE_LONG:</div>
<div> EC_WRITE_S32(ecrt_sdo_request_data(p->sdo), *reinterpret_cast<int32_t*>(p->data));</div>
<div> break;</div>
<div> case EtherCATMaster::EC_DATATYPE_ULONG:</div>
<div> EC_WRITE_U32(ecrt_sdo_request_data(p->sdo), *reinterpret_cast<uint32_t*>(p->data));</div>
<div> break;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>default:</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> break;</div>
<div> }</div>
<div> ecrt_sdo_request_write(p->sdo);</div>
<div> } else {</div>
<div> rt_printf("Invalid SDO direction.\n");</div>
<div> p->inProgress = false;</div>
<div> rt_sem_v(&(p->completeSignal));</div>
<div> removeFromSDOExecutionList(p);</div>
<div> }</div>
<div> } else if (p->inProgress == true && reqState == EC_REQUEST_SUCCESS) {</div>
<div> p->inProgress = false;</div>
<div> p->ioError = false;</div>
<div> if (p->direction == EC_DIR_INPUT) {</div>
<div> rt_printf("Read SDO Completed: addr:0x%x\n", p);</div>
<div> switch (p->dataType) {</div>
<div> case EtherCATMaster::EC_DATATYPE_SHORT:</div>
<div> *reinterpret_cast<int8_t*>(p->data) = EC_READ_S8(ecrt_sdo_request_data(p->sdo));</div>
<div> break;</div>
<div> case EtherCATMaster::EC_DATATYPE_USHORT:</div>
<div> *reinterpret_cast<uint8_t*>(p->data) = EC_READ_U8(ecrt_sdo_request_data(p->sdo));</div>
<div> break;</div>
<div> case EtherCATMaster::EC_DATATYPE_INT:</div>
<div> *reinterpret_cast<int16_t*>(p->data) = EC_READ_S16(ecrt_sdo_request_data(p->sdo));</div>
<div> break;</div>
<div> case EtherCATMaster::EC_DATATYPE_UINT:</div>
<div> *reinterpret_cast<uint16_t*>(p->data) = EC_READ_U16(ecrt_sdo_request_data(p->sdo));</div>
<div> break;</div>
<div> case EtherCATMaster::EC_DATATYPE_LONG:</div>
<div> *reinterpret_cast<int32_t*>(p->data) = EC_READ_S32(ecrt_sdo_request_data(p->sdo));</div>
<div> break;</div>
<div> case EtherCATMaster::EC_DATATYPE_ULONG:</div>
<div> *reinterpret_cast<uint32_t*>(p->data) = EC_READ_U32(ecrt_sdo_request_data(p->sdo));</div>
<div> break;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>default:</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span> break;</div>
<div> }</div>
<div> } else if (p->direction == EC_DIR_OUTPUT) {</div>
<div> rt_printf("Write SDO Completed: addr:0x%x\n", p);</div>
<div> }</div>
<div> rt_sem_v(&(p->completeSignal));</div>
<div> if (p->persistent == false) {</div>
<div> removeFromSDOExecutionList(p);</div>
<div> }</div>
<div> } else if (p->inProgress == true && reqState == EC_REQUEST_ERROR) {</div>
<div>// **** This is the failure path that I see on CoE writes</div>
<div> rt_printf("SDO Had error: addr:0x%x, direction: %d\n", p, p->direction);</div>
<div> p->inProgress = false;</div>
<div> p->ioError = true;</div>
<div> rt_sem_v(&(p->completeSignal));</div>
<div> if (p->persistent == false) {</div>
<div> removeFromSDOExecutionList(p);</div>
<div> }</div>
<div> }</div>
<div> p = next;</div>
<div> }</div>
<div>}</div>
</div>
<div><br>
</div>
</body>
</html>