I want to find...

Search

Shares

Table of Content

EthercatMaster.getSerialNumber()

[Ethercat Master]

Description

Get the EtherCAT Slave Serial Number on EtherCAT bus.

Syntax

uint32_t getSerialNumber(uint16_t slave_no);

Parameters

  • [in] unit16_t slave_no
    The sequence number of the EtherCAT slave device on the network, 0 indicates the first slave device, 1 indicates the second slave device, and so on.

Return Value

Return the Serial Number of the specified slave. If an error occurs, it will return UINT32_MAX.

Comment

This function must be called after a successful execution of EthercatMaster::begin(). This function is non-blocking and can be called within the Cyclic Callback.

Example

#include "Ethercat.h"

EthercatMaster master;

void setup() {
    uint32_t slaveserialnum;
    uint16_t slavecount=1;
  
    Serial.begin(115200);
    while (!Serial);
  
    master.begin();
    slaveserialnum = master.getSerialNumber(slavecount);
    Serial.println(slaveserialnum);
}

void loop() {
    // ...
}

Please see the EtherCAT Library User Manual for more QEC EtherCAT instructions and API usage.

Leave a Comment

Scroll to Top