snmpSetString (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All NX devices

Firmware version:

1.50.00


This function will write a string 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 : STRING

The value to write.

 

Subtype : SINT [0..2] (default 0)

The type of string to write.

0:

Text string type.

1:

Hex string type.

2:

Decimal string 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 snmpSetString : 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_string : STRING;
END_VAR;
  // Open net interface.
  rc := netOpen(iface := iface);
  DebugFmt(Message := "netOpen (rc=\1)", v1 := rc);
  WHILE NOT netConnected(iface := iface) DO
    Sleep(Delay := 2000);
  END_WHILE;
 
  // Establish connection with client host.
  rc := snmpConnect(
                    handle   := snmplabs,
                    community := "public",
                    host     := "demo.snmplabs.com"
                   );
  IF rc = 1 THEN
     // Write to string variable.
     rc := snmpSetString(
                         handle := snmplabs,
                         oid     := "1.3.6.1.2.1.2.2.1.6.1",
                         v       := var_string,
                         subtype := 0
                        );
     DebugFmt(message := "snmpSetString (rc=\1)", v1 := rc);
  ELSE
    DebugFmt(message := "snmpConnect failed (rc=\1)", v1 := rc);
  END_IF;
  ...
BEGIN
  ...
END;
END_PROGRAM;