Tema: Indy 9
Ver Mensaje Individual
  #4  
Antiguo 19-01-2007
GMV Man GMV Man is offline
Registrado
 
Registrado: ene 2007
Posts: 1
Reputación: 0
GMV Man Va por buen camino
Smile La respuesta al problema

Aparentemente el código es correcto pero pero le falta un pequeño detalle. Como norma general debe indicarse el tipo de variable del que se va a hacer el "MIBSet". So esto no es así (como en los ejemplos anteriores) la variable por defecto a escribir será del tipo "Octeto" (ASN1_OCTSTR).
Para solucionar esto sugiero cambiar la función para indicar también el tipo de variable a escribir:

function TfrmMainSNMP.SetOID(OID: String; Value: String; var iType: Integer; var Error: String): Boolean;
var
Tmp: String;

begin
Result := False;
try
if SNMP = Nil then begin
SNMP := TIdSNMP.Create(nil);
end;

if not LeerIni(RutaIni, 'HOST', 'Address', Tmp, '', Error) then begin
GrabarLog(RutaLog, Error, Error);
end;
IP := Tmp;

SNMP.Community := 'public';
SNMP.Host := IP;
SNMP.Query.Clear;
SNMP.Query.MIBAdd(OID, Value, iType);
SNMP.Query.PDUType := PDUSetRequest;
if not SNMP.SendQuery then begin
Error := 'Error al Escribir en OID: ' + OID + '(' + Value + ')';
end else begin
snmp.Reply.MIBGet(OID);
memo1.Lines.Add('OID ' + OID + ' = ' + Value + '.');
end;
Result := True;
Except On E: Exception do begin
Error := 'Error en la función (TfrmMainTPVSNMP)ConsultarOID. ' + E.Message;
end;
end;
end;


A la variable iType podrá tener cualquiera de los valores siguientes:
ASN1_INT
ASN1_OCTSTR
ASN1_NULL
ASN1_OBJID
ASN1_SEQ
ASN1_IPADDR
ASN1_COUNTER
ASN1_GAUGE
ASN1_TIMETICKS
ASN1_OPAQUE

Aleeee.
Responder Con Cita