PROFINET Device4.2.0
 
Loading...
Searching...
No Matches

◆ PN_API_IOD_changeIpSuite()

uint32_t PN_API_IOD_changeIpSuite ( PN_API_IOD_Handle_t *const  pnHandle,
uint32_t  newIpAddr,
uint32_t  subnetMask,
uint32_t  defaultGw 
)

Momentarily modifies the IP suite within the Profinet stack.

Changes IP suite values and sends the new values to Profinet stack to be used. However, the modified values are not retained within the NV memory, so they are lost after device restarts.

Warning
Must be called only when no AR is running.
Parameters
[in]pnHandleProfinet API Handle.
[in]newIpAddrNew IP address.
[in]subnetMaskNew value for subnet mask.
[in]defaultGwNew value for default gateway.
Returns
result of the operation as uint32_t.
Return values
PN_API_OKSuccess.
PN_API_NOT_OKSomething went wrong or an AR is running.
PN_API_ERR_PARAMInvalid parameter.
Example
#include "pn_api_iod_settings.h"
#include "pn_api_iod_startup.h"
PN_API_IOD_Handle_t* pnHandle = NULL;
uint32_t status;
pnHandle = PN_API_IOD_new();
uint8_t ip1 = 192, ip2 = 168, ip3 = 1, ip4 = 10;
uint8_t mask1 = 255, mask2 = 255, mask3 = 0, mask4 = 0;
uint8_t gw1 = 192, gw2 = 168, gw3 = 1, gw4 = 1;
uint32_t ip = ((uint32_t)ip1 << 24) | ((uint32_t)ip2 << 16) | ((uint32_t)ip3 << 8) | ip4;
uint32_t mask = ((uint32_t)mask1 << 24) | ((uint32_t)mask2 << 16) | ((uint32_t)mask3 << 8) |
mask4; uint32_t gw = ((uint32_t)gw1 << 24) | ((uint32_t)gw2 << 16) | ((uint32_t)gw3 << 8) | gw4;
status = PN_API_IOD_changeIpSuite(pnHandle, ip, mask, gw);
PN_API_IOD_Handle_t * PN_API_IOD_new(void)
Creates Profinet API handle.
uint32_t PN_API_IOD_changeIpSuite(PN_API_IOD_Handle_t *const pnHandle, uint32_t newIpAddr, uint32_t subnetMask, uint32_t defaultGw)
Momentarily modifies the IP suite within the Profinet stack.
struct PN_API_IOD_Handle PN_API_IOD_Handle_t
API handle instance which holds IO device's info.
Definition pn_api_iod_types.h:61