[Ethercat Master]
Description
Get the content of the ECAT_ERR_CABLE_BROKEN
error, which represents the cable broken location 2.
Syntax
int errGetCableBrokenLocation2();
Parameters
None.
Return Value
Return the cable broken location 2.
Comment
This function must be called in error callback.
Example Code
#include <Ethercat.h> EthercatMaster master; bool CableBrokenLatched = false; int CableBrokenLocation1; int CableBrokenLocation2; void ErrorCallback(uint32_t errorcode) { if (errorcode == ECAT_ERR_CABLE_BROKEN) { if (CableBrokenLatched == false) { CableBrokenLatched = true; CableBrokenLocation1 = master.errGetCableBrokenLocation1(); CableBrokenLocation2 = master.errGetCableBrokenLocation2(); } } } void setup() { Serial.begin(115200); master.attachErrorCallback(ErrorCallback); master.begin(); master.start(); } void loop() { if (CableBrokenLatched == true) { Serial.print("Cable broken between "); if (CableBrokenLocation1 < 0) Serial.print("Primary Port"); else Serial.print("Slave "); Serial.print(CableBrokenLocation1); Serial.print(" and "); if (CableBrokenLocation2 < 0) Serial.println("Secondary Port"); else Serial.println("Slave "); Serial.println(CableBrokenLocation2); CableBrokenLatched = false; } }
Please see the EtherCAT Library User Manual for more QEC EtherCAT instructions and API usage.