Function block for gathering SNMP values from managed switches

Available with AXC F 2152 and AXC F 3152

General concept

By means of this function block, SNMP values from managed switches with up to 8 ports can be read directly by the PLC via the SNMP protocol. 

function block ASR_GET_SNMP_UNI

arrPartnerList

The IP addresses and the number of ports (maximum 16) of the managed switches must be applied to the arrPartnerList input parameter. This input parameter is an Array of Struct with 30 elements, so that a maximum number of 30 IP addresses can be used. The proper syntax for an IP address is: ‘/IP=www.xxx.yyy.zzz’ (e.g. ‘/IP=192.168.0.21’).

xActivate

TRUE at the xActivate input parameter activates the function block. After the activation, the function block requests cyclically the SNMP values from the indicated managed switches. The desired scanning time can be adjusted via the iScanTimeSP input parameter. The received SNMP values are stored at the arrSnmpInfo output parameter.

FALSE at the xActivate input parameter deactivates the function block and requesting the SNMP values is stopped.

xError

The appearance of an error is indicated by the xError output parameter. The wDiagCode and wAddDiagCode output parameters display the cause of the error. The values are valid within the cycle, in which the rising edge of the xError output parameter occurred. The acknowledgment of an error message is carried out by a rising edge of the xQuit input parameter.

Prerequisites

From the PLCnext Store, download the ASR AXC F 2152 or the ASR AXC F 3152 function block library (free of charge) and import it into PLCnext Engineer on your computer.

Description of inputs and outputs

Name

Data type

Data direction

Description

xActivate

BOOL

Input

With TRUE the function block is activated and reading of the SNMP values is started.

FALSE deactivates the function block and reading of the SNMP values is stopped.

xQuit

BOOL

Input

With a rising edge at this input parameter error messages, which occurred during requesting the SNMP values, are acknowledged.

iScanTimeSP

INT

Input

Desired scanning cycle time in seconds.

arrPartnerList

ASR_ARR_PARTNER_LIST1_30

Input

List of IP addresses and the number ports of the managed switches from which the SNMP values should be collected. This input parameter is an Array of Struct with 30 elements, so that a maximum number of 30 IP addresses can be used.
The proper syntax for an IP addresses is: '/IP=www.xxx.yyy.zzz' (e.g. '/IP=192.168.0.21').

xActive

BOOL

Output

TRUE at this output parameter indicates that the function block is requesting now the SNMP values cyclically.

xError

BOOL

Output

This output indicates with a rising edge that an error has occurred. You can read the corresponding error codes at the wDiagCode and wAddDiagCode output parameters during the cycle in which the rising edge occurs.

wDiagCode

WORD

Output

Indicates the cause of the error.

wAddDiagCode

DWORD

Output

Indicates additional information to the cause of the error.

iScanTimeAV

INT

Output

Actual scanning cycle time in seconds.

arrSnmpInfo

ASR_ARR_SNMP_INFO_1_30

Output

SNMP values from the specified managed switches. This output parameter is an Array of Struct, in which each field contains the SNMP values of a managed switch corresponding to the IP addresses at the arrPartnerList input parameter. The DataValid element indicates whether the last request of SNMP values to this managed switch was successful (TRUE) or unsuccessful (FALSE).
The meaning of the individual information read from the managed switches is explained separately in the table below.

Description of the elements of the SnmpInfo structure

Most elements are available for each port and therefore presented in an array.

Name

Data type

Description

SysUpTime

UDINT

Time in hundreds of seconds since the last reset of the managed switch.

PortSpeed

UDINT

Current bandwidth of the port in bits per second.

OperStatus

USINT

Current operational state of the port. Typical possible values:
1: LinkUp
2: LinkDown
3: Testing
4: Unknown
5: Dormant,
6: Not present

InOctets

UDINT

Total number of received octets.

InUcasts

UDINT

Total number of received unicast packets.

InNUcasts

UDINT

Total number of received broad and multicast packets.

InDiscards

UDINT

Total number of discarded inbound packets.

InErrors

UDINT

Total number of inbound packets with errors.

InUtilization

REAL

Calculated inbound utilization in percent.

InNUcastsPerSec

UINT

Calculated number of received broad and multicast packets per second.

InCorrupt

REAL

Calculated error rate of received packets in percent.

OutOctets

UDINT

Total number of transmitted octets.

OutUcasts

UDINT

Total number of transmitted unicast packets.

OutNUcasts

UDINT

Total number of transmitted broad and multicast packets.

OutDiscards

UDINT

Total number of discarded outbound packets.

OutErrors

UDINT

Total number of outbound packets with errors.

OutUtilization

REAL

Calculated outbound utilization in percent.

OutNUcastsPerSec

UINT

Calculated number of transmitted broad and multicast packets per second.

OutCorrupt

REAL

Calculated error rate of transmitted packets in percent.

Error Codes

Error Code

Description

C401

Indicates that the syntax of an applied string for the IP address at the input parameter arrPartnerList is wrong (proper syntax: '/IP=www.xxx.yyy.zzz').
The output parameter wAddDiagCode indicates the index of the relevant switch.

The acknowledgement of this error message is carried out at a rising edge of the xQuit input parameter.

C402

Indicates that the SNMP client function block reported an error while a SNMP request was sent to a managed switch.

The output parameter wAddDiagCode contains the DiagCode of the SNMP client function block.

The acknowledgement of this error message is carried out at a rising edge of the xQuit input parameter.

C403

Time-out detection of the internal state machine (3s).

The output parameter wAddDiagCode indicates the step of the internal state machine (high-byte) and the index of the relevant managed switch (low-byte) at which this error has occurred.

The acknowledgement of this error message is carried out at a rising edge of the xQuit input parameter.

 

 

 


•  Web browser recommendation: Chrome/Edge 88 or newer, Firefox ESR 90 or neweror Safari • 
• Published/reviewed: 2022-09-14 • Revision 046 •