Re: [tkined] Problem handling engineId on the tcl interface in scotty

Graeme McKerrell (graemem@pdd.3com.com)
Mon, 8 Mar 1999 13:21:39 +0000 (GMT)

Here's a snippet of code which I use to look at binary data
#------------------------------------------------------------
# {{{ protocol_DumpHex()

proc protocol_DumpHex {data} {
set pos 0
set result "[format %4d [string length $data]] Bytes 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef"
set bytes {}
set chars {}
for {set pos 0} {$pos < [string length $data]} {} {
binary scan [string index $data $pos] H2 byte
binary scan [string index $data $pos] c1 char
if {($char < 32) || ($char > 126)} {
set char "."
} else {
set char [string index $data $pos]
}
set bytes "$bytes $byte"
set chars "${chars}$char"
incr pos
if {($pos % 16) == 0} {
set result "$result\n [format {%04x} [expr $pos - 16]] :$bytes $chars"
set bytes {}
set chars {}
}
}
if {($pos %16) == 0} {
return $result
}
#
# mop up the end of the line
#
while { $pos % 16} {
set bytes "$bytes .."
set chars "$chars "
incr pos
}
#
# show the last line if needed
#
set result "$result\n [format {%04x} [expr $pos - 16]] :$bytes $chars"

return $result
}

# }}}
#------------------------------------------------------------

it's not too difficult to get into a readable format
Graeme

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.