Example
Task
As the security guidelines in your network do not allow SNMP, you want to deactivate SNMP for a CPU.
Solution
First, create a data block that contains the structure of data record B071
"Deactivate SNMP". The data block "Deactivate SNMP" contains not only the data record B071
use to transfer the data record. The tag "snmp_deactivate" is used to trigger the job for WRREC.
Table 1
Example: Data block for deactivating SNMP
Name
Data type
snmp_deactivate
Bool
snmp_record
Struct
BlockID
Word
BlockLength
Word
Version
Byte
Subversion
Byte
Reserved
Word
SNMP_control
DWord
snmp_done
Bool
snmp_error
Bool
snmp_status
DWord
Transfer the data record B071
In the following program code, the data record B071
...
"Deactivate SNMP".snmp_deactivate := 1;
"Deactivate SNMP".snmp_record.SNMP_control := 16#0;
REPEAT
//Write data record
"WRREC_DB_1"(REQ := "Deactivate SNMP".snmp_deactivate,//Transfer data record
ID := 2046,//integrated profinet interface
INDEX := -20367,//Data record number for snmp deactivation
LEN := 12,
DONE => "Deactivate SNMP".snmp_done,
ERROR => "Deactivate SNMP".snmp_error,
STATUS => "Deactivate SNMP".snmp_status,
RECORD := "Deactivate SNMP".snmp_record);//Data record
UNTIL "Deactivate SNMP".snmp_done OR "Deactivate SNMP".snmp_error
END_REPEAT;
...
8
Offset
0.0
-
2.0
4.0
6.0
7.0
8.0
10.0
14.0
14.1
16.0
in the startup OB (OB100) to the CPU with the WRREC instruction (write data record).
H
is transferred with the WRREC instruction in a REPEAT UNTIL loop.
H
. The figure below shows the data block
H
Start value
Comment
true
Tags for deactivation
-
Data record 16#B071
16#F003
-
16#0008
-
16#01
-
16#00
-
16#0000
-
16#0000_0000
-
false
-
false
-
16#0000_0000
-
//Set WRREC Request
//act=1 ; deact= 0
, but additional tags that you
H
Product information Deactivating SNMP
A5E46739177-AA, 02/2019