# A Hex Enigma

## Recommended Posts

Hi,

have somebody an idea how to do this ?

However, a special rule is required for large numbers because one byte (eight bits) can only represent a number from 0-255. For example, the number 2680 in the Rane NM 1 microphoneMute OID '1.3.6.1.4.1.2680.1.2.7.3.2.0' cannot be encoded using a single byte. The rule for large numbers states that only the lower 7 bits in the byte are used for holding the value (0-127). The highest order bit is used as a flag to let the recipient know that this number spans more than one byte. Therefore, any number over 127 must be encoded using more than one byte. According to this rule, the number 2680 must be encoded 0x94 0x78. Since the most significant bit is set in the first byte (0x94), the recipient knows to use the lower 7 bits from each byte (0x14 and 0x78) and decode the two bytes as (0x14 *128) + 0x78 = 2680.

I want to convert 641 ???

##### Share on other sites

641 = 0x82 0x81

my bad: 641 = 0x85 0x01 (didn't take into account the 1st digit of 2nd byte.

Explanation: 641 = 512 + 128 + 1

bytes: 10000010 10000001

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

##### Share on other sites

If 127<\$i<16384

you can do

\$encoded = Hex(BitOR(BitShift(\$i/128,-8),32768,Mod(\$i,128)),4)

Not sure how this works out with numbers higher than 16383 and I'm not in the mood for thinking. I don't quite understand how 0x82B1FAD929 translates into 641641641 in the post above.

Edited by Siao

##### Share on other sites

@boodo

This looks as you are after an SNMP OID.

Maybe you might be interested in looking at my SNMP example in the example script section.

Using SNMP - MIB protocol

The OID normally comes from the MIB file of your device. So you don't have to calculate it I guess ?!

regards,

ptrex

##### Share on other sites

Thanks alot that helps me very well

@ptrex

I don`t want to use mib files with oid`s iàm more indipendend.

But there is a nother problem

This function works with any Lexmark Printer but not with any HP ore Kyocero or something else.

SNMPGET tells me from the other printers that the name is correct.

The Oid is:

.iso.3.6.1.2.1.25.3.2.1.3.1

Here is a Probe:

.iso.3.6.1.2.1.25.3.2.1.3.1 = "HP Color LaserJet 2840"

I converted to hex:

06010201190302010301

But it is shorter then the others so i aded 00 -> 0601020119030201030100 -> All Lexmark Printers are sending a reply but no hp ore others.

Now iam searching in the internet the oid is a Octet String so i changed 06 in 04 in the protokoll. Nothing happens at next i delete the 2 00 and changing the lenght to 0B but the same. No Response.

Her The code fore some try`s

I Hope that someone could this understand Mad World....

#include <string.au3>

_SUPPLYNAME ("10.1.32.29")

Func _SUPPLYNAME(\$ip)

ConsoleWrite(@CRLF & "| | | Funktion zum Auslesen des Supplynamens aufgerufen ! | | |" & @CRLF)

\$Port = 161 ; UDP 161 = SNMP port

UDPStartup()

\$Start = 1

\$Socket = UDPOpen(\$ip, \$Port)

ConsoleWrite(@CRLF & \$Socket[1] & "|" & \$Socket[2] & "|" & \$Socket[3] & @LF & @LF)

\$cmd = "0x302B02010004067075626C6963A01E0202014402010002010030123010060C2B06010201190302010301000500"

ConsoleWrite(\$cmd & @LF & @LF)

UDPSend(\$Socket, \$cmd)

\$loop = 1

While 1

\$srcv = UDPRecv(\$Socket, 2048)

If (\$srcv <> "") Then

ConsoleWrite(\$srcv & @CR)

ExitLoop

EndIf

\$loop = \$loop + 1

If \$loop = 1000 Then

UDPCloseSocket(\$Socket)

ExitLoop

EndIf

WEnd

EndFunc ;==>_SUPPLYNAME

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...