[Ethercat Master]
描述
Register Error Callback Function.
語法
void attachErrorCallback(void (*callback)(uint32_t));
參數
[in] void (*callback)(uint32_t)
The error callback function to be registered, which only has one parameter, a 32-bit error code.
回傳值
無
備註
This function must be called before EthercatMaster::begin() or after EthercatMaster::end().
範例
#include "Ethercat.h"
EthercatMaster master;
EthercatDevice_Generic slave;
uint32_t ErrorCode = 0;
void ErrorCallback(uint32_t errorcode) {
ErrorCode = errorcode;
}
void setup() {
Serial.begin(115200);
master.attachErrorCallback(ErrorCallback); // ErrorCallback Function.
master.begin();
slave.attach(0, master);
master.start(1000000, ECAT_SYNC); // 1000000 ns = 1 ms
}
void loop() {
/* Error Code */
uint32_t error = ErrorCode;
ErrorCode = 0;
if (error) {
Serial.print("ErrorCode:");
Serial.println(error);
}
}Please see the EtherCAT Library User Manual for more QEC EtherCAT instructions and API usage.