I want to find...

Search

Shares

Table of Content

EthercatMaster.getSlaveNo()

[Ethercat Master]

Description

Obtain the sequential ID of the specified slave based on the alias address, supplier number, product number, amendment number, serial number.

Syntax

int getSlaveNo(uint16_t alias_addr);

int getSlaveNo(uint32_t vendor, uint32_t product);

int getSlaveNo(uint32_t vendor, uint32_t product, uint32_t revision, uint32_t serial_num);

int getSlaveNo(uint16_t alias_addr, uint32_t vendor, uint32_t product);

int getSlaveNo(uint16_t alias_addr, uint32_t vendor, uint32_t product, uint32_t revision, uint32_t serial_num);

Parameters

  • [in] uint16_t alias_addr
    The Alias Address of the EtherCAT slave device you want to find. If the input value is 0, it indicates that this parameter should not be used for the search.
  • [in] uint32_t vendor
    The Vendor ID of the EtherCAT slave device you want to find. If the input value is 0, it indicates that this parameter should not be used for the search.
  • [in] uint32_t product
    The Product Code of the EtherCAT slave device you want to find. If the input value is 0, it indicates that this parameter should not be used for the search.
  • [in] uint32_t revision
    The Revision Number of the EtherCAT slave device you want to find. If the input value is 0, it indicates that this parameter should not be used for the search.
  • [in] uint32_t serial_num
    The Serial Number of the EtherCAT slave device you want to find. If the input value is 0, it indicates that this parameter should not be used for the search.

Return Value

Return the sequence number of the matching EtherCAT slave device on the network. If the returned value is -1, it indicates that no matching EtherCAT slave device was found. Any other value less than 0 indicates an error code.

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() {
  Serial.begin(115200);
  master.begin();
  
  Serial.print("Search Test 1 => ");
  Serial.println(master.getSlaveNo(1200));

  Serial.print("Search Test 2 => ");
  Serial.println(master.getSlaveNo(0x00000BC3, 0x0086D324));

  Serial.print("Search Test 3 => ");
  Serial.println(master.getSlaveNo(0x00000BC3, 0x0086D304, 0x20220316, 0x00000000));

  Serial.print("Search Test 4 => ");
  Serial.println(master.getSlaveNo(251, 0x00000BC3, 0x0086D302));

  Serial.print("Search Test 5 => ");
  Serial.println(master.getSlaveNo(252, 0x00000BC3, 0x0086D301, 0x20220316, 0x00000000));
}

void loop() {
  // ...
}

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

Leave a Comment

Scroll to Top