Open Core Interface - MLPI
MLPI-MotionLogicProgrammingInterface(mlpiCore)  1.26.2
Data link layer
Collaboration diagram for Data link layer:

Functions

MLPIRESULT mlpiEthercatGetSlavePortState (const MLPIHANDLE connection, const ULONG interfaceNumber, const MlpiEthercatAddressType addressType, const USHORT address, USHORT *portState)
 
MLPIRESULT mlpiEthercatReadSlaveRegister (const MLPIHANDLE connection, const ULONG interfaceNumber, const MlpiEthercatAddressType addressType, const USHORT address, const USHORT registerOffset, UCHAR *data, const ULONG dataSize, ULONG *dataSizeRet)
 
MLPIRESULT mlpiEthercatWriteSlaveRegister (const MLPIHANDLE connection, const ULONG interfaceNumber, const MlpiEthercatAddressType addressType, const USHORT address, const USHORT registerOffset, UCHAR *data, const ULONG dataSize)
 
MLPIRESULT mlpiEthercatResetSlaveController (const MLPIHANDLE connection, const ULONG interfaceNumber, const MlpiEthercatAddressType addressType, const USHORT address)
 
MLPIRESULT mlpiEthercatReadSlaveEeprom (const MLPIHANDLE connection, const ULONG interfaceNumber, const MlpiEthercatAddressType addressType, const USHORT address, const USHORT eepromOffset, USHORT *data, const ULONG numElements, ULONG *numElementsRet)
 
MLPIRESULT mlpiEthercatWriteSlaveEeprom (const MLPIHANDLE connection, const ULONG interfaceNumber, const MlpiEthercatAddressType addressType, const USHORT address, const USHORT eepromOffset, USHORT *data, const ULONG numElements)
 
MLPIRESULT mlpiEthercatReloadSlaveEeprom (const MLPIHANDLE connection, const ULONG interfaceNumber, const MlpiEthercatAddressType addressType, const USHORT address)
 
MLPIRESULT mlpiEthercatAssignSlaveEeprom (const MLPIHANDLE connection, const ULONG interfaceNumber, const MlpiEthercatAddressType addressType, const USHORT address, const BOOL8 slavePdiAccessEnable, const BOOL8 forceAssign)
 
MLPIRESULT mlpiEthercatCheckSlaveEeprom (const MLPIHANDLE connection, const ULONG interfaceNumber, const MlpiEthercatAddressType addressType, const USHORT address, BOOL8 *slavePdiAccessActive)
 
MLPIRESULT mlpiEthercatReadSlaveIdentification (const MLPIHANDLE connection, const ULONG interfaceNumber, const MlpiEthercatAddressType addressType, const USHORT address, const USHORT ado, USHORT *value)
 
MLPIRESULT mlpiEthercatGetSlaveStatistics (const MLPIHANDLE connection, const ULONG interfaceNumber, const MlpiEthercatAddressType addressType, const USHORT address, MlpiEthercatSlaveStatistics *slaveStatistics)
 
MLPIRESULT mlpiEthercatResetSlaveStatistics (const MLPIHANDLE connection, const ULONG interfaceNumber)
 
MLPIRESULT mlpiEthercatSetSlaveStatisticsPeriod (const MLPIHANDLE connection, const ULONG interfaceNumber, const ULONG periodMs)
 
MLPIRESULT mlpiEthercatGetSlaveStatisticsPeriod (const MLPIHANDLE connection, const ULONG interfaceNumber, ULONG *periodMs)
 

Detailed Description

Contains functions to read/write information on the data link layer.

Function Documentation

MLPIRESULT mlpiEthercatGetSlavePortState ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
const MlpiEthercatAddressType  addressType,
const USHORT  address,
USHORT portState 
)

This function returns the state of the slave ports.

Slave port state is encoded as follows: USHORT consists out of four nibble. Each nibble signals one information for all four ports.

Port order within each nibble: 3210

