EthercatMaster.attachErrorCallback()

[Ethercat Master]

説明

エラー・コールバック関数を登録します。

構文

void attachErrorCallback(void (*callback)(uint32_t));

媒介変数

  • [in] void (*callback)(uint32_t)
    エラー・コールバック関数を登録します。1つの変数のみで、32ビット・エラー・コードです。

戻り値

なし

備考

この関数は、 EthercatMaster::begin() の前に、または、 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);
    }
}

詳細は EtherCAT Library User Manual QEC EtherCAT命令とAPI使用法参照

上部へスクロール