[Ethercat Master]
Description
Get the content of the ECAT_EVT_STATE_CHANGED event, which represents the EtherCAT master state.
Syntax
int evtGetMasterState();
Parameters
None.
Return Value
Return the EtherCAT master state.
Comment
This function must be called in event callback.
Example Code
#include <Ethercat.h>
EthercatMaster master;
int CurrentMasterState;
void EventCallback(uint32_t eventcode)
{
if (eventcode == ECAT_EVT_STATE_CHANGED)
CurrentMasterState = master.evtGetMasterState();
}
void setup() {
Serial.begin(115200);
master.attachEventCallback(EventCallback);
master.begin();
master.start();
}
void loop() {
Serial.print("CurrentMasterState: ");
Serial.println(CurrentMasterState);
delay(1000);
}Please see the EtherCAT Library User Manual for more QEC EtherCAT instructions and API usage.