Re: [pysnmp-users] Sending an activation Sequence, getting timeout
Brought to you by:
elie
From: Ilya E. <il...@gl...> - 2015-11-10 07:23:34
|
Hi Diego, OctetString can also take a sequence of bytes: >>> OctetString([1, 32, 73, 0xf0, 0xff]) OctetString(hexValue='012049f0ff') >>> str(OctetString([1, 32, 73, 0xf0, 0xff])) '\x01 I\xf0\xff’ -ilya > On 07 Nov 2015, at 18:59, Diego Muñoz <dmu...@gm...> wrote: > > Sadly I won't be able to work with the device until monday or tuesday maybe. As soon as I can, I will send another email. > > Meanwhile, I want to ask an extra question. > I have to create the OctetString based on 6 different values. What I currently do is to create a hex string with the corresponding byte length for each value, then use the binascii.unhexlify function and finally create the OctetString with this result: > > message = duration_hex + activatePriority_hex + messageMemoryType_hex + \ > messageNumber_hex + messageCRC_hex + deviceIp_hex > message = binascii.unhexlify(message) > > An example of the hex string is: > "ff ff ff 03 00 3c 2f f5 c0 a8 01 de" (blank spaces added to read easily) > where: > duration_hex = ff ff > activatePriority_hex = ff > messageMemoryType_hex = 03 > messageNumber_hex = 00 3c > messageCRC_hex = 2f f5 > deviceIp_hex = c0 a8 01 de > > Is there a cleaner way to create the OctetString? > > 2015-11-06 20:14 GMT-03:00 Ilya Etingof <il...@gl...>: > Hi Diego, > > Try to enable pysnmp debug and see what OID and what value type (is it still OctetString?) is being sent in the second case: > > from pysnmp import debug > > debug.setDebug(debug.Debug(‘msgproc’)) > > -ilya > > >> On 06 Nov 2015, at 22:21, Diego Muñoz <dmu...@gm...> wrote: >> >> Hi Ilya, I am using the correct community, and I could successfully change the image with this code: >> >> from pysnmp.entity.rfc3413.oneliner import cmdgen >> from pysnmp.proto.rfc1902 import OctetString >> >> device_ip = '192.168.1.222' >> port = 6000 >> >> cmdGen = cmdgen.CommandGenerator() >> >> a = '\xff\xff\xff\x03\x00\x3c\x2f\xf5\x00\x00\x00\x00' >> >> errorIndication, errorStatus, errorIndex, varBinds = cmdGen.setCmd( >> cmdgen.CommunityData('public'), >> cmdgen.UdpTransportTarget((device_ip, port)), >> ('1.3.6.1.4.1.1206.4.2.3.6.3.0', OctetString(a)), >> lookupNames=True, lookupValues=True >> ) >> >> I could finally understand the bytes in the sequence and get the OID of the object and the Octet String argument that I have to provide. This octet string (variable "a" in the code I wrote) contains 6 parameters, including the type of memory (03) and the memory number that corresponds to the image (00 3c). >> >> Now, what I don't get is why the new code works, when the only difference is the way I refer to the function I call: >> >> Code that does not work: >> (cmdgen.MibVariable('NTCIP1203_v03_38', 'dmsActivateMessage', 0), >> OctetString(a)), >> >> Code that works: >> ('1.3.6.1.4.1.1206.4.2.3.6.3.0', OctetString(a)), >> >> >> 2015-11-06 17:29 GMT-03:00 Ilya Etingof <il...@gl...>: >> >> Hi Diego, >> >> Make sure you are using correct community name, for SET queries it is frequently defaulted to ‘private’. >> >> If you show me the byte-string that works, I can possibly come up with corresponding SNMP message. >> >> -ilya >> >> > On 05 Nov 2015, at 17:02, Diego Muñoz <dmu...@gm...> wrote: >> > >> > Hello everyone, >> > >> > I have been working with NTCIP for only one week, and I need to change an image on a device by sending a SNMP activation message. I have been given the corresponding MIB, and a byte sequence of a SNMP message. >> > >> > I recently understood how the sequence is formed, and its components. I identified the MIB OID to activate the image, and identified the parameters that I need to give to the function. By editing the byte sequence, I can successfully send the message and change the image with python sockets using UDP. I also can successfully get information from the device with PySNMP and the getCmd function. >> > >> > The problem I have is that I try to setCmd the message and I only get a Timeout from the device. This is the code of my setCmd >> > >> > from pysnmp.entity.rfc3413.oneliner import cmdgen >> > from pysnmp.proto.rfc1902 import OctetString >> > >> > device_ip = '192.168.1.222' >> > port = 6000 >> > >> > cmdGen = cmdgen.CommandGenerator() >> > >> > # this variable includes the parameters I need to send to the device >> > a = '\xff\xff\xff\x03\x00\x0a\x2f\xf5\x00\x00\x00\x00' >> > >> > errorIndication, errorStatus, errorIndex, varBinds = cmdGen.setCmd( >> > cmdgen.CommunityData('public'), >> > cmdgen.UdpTransportTarget((device_ip, port)), >> > (cmdgen.MibVariable('NTCIP1203_v03_38', 'dmsActivateMessage', 0), >> > OctetString(a)), >> > lookupNames=True, lookupValues=True >> > ) >> > >> > I don't know which part is wrong, I would appreciate any help. >> > Regards, >> > Diego >> >> >> > > > ------------------------------------------------------------------------------ > _______________________________________________ > pysnmp-users mailing list > pys...@li... > https://lists.sourceforge.net/lists/listinfo/pysnmp-users |