[Ethercat Master]
描述
Get the content of the ECAT_ERR_CABLE_BROKEN error, which represents the cable broken location 1.
語法
int errGetCableBrokenLocation1();
參數
無
回傳值
Return the cable broken location 1.
備註
This function must be called in error callback.
範例程式碼
#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.