Hey! I try to create simple snmp GET query using pyasn1-modules lib, with following code:
`
import sys
import socket
from pyasn1_modules.rfc1901 import Message
from pyasn1_modules.rfc1905 import PDUs, VarBindList, VarBind, GetRequestPDU
from pyasn1.type import univ
from pyasn1.codec.ber import decoder
from pyasn1.codec.ber import encoder
from pyasn1 import debug
// Define settings
community = 'test'
host = '1.2.3.4'
oid = '1.3.6.1.2.1.2.2.1.2.1'
// Create msg
msg = Message()
msg.setComponentByPosition(0)
msg.setComponentByPosition(1, community) // Set community
pdus = PDUs() # create pdus
pdus = msg.setComponentByPosition(2, pdus).getComponentByPosition(2)
pdu = pdus.setComponentByPosition(0).getComponentByPosition(0)
pdu.setComponentByPosition(0, 123)
pdu.setComponentByPosition(1, 0)
pdu.setComponentByPosition(2, 0)
vbl = pdu.setComponentByPosition(3).getComponentByPosition(3)
vb = vbl.setComponentByPosition(0).getComponentByPosition(0)
vb.setComponentByPosition(0, oid)
res = vb.getComponentByPosition(1).setComponentByPosition(1).getComponentByPosition(1)
print('sending: %s' % msg.prettyPrint())
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(encoder.encode(msg), (host, 161))
substrate, _ = sock.recvfrom(2048)
rMsg, _ = decoder.decode(substrate, asn1Spec=msg)
print('received: %s' % rMsg.prettyPrint())
`
After running script, got this exception: pyasn1.error.PyAsn1Error: Attempted "eq" operation on ASN.1 schema object. Can anybody help me, please ?
pyasn1.error.PyAsn1Error: Error encoding <Message schema object, tagSet=<TagSet object, tags 0:32:16>, subtypeSpec=, componentType=<NamedTypes object, types <NamedType object, type version=<Integer schema object, tagSet <TagSet object, tags 0:0:2>, namedValues <NamedValues object, enums version-2c=1>>>, <NamedType object, type community=<OctetString schema object, tagSet <TagSet object, tags 0:0:4>, encoding iso-8859-1>>, <NamedType object, type data=<Any schema object, encoding iso-8859-1>>>, sizeSpec=>: Error encoding <Integer schema object, tagSet <TagSet object, tags 0:0:2>, namedValues <NamedValues object, enums version-2c=1>>: Attempted "eq" operation on ASN.1 schema object