PROFINET Device  v1.04.02

◆ PN_API_DEV_plugSubmodule()

uint32_t PN_API_DEV_plugSubmodule ( uint16_t  slotNumber_p,
uint16_t  subslotNumber_p,
PN_API_DEV_SSubmoduleDescriptor_t pSubmoduleDescriptor_p 
)

Plug a submodule.

With this function the application can attach a submodule to particular module and plug a submodule to a subslot. By doing this, the submodule will be registered on stack and can be visible from outside.

Function takes a pointer to an instance of the submodule description structure and checks, that it is filled with valid parameters. If the parameters are correct, it checks further:

  • if there is free memory on the stack for a new subslot;
  • if a module is plugged under specified slot number;
  • if a subslot with specified subslot number is free;

If the conditions fulfilled the function will copy the instance of the submodule to the stack. Application can modify the module instance and the pointer to it after invoking the function.

/////////////////// I&M Functionality ///////////////////

Additionally, the function checks the I&M representation scope of the submodule. If I&M representation scope of the submodule is other than no representation (PN_API_DEV_APP_IM_R_NO), submodule will be assigned as an I&M Carrier. In thi case function checks the correctness of the I&M Data Set, specified by the I&M Data Set pointer in the submodule description structure.

Every I&M Data Set must contain at least I&M0 Data. An I&M Device Representative must support additionally I&M1, I&M2 and I&M3 Data.

Warning
It is required to invoke PN_API_DEV_APP_applyEquipmentConfiguration() function to finalize new equipment configuration of the device: that means after pulling / plugging of modules / submodules.
Parameters
[in]slotNumber_pNumber of the slot.
[in]subslotNumber_pNumber of the sub slot.
[in]pSubmoduleDescriptor_pSub module, to be plugged.
Returns
PN_API_DEV_EError_t as uint32_t value.
Return values
PN_API_DEV_eOKSubmodule was plugged successfuly.
PN_API_DEV_eERROR_PLUG_SUBMODULE_INVALID_SLOTEither slot is empty or invalid slot number.
PN_API_DEV_eERROR_PLUG_SUBMODULE_NO_FREE_SUBSLOTNo free subslot.
PN_API_DEV_eERROR_PLUG_SUBMODULE_SUBSSLOT_ALREADY_PLUGGEDSubslot with this number is already plugged.
PN_API_DEV_eERROR_PLUG_SUBMODULE_INVALID_SUBMODULE_TYPEInvalid submodule type.

\ Relevant for I&M Carrier

Return values
PN_API_DEV_eERROR_IM_DATA_SET_INVALID_POINTERInvalid pointer to I&M Data.
PN_API_DEV_eERROR_IM_INVALID_REPRESENTATIVE_SCOPEInvalid representative scope of I&M Carrier.
#PN_API_DEV_eERROR_IM_DEVICE_REPRESENTATIVE_ALREADY_PLUGGEDI&M device representative is already assigned.
#PN_API_DEV_eERROR_IM_MODULE_REPRESENTATIVE_ALREADY_PLUGGEDI&M module representative is already assigned for this module.
PN_API_DEV_eERROR_IM_CARRIER_NO_IM0_DATAI&M data set doesn't contain valid I&M0 data.
PN_API_DEV_eERROR_IM_DEVICE_REPRESENTATIVE_NO_IM1_DATAI&M data set for I&M device representatives doesn't support I&M1 data.
PN_API_DEV_eERROR_IM_DEVICE_REPRESENTATIVE_NO_IM2_DATAI&M data set for I&M device representatives doesn't support I&M2 data.
PN_API_DEV_eERROR_IM_DEVICE_REPRESENTATIVE_NO_IM3_DATAI&M data set for I&M device representatives doesn't support I&M3 data.
Example
#include <PN_API_DEV.h>
//Create an instance of submodule description structure and fill it
//Plug submodule
....
// Finish equipment configuration
PN_API_DEV_plugSubmodule
uint32_t PN_API_DEV_plugSubmodule(uint16_t slotNumber_p, uint16_t subslotNumber_p, PN_API_DEV_SSubmoduleDescriptor_t *pSubmoduleDescriptor_p)
Plug a submodule.
Definition: PN_API_main.c:1207
PN_API_DEV_applyEquipmentConfiguration
uint32_t PN_API_DEV_applyEquipmentConfiguration(void)
Apply equipment configuration.
Definition: PN_API_main.c:1062