Nibble: wwww.xxxx.yyyy.zzzz wwww: Signal detected 1=TRUE 0=FALSE xxxx: Loop closed 1=TRUE 0=FALSE yyyy: Link established 1=TRUE 0=FALSE zzzz: Slave connected 1=TRUE 0=FALSE (logical result of w,x,y)

Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[in]addressTypeAddress type.
[in]addressSlave address (depending on addressType).
[out]portStateSlave port state.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Get the state of the slave ports.
2 ULONG interfaceNumber = 0;
3 MlpiEthercatAddressType addressType = MLPI_ETHERCAT_AUTO_INCREMENT;
4 USHORT address = 0;
5 USHORT portState = 0;
6 MLPIRESULT result = mlpiEthercatGetSlavePortState(connection, interfaceNumber, addressType, address, &portState);
MLPIRESULT mlpiEthercatReadSlaveRegister ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
const MlpiEthercatAddressType  addressType,
const USHORT  address,
const USHORT  registerOffset,
UCHAR data,
const ULONG  dataSize,
ULONG dataSizeRet 
)

This function reads data from the EtherCAT Slave Controller memory of a specific device.

Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[in]addressTypeAddress type.
[in]addressSlave address (depending on addressType).
[in]registerOffsetRegister offset, e.g. 0x0120 for AL Control register.
[out]dataData buffer for uploaded data.
[in]dataSizeNumber of bytes in 'data' available to read.
[out]dataSizeRetNumber of bytes used.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Read data from the EtherCAT Slave Controller memory of a specific device.
2 ULONG interfaceNumber = 0;
3 MlpiEthercatAddressType addressType = MLPI_ETHERCAT_AUTO_INCREMENT;
4 USHORT address = 0;
5 USHORT registerOffset = 5;
6 UCHAR data[128] = {0};
7 ULONG dataSize = _countof(data);
8 ULONG dataSizeRet = 0;
9 MLPIRESULT result = mlpiEthercatReadSlaveRegister(connection, interfaceNumber, addressType, address, registerOffset, data, dataSize, &dataSizeRet);
MLPIRESULT mlpiEthercatWriteSlaveRegister ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
const MlpiEthercatAddressType  addressType,
const USHORT  address,
const USHORT  registerOffset,
UCHAR data,
const ULONG  dataSize 
)

This function writes data into the EtherCAT Slave Controller memory of a specific device.

Attention
Changing contents of ESC registers may lead to unpredictable behavior of the slaves and/or the master.
Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[in]addressTypeAddress type.
[in]addressSlave address (depending on addressType).
[in]registerOffsetRegister offset, e.g. 0x0120 for AL Control register.
[in]dataData to be transferred.
[in]dataSizeNumber of bytes in 'data' available to write.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Write data into the EtherCAT Slave Controller memory of a specific device.
2 ULONG interfaceNumber = 0;
3 MlpiEthercatAddressType addressType = MLPI_ETHERCAT_AUTO_INCREMENT;
4 USHORT address = 0;
5 USHORT registerOffset = 5;
6 UCHAR data[100] = {0};
7 ULONG dataSize = _countof(data);
8 MLPIRESULT result = mlpiEthercatWriteSlaveRegister(connection, interfaceNumber, addressType, address, registerOffset, data, dataSize);
MLPIRESULT mlpiEthercatResetSlaveController ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
const MlpiEthercatAddressType  addressType,
const USHORT  address 
)

This function resets a ESC (e.g., ET1100, ET1200, and IP Core) if it is capable of issuing a hardware reset. A special sequence of three independent and consecutive frames/commands has to be sent do the slave (Reset register ECAT 0x0040 or PDI 0x0041). Afterwards, the slave is reset.

Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[in]addressTypeAddress type.
[in]addressSlave address (depending on addressType).
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Reset a ESC if it is capable of issuing a hardware reset.
2 ULONG interfaceNumber = 0;
3 MlpiEthercatAddressType addressType = MLPI_ETHERCAT_AUTO_INCREMENT;
4 USHORT address = 0;
5 MLPIRESULT result = mlpiEthercatResetSlaveController(connection, interfaceNumber, addressType, address);
MLPIRESULT mlpiEthercatReadSlaveEeprom ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
const MlpiEthercatAddressType  addressType,
const USHORT  address,
const USHORT  eepromOffset,
USHORT data,
const ULONG  numElements,
ULONG numElementsRet 
)

