boodo Posted May 14, 2008 Posted May 14, 2008 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 ???
enaiman Posted May 14, 2008 Posted May 14, 2008 (edited) 641 = 0x82 0x81my bad: 641 = 0x85 0x01 (didn't take into account the 1st digit of 2nd byte.Explanation: 641 = 512 + 128 + 1bytes: 10000010 10000001 Edited May 15, 2008 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 :)
Siao Posted May 15, 2008 Posted May 15, 2008 (edited) 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 May 15, 2008 by Siao "be smart, drink your wine"
ptrex Posted May 15, 2008 Posted May 15, 2008 @boodoThis 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 protocolThe OID normally comes from the MIB file of your device. So you don't have to calculate it I guess ?!regards,ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
boodo Posted May 16, 2008 Author Posted May 16, 2008 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) ;$Broadcast = "172.30.7.122" ; Detination Address $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 ;_StartListener($Socket,$Broadcast) $srcv = UDPRecv($Socket, 2048) If ($srcv <> "") Then ConsoleWrite("Received Response" & @CR) ConsoleWrite($srcv & @CR) ExitLoop EndIf $loop = $loop + 1 If $loop = 1000 Then UDPCloseSocket($Socket) ExitLoop EndIf WEnd EndFunc ;==>_SUPPLYNAME
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now