Re: Mac Addr to bin
From: Aric Bills (aricb_at_u.wwashingtonn.edu)
Date: 11/04/03
- Next message: David Gravereaux: "Re: stubs-enabled Expect"
- Previous message: Bryan Oakley: "how do you test GUI functionality?"
- In reply to: Jaspal: "Re: Mac Addr to bin"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 4 Nov 2003 12:54:47 -0800
Hi Jaspal,
> A) If there's only one character in a pair e.g. [A0 0b c 34 7a 9], the
> solution would work better if I can before "join", make each a 2 character
> pair. (How do I?)
There are two things you could do here. The first would be to loop through
the octets to format them correctly:
set hexString ""
foreach octet $macAddr {
append hexString [ format "%02s" $octet ]
}
set addr [ binary format H12 $hexString ]
The other option is to alter the "formatString" argument to [binary format]
and to use [eval] to break up $macAddr into a set of component arguments:
set addr [ eval binary format H2H2H2H2H2H2 $macAddr ]
If I understand correctly, beginning in Tcl 8.5 it should be possible to use
a leading {expand} instead of [eval] to accomplish the same thing:
set addr [ binary format H2H2H2H2H2H2 {expand}$macAddr ]
> B) In a mac-address, its perfectly legal to have a 00 as any octet i.e.
[00
> 0A 0 b 78 90] and in that case, the string "addr" stops as soon as it
> encounters the first NULL (0x00) - how do I ensure that "addr" is a
variable
> which is independent of the presence of NULL in its value and is always a
6
> character response?
I'm unable to reproduce this error for the test case you provide. [string
length $addr] tells me the binary string is six characters long.
Regards,
Aric
- Next message: David Gravereaux: "Re: stubs-enabled Expect"
- Previous message: Bryan Oakley: "how do you test GUI functionality?"
- In reply to: Jaspal: "Re: Mac Addr to bin"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]