Description of the DP Functions, Data, and Error Codes
4.3.2
Reading the Diagnostic Data of a DP Slave
Consistent Reading of the Diagnostic Data
Each individual slave has a fixed data area in the process image of the
CP 5613/CP 5614 (for more information on the data format see Section 4.6).
To allow the diagnostic data of a slave to be read consistently, your user program
first locks this data area to prevent it being updated by the DP master, then
accesses the area, and releases it again. The program locks the area by writing the
slave number to a control register in the process image. The data area is released
again by writing the value DPR_DP_UNLOCK to the same register.
There is also a counter that counts the diagnostic data of the relevant slave.
Example of Consistent Reading of the Diagnostic Data
"p" is a pointer to the process image that your user program obtained with the
"DP_get_pointer" call. Then 200 bytes of the diagnostic data of slave no. 5 are
copied to a local buffer "buf":
/* Lock the diagnostic data area against updating */
p->ctr.D_lock_diag_slave_adr = 5;
/* Evaluate the counter */
count = p->pi.slave_diag[5].diag_count;
/* Copy current data */
memcpy(buf, &p->pi.slave_diag[5].data[0],
/* Cancel lock again
p->ctr.D_lock_diag_slave_adr = DPR_DP_UNLOCK;
154
p->pi.slave_diag[5].diag_len);
*/
DP Base Programming Interface for CP 5613/CP 5614
C79000-G8976-C108-02