This function will write an integer value to a managed device.
Input:
Handle : SYSHANDLE
The handle to the connection established from snmpConnect.
OID : STRING
The OID for the value to write.
V : DINT
The value to write.
Subtype : SINT [0..1] (default 0)
The type of integer to write.
0:
|
Signed integer type
|
1:
|
Unsigned integer type
|
Returns: INT
1
|
- Success.
|
0
|
- This function is not supported.
|
-1
|
- Invalid handle.
|
-2
|
- Invalid parameter.
|
-8
|
- Communication error.
|
-10
|
- Invalid OID.
|
Declaration
FUNCTION snmpSetInteger : INT;
VAR_INPUT
Handle : MANDATORY SYSHANDLE;
OID : MANDATORY STRING;
V : MANDATORY DINT;
Subtype : SINT := 0;
END_VAR;
Example:
INCLUDE rtcu.inc
VAR
iface : SINT := 2;
END_VAR;
PROGRAM test;
VAR
rc : INT;
snmplabs : SYSHANDLE;
var_int : DINT;
END_VAR;
rc := netOpen(iface := iface);
DebugFmt(Message := "netOpen (rc=\1)", v1 := rc);
WHILE NOT netConnected(iface := iface) DO
Sleep(Delay := 2000);
END_WHILE;
rc := snmpConnect(
handle := snmplabs,
community := "public",
host := "demo.snmplabs.com"
);
IFrc = 1THEN
rc := snmpSetInteger(
handle := snmplabs,
oid := "1.3.6.1.2.1.4.26.0",
v := var_int,
subtype := 0
);
DebugFmt(message := "snmpSetInteger (rc=\1)", v1 := rc);
ELSE
DebugFmt(message := "snmpConnect failed (rc=\1)", v1 := rc);
END_IF;
...
BEGIN
...
END;
END_PROGRAM;
|