• No results found

Description of the DP Functions, Data, and

4.2 DP slave functions

4.2.2 DPS_open

Purpose

With this function, a DP slave user program logs on at the CP 5614 and sets the slave parameters. If successful, the function returns a user handle. The user handle must be included in all further function calls.

Note 1

In the DPS_SM_DYNAMIC mode, the input data of the slave module must be initialized after receiving the positive confirmation of a configuration frame (in other words written) so that the slave module takes part in data exchange.

Note 2

DP-V1 services (DPS_SM_V1_ENABLE) are supported only in the DPS_SM_SIMPLE slave mode.

Note 3

In the DP-V1 mode, the slave submodule of the CP 5614 supports one DPC2 connection.

Note 4

Refer to the notes on GSD files in Section 4.7.4.

Syntax

DPR_DWORD DPS_open (

const DPR_STRING *cp_name, // in

DPR_DWORD *user_handle, // out

DPR_DWORD slave_mode, // in

DPR_WORD station_addr, // in

DPR_WORD addr_change, // in

DPR_WORD pno_ident_nr, // in

DPR_WORD user_wd, // in

DPS_INIT_DATA_T *init_data, // in

DPS_MAX_DATA_T *max_data, // in

DPR_WORD baud_rate, // in

DP_ERROR_T *error); // out

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 189

Parameters

Name Description

cp_name Access point of the CP 5614 (for example, "CP_L2_1:") user_handle Pointer to the user handle variable - if successful, the user

handle assigned to the DP user program is entered here.

slave_mode Setting for the slave mode (the individual flags are logically linked in bits):

● DPS_SM_SIMPLE simple slave with automatic checking of the parameter assignment and

configuration data

● DPS_SM_V1_ENABLE activate DP-V1 services

● DPS_SM_DYNAMIC parameter assignment and configuration data of the slave are checked dynamically.

station_addr Station address of the slave module on the CP 5614. This parameter is irrelevant on the CP 5613.

addr_change 1 means: allow address change on the bus.

0 means: do not allow address change on the bus pno_ident_nr Unique number for the slave assigned by the PROFIBUS

Users Organization (for example 0x80B4 for the sample user program) during certification. This number is represented in Intel format. This can generally be taken from the device description data file (GSD file) of the slave.

user_wd Formula:

User_wd*10ms = monitoring time of the DP user program If the watchdog is not restarted in this time, the slave drops out of productive operation (Data_Ex). The value 0

deactivates the watchdog.

As long as the watchdog is not supported by the CP 5614, this parameter must be set to 0.

Table continued on next page

Continued

Name Description

init_data Pointer to a union with information on the extended slave data. The DPS_SIMPLE_S structure must be used in the slave mode DPS_SM_SIMPLE, otherwise the

DPS_DYNAMIC_S structure.

The DPS_SIMPLE_S structure contains the values set for the user parameter assignment data and for the

configuration data. These values must match the values that the master sends to the slave during the parameter assignment and configuration phase. This is verified automatically by the slave firmware.

Note:

If DP-V1 services are not activated (bit

DPS_SM_V1_ENABLE is not set), the first user

parameter assignment data byte is reserved for the slave controller!

If DP-V1 services are activated (bit DPS_SM_V1_ENABLE is set), the first three user parameter assignment data bytes are reserved!

The DPS_DYNAMIC_S structure contains the default configuration of the slave submodule. The DP master can read out these values at any time. During the configuration phase, the master can, however, send other configuration data (desired configuration) to the slave. The slave must read out this configuration data using DPS_get_ind and confirm explicitly with DPS_set_resp.

Table continued on next page

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 191

Continued

Name Description

Typedef union DPS_INIT_DATA_S {

struct DPS_SIMPLE_S

{

DPR_WORD user_prm_data_len; // in

DPR_BYTE user_prm_data

[DPS_MAX_PDU_LEN]; // in

DPR_WORD cfg_data_len; // in DPR_BYTE cfg_data[DPS_MAX_PDU_LEN];

// in

}simple;

struct DPS_DYNAMIC_S

{

DPR_WORD def_cfg_data_len; // in

DPR_BYTE def_cfg_data

[DPS_MAX_PDU_LEN]; // in

}dynamic;

}DPS_INIT_DATA_T

user_prm_data_len: length of the specified user parameter assignment data <=

237 bytes

user_prm_data: specified user parameter assignment data

cfg_data_len: length of the specified

configuration data <= 244 bytes

cfg_data: specified configuration data (format see Section 4.7.3)

def_cfg_data_len: length of the default configuration data <= 244 bytes

def_cfg_data: default configuration data

Table continued on next page

Continued

Name Description

max_data Pointer to a structure with the maximum buffer lengths.

This parameter is reserved and must have the value NULL set.

baud_rate Data transmission rate to be set.

This parameter is reserved and must be set to

DPS_BD_AUTO_DETECT (automatic detection of the data transmission rate).

error Address of a structure provided by the DP user program of the type DP_ERROR_T - If an error occurred, the structure contains details for troubleshooting (see Section 4.4).

Return Value

Name Description

DP_OK Successful completion of function.

DP_ ERROR_CI and

DPS_open was already executed.

DP_ERROR_EVENT_NET and error->error_code ==

DPS_RET_NOT_OFFLINE

The slave module is not offline.

DP_ERROR_REQ_PAR and error->error_code ==

DPS_RET_INV_SLAVE_ADDR

The specified slave address is invalid.

DP_ERROR_REQ_PAR and

error->error_code == Max_user_prm_data_len incorrect.

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 193

Continued

Name Description

DP_ERROR_REQ_PAR and

DP-V1 operation not possible.

DP_ERROR_RES and error->error_code ==

DP_RET_TOO_MANY_USR

No more DP instances can log on at the CP.

DP_ERROR_RES and error->error_code ==

DPS_RET_NO_SLAVE_MODULE

DP slave functions are not available since this is a CP 5613 (without a slave module).

DP_ERROR_RES and error->error_code ==

DPS_RET_LESS_MEM

The requested buffers are too large.

other Unsuccessful completion of function.