GetModuleConfiguration
Gets the information of the configured device.
Syntax
KsError GetModuleConfiguration(
int ConfigurationIndex,
int* SlaveId,
int* ModuleId,
KsConfigurationType* ConfigurationType,
VOID* Configuration
);
Parameters
ConfigurationIndex: the index of the configured device.
SlaveId: the index of a slave array. When EtherCAT is started, this index has the same value as the SlaveId, which corresponds to the position of the slave in the network. Please note that after EtherCAT is started in the Operational (Op) state, any addition or removal of slaves from the network will change the position of the slaves in the network (SlaveId). Nevertheless, the index of the slave will remain the same. Newly added devices will be added in the back of the slave array. For all slaves after the change, the index and SlaveId will no longer match. This behavior is only available for physical devices; simulated devices are inapplicable. Please refer to the use cases in EnableHotConnect for more details.
ModuleId: the module (devices linked to the coupler) ID. It can be slot ID, port ID, or CANopen slave ID.
ConfigurationType: the type of link between the device and the coupler. See the KsConfigurationType type.
Configuration: pointer to the configuration structure. It depends on what protocol you use. For example, if it's IO-Link, the configuration is the IoLinkSetting structure.
Return value
If the function succeeds, it returns errNoError
, otherwise an error code. For more information about the error code, see the KsError list.
Usable EtherCAT states
ecatOffline, ecatInit, ecatBoot, ecatPreOP, ecatSafeOP, ecatOP
Example
int slaveId = 0, moduleId = 0;
void* Configuration = malloc(sizeof(CanOpenSetting));
KsConfigurationType type = KsConfigurationType::configEtherCAT;
nRet = GetModuleConfiguration(0, &slaveId, &moduleId, &type, Configuration);
// Cast Configuration to the pointer of setting structure based on the type value
if (type == configCANopen)
{
CanOpenSetting CanOpenConf = *(CanOpenSetting*)Configuration;
}
Requirements
RT | Win32 | |
---|---|---|
Minimum supported version | 4.0 | 4.0 |
Header | ksapi.h | ksapi.h |
Library | KsApi_Rtss.lib | KsApi.lib |
See also