diff options
| -rwxr-xr-x | recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl | 9 | 
1 files changed, 8 insertions, 1 deletions
| diff --git a/recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl b/recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl index aca956bdf..a4e8008f1 100755 --- a/recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl +++ b/recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl | |||
| @@ -11,6 +11,13 @@ fconfigure $fileid_o -translation {binary binary} | |||
| 11 | 11 | ||
| 12 | set old_bin [read $fileid_i] | 12 | set old_bin [read $fileid_i] | 
| 13 | set new_bin {} | 13 | set new_bin {} | 
| 14 | set old_length [string length $old_bin] | ||
| 15 | set old_rem [expr $old_length % $num_b] | ||
| 16 | if {$old_rem != 0} { | ||
| 17 | for {set i 0} {$i< [expr $num_b - $old_rem]} {incr i 1} { | ||
| 18 | append old_bin y | ||
| 19 | } | ||
| 20 | } | ||
| 14 | for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} { | 21 | for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} { | 
| 15 | for {set j $num_b} {$j>0} {incr j -1} { | 22 | for {set j $num_b} {$j>0} {incr j -1} { | 
| 16 | append new_bin [string index $old_bin [expr $i+($j-1)]] | 23 | append new_bin [string index $old_bin [expr $i+($j-1)]] | 
| @@ -20,7 +27,7 @@ for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} { | |||
| 20 | for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} { | 27 | for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} { | 
| 21 | set binValue [string range $old_bin [expr $i+0] [expr $i+($num_b-1)]] | 28 | set binValue [string range $old_bin [expr $i+0] [expr $i+($num_b-1)]] | 
| 22 | binary scan $binValue H[expr $num_b*2] hexValue | 29 | binary scan $binValue H[expr $num_b*2] hexValue | 
| 23 | 30 | ||
| 24 | set binValue [string range $new_bin [expr $i+0] [expr $i+($num_b-1)]] | 31 | set binValue [string range $new_bin [expr $i+0] [expr $i+($num_b-1)]] | 
| 25 | binary scan $binValue H[expr $num_b*2] hexValue | 32 | binary scan $binValue H[expr $num_b*2] hexValue | 
| 26 | } | 33 | } | 
