[Ethercat Master]
Description
Register Error Callback Function.
Syntax
void attachErrorCallback(void (*callback)(uint32_t));
Parameters
[in] void (*callback)(uint32_t)
The error callback function to be registered, which only has one parameter, a 32-bit error code.
Return Value
None.
Comment
This function must be called before EthercatMaster::begin()
or after EthercatMaster::end()
.
Example
#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.