TM wrote:
> I've tested the options.
>
> [binary scan S* ...] doesn't work. I have to stick to [binary scan H* ...].
it should.
do you really need the numbers formatted 0x12ef or would
a list of ints be sufficient?
What do you do with the list you get ?
uwe
>
> Within that constraint, these are the results:
>
> binary scan $pkt H* data
>
> 1. ~280us
> foreach {a b c d} [split $data {}] {
> lappend out "0x${c}${d}${a}${b}"
> }
>
> 2. ~330us
> for {set j 0} {$j < [string length $data]} {incr j 4} {
> set d 0x[string range $data $j [expr {$j + 3}]]
> lappend out [expr {(($d & 0xff) << 8) + (($d & 0xff00) >> 8)}]
> }
>
> 3. ~700us
> for {set j 0} {$j < [string length $data]} {incr j 4} {
> set point [string range $data [expr {$j + 2}] [expr {$j + 3}]][string range $data $j [expr {$j + 1}]]
> lappend out 0x$point
> }
>
> Uwe, your suggestion is indeed the best solution, thanks for your help,
>
> TM
;-)