[Ethercat Master]
描述
Get the content of the ECAT_EVT_STATE_CHANGED
event, which represents the EtherCAT master state.
語法
int evtGetMasterState();
參數
無
回傳值
Return the EtherCAT master state.
備註
This function must be called in event callback.
範例程式碼
#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.