This function reads data from the EEPROM of a specific device.

Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[in]addressTypeAddress type.
[in]addressSlave address (depending on addressType).
[in]eepromOffsetEEPROM offset (word address to start reading from).
[out]dataData buffer for EEPROM content.
[in]numElementsNumber of words in 'data' available to read.
[out]numElementsRetNumber of words used.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Read data from the EEPROM of a specific device.
2 ULONG interfaceNumber = 0;
3 MlpiEthercatAddressType addressType = MLPI_ETHERCAT_AUTO_INCREMENT;
4 USHORT address = 0;
5 USHORT eepromOffset = 5;
6 USHORT data[128] = {0};
7 ULONG numElements = _countof(data);
8 ULONG numElementsRet = 0;
9 MLPIRESULT result = mlpiEthercatReadSlaveEeprom(connection, interfaceNumber, addressType, address, eepromOffset, data, numElements, &numElementsRet);
MLPIRESULT mlpiEthercatWriteSlaveEeprom ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
const MlpiEthercatAddressType  addressType,
const USHORT  address,
const USHORT  eepromOffset,
USHORT data,
const ULONG  numElements 
)

This function writes data into the EEPROM of a specific device.

Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[in]addressTypeAddress type.
[in]addressSlave address (depending on addressType).
[in]eepromOffsetEEPROM offset (word address to start reading from).
[in]dataData buffer for EEPROM content.
[in]numElementsNumber of words in 'data' available to write.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Write data into the EEPROM of a specific device.
2 ULONG interfaceNumber = 0;
3 MlpiEthercatAddressType addressType = MLPI_ETHERCAT_AUTO_INCREMENT;
4 USHORT address = 0;
5 USHORT eepromOffset = 5;
6 USHORT data[128] = {0};
7 ULONG numElements = _countof(data);
8 MLPIRESULT result = mlpiEthercatWriteSlaveEeprom(connection, interfaceNumber, addressType, address, eepromOffset, data, numElements);
MLPIRESULT mlpiEthercatReloadSlaveEeprom ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
const MlpiEthercatAddressType  addressType,
const USHORT  address 
)

This function causes a specific slave to reload its EEPROM values to ESC registers.

Note
Alias address 0x12 is not reloaded through this command. This is prevented by the slave hardware. To reload the alias address use mlpiEthercatResetSlaveController.
Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[in]addressTypeAddress type.
[in]addressSlave address (depending on addressType).
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Cause a specific slave to reload its EEPROM values to ESC registers.
2 ULONG interfaceNumber = 0;
3 MlpiEthercatAddressType addressType = MLPI_ETHERCAT_AUTO_INCREMENT;
4 USHORT address = 0;
5 MLPIRESULT result = mlpiEthercatReloadSlaveEeprom(connection, interfaceNumber, addressType, address);
MLPIRESULT mlpiEthercatAssignSlaveEeprom ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
const MlpiEthercatAddressType  addressType,
const USHORT  address,
const BOOL8  slavePdiAccessEnable,
const BOOL8  forceAssign 
)

This function assigns the slave EEPROM either to Slave PDI or EtherCAT Master.

Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[in]addressTypeAddress type.
[in]addressSlave address (depending on addressType).
[in]slavePdiAccessEnableAssigns EEPROM to Slave PDI (TRUE) or EtherCAT master (FALSE).
[in]forceAssignForce Assignment of EEPROM (only in case of assignment to EtherCAT master).
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Assign the slave EEPROM either to Slave PDI or EtherCAT Master.
2 ULONG interfaceNumber = 0;
3 MlpiEthercatAddressType addressType = MLPI_ETHERCAT_AUTO_INCREMENT;
4 USHORT address = 0;
5 BOOL8 slavePdiAccessEnable = TRUE;
6 BOOL8 forceAssign = FALSE;
7 MLPIRESULT result = mlpiEthercatAssignSlaveEeprom(connection, interfaceNumber, addressType, address, slavePdiAccessEnable, forceAssign);
MLPIRESULT mlpiEthercatCheckSlaveEeprom ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
const MlpiEthercatAddressType  addressType,
const USHORT  address,
BOOL8 slavePdiAccessActive 
)

This function checks if the slave EEPROM is marked for slave PDI access or not.

Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[in]addressTypeAddress type.
[in]addressSlave address (depending on addressType).
[out]slavePdiAccessActiveAssigns EEPROM to Slave PDI (TRUE) or EtherCAT master (FALSE).
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Check if the slave EEPROM is marked for slave PDI access or not.
2 ULONG interfaceNumber = 0;
3 MlpiEthercatAddressType addressType = MLPI_ETHERCAT_AUTO_INCREMENT;
4 USHORT address = 0;
5 BOOL8 slavePdiAccessActive = TRUE;
6 MLPIRESULT result = mlpiEthercatCheckSlaveEeprom(connection, interfaceNumber, addressType, address, &slavePdiAccessActive);
MLPIRESULT mlpiEthercatReadSlaveIdentification ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
const MlpiEthercatAddressType  addressType,
const USHORT  address,
const USHORT  ado,
USHORT value 
)

This function reads the identification value from a slave.

Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[in]addressTypeAddress type.
[in]addressSlave address (depending on addressType).
[in]adoADO used for identification.
[out]valueIdentification value.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Read the identification value from a slave.
2 ULONG interfaceNumber = 0;
3 MlpiEthercatAddressType addressType = MLPI_ETHERCAT_AUTO_INCREMENT;
4 USHORT address = 0;
5 USHORT ado = 4;
6 USHORT value = 0;
7 MLPIRESULT result = mlpiEthercatReadSlaveIdentification(connection, interfaceNumber, addressType, address, ado, &value);
MLPIRESULT mlpiEthercatGetSlaveStatistics ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
const MlpiEthercatAddressType  addressType,
const USHORT  address,
MlpiEthercatSlaveStatistics slaveStatistics 
)

This function returns the slave's statistics counter. Counter can be used to detect errors on Ethernet Layer.

Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[in]addressTypeAddress type.
[in]addressSlave address (depending on addressType).
[out]slaveStatisticsStatistics of a slave.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Get the slave's statistics counter. Counter can be used to detect errors on Ethernet Layer.
2 ULONG interfaceNumber = 0;
3 MlpiEthercatAddressType addressType = MLPI_ETHERCAT_AUTO_INCREMENT;
4 USHORT address = 0;
5 MlpiEthercatSlaveStatistics slaveStatistics;
6 memset (&slaveStatistics, 0, sizeof(MlpiEthercatSlaveStatistics));
7 MLPIRESULT result = mlpiEthercatGetSlaveStatistics(connection, interfaceNumber, addressType, address, &slaveStatistics);
MLPIRESULT mlpiEthercatResetSlaveStatistics ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber 
)

This function clears all error registers (statistics counter) in all slaves.

Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Clear all error registers (statistics counter) in all slaves.
2 ULONG interfaceNumber = 0;
3 MLPIRESULT result = mlpiEthercatResetSlaveStatistics(connection, interfaceNumber);
MLPIRESULT mlpiEthercatSetSlaveStatisticsPeriod ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
const ULONG  periodMs 
)

This function sets the update period of internal slave statistics collection.

Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[in]periodMsUpdate period in unit of milliseconds (0 means disable feature).
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Set the update period of internal slave statistics collection.
2 ULONG interfaceNumber = 0;
3 ULONG periodMs = 1000;
4 MLPIRESULT result = mlpiEthercatSetSlaveStatisticsPeriod(connection, interfaceNumber, periodMs);
MLPIRESULT mlpiEthercatGetSlaveStatisticsPeriod ( const MLPIHANDLE  connection,
const ULONG  interfaceNumber,
ULONG periodMs 
)

This function returns the update period of internal slave statistics collection.

Parameters
[in]connectionHandle for multiple connections.
[in]interfaceNumberMaster interface number.
[out]periodMsUpdate period in unit of milliseconds (0 means disabled feature).
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Get the update period of internal slave statistics collection.
2 ULONG interfaceNumber = 0;
3 ULONG periodMs = 0;
4 MLPIRESULT result = mlpiEthercatGetSlaveStatisticsPeriod(connection, interfaceNumber, &periodMs);