<p>AUTHOR: erik.johnson@jogle.us</p>
<p>DESCRIPTION:
rawbin.tcl is part of the binconvert package. binconvert is a package
that reads &amp; writes EEPROM memory files in multiple formats.
It converts the data to &amp; from a Tcl representation as a list of
data segments, which is available for processing.</p>
<p>rawbin.tcl contains all the support procs to manage input from binary
files of no particular format. It will</p>
<h6></h6>
<p>This package documentation is auto-generated with
Pycco: <a href="https://pycco-docs.github.io/pycco/">https://pycco-docs.github.io/pycco/</a></p>
<p>Use "pycco <em>filename</em>" to re-generate HTML documentation in ./docs .</p>
</div>
<div class='code'>
<div class="highlight"><pre><span></span>
</pre></div>
</div>
</div>
<div class='clearall'></div>
</div>
</body>

# DESCRIPTION:
# rawbin.tcl is part of the binconvert package. binconvert is a package
# that reads & writes EEPROM memory files in multiple formats.
# It converts the data to & from a Tcl representation as a list of
# data segments, which is available for processing.
#
# rawbin.tcl contains all the support procs to manage input from binary
# files of no particular format. It will
#
###########################################################################
#
# This package documentation is auto-generated with
# Pycco: <https://pycco-docs.github.io/pycco/>
#
# Use "pycco *filename*" to re-generate HTML documentation in ./docs .
#

# DESCRIPTION:
# rawbin.tcl is part of the binconvert package. binconvert is a package
# that reads & writes EEPROM memory files in multiple formats.
# It converts the data to & from a Tcl representation as a list of
# data segments, which is available for processing.
#
# rawbin.tcl contains all the support procs to manage input from binary
# files of no particular format. It assumes a starting address of 0# and packs all data read into one initial segment. When writing out# data, it will start at 0 or such other address as the user sets, and# will fill in undefined data with bytes of 0xFF or as the user sets.
#
###########################################################################
#
# This package documentation is auto-generated with
# Pycco: <https://pycco-docs.github.io/pycco/>
#
# Use "pycco *filename*" to re-generate HTML documentation in ./docs .
#
#--------------------------------------------------------------------------## Procedures for Raw Binary Format## This format is not really a format. This is intended to be used to input# things like memory dumps from tools to be saved in another format, or to# write##--------------------------------------------------------------------------# <a name="ProcessRawbinLine"></a>### ProcessRawbinLine# *ProcessRawbinLine* is the parser for the readline proc. Since the input# file did not have lines, we don't expect more than one lump of data.# Use *binary scan* to convert the whole thing to a list of byte values.## N.B. that there are no checksums or CRCs, and thus no way of detecting a# corrupted file unless the corruption makes a line not interpretable.proc ::binconvert::ProcessRawbinLine {dataIn} { set addr 0 binary scan $dataIn cu* dataL return [list DATA $addr $dataL]}#--------------------------------------------------------------------------# <a name="WriteRawbinFile"></a>### WriteRawbinFile# *WriteRawbinFile* will iterate over the segments of the segment list.#proc ::binconvert::WriteRawbinFile {segmentList outchan {startAddr 0} {fillValue 0x255}} { # Scan the list for the end address. set maxAddr 0 foreach {addr dataL} $segmentList { if {$maxAddr < ($addr + [llength $dataL])} { set maxAddr [expr {$addr + [llength $dataL]}] } } set outL [lrepeat $fillValue ] # We have our filled output list. For each segment, replace the data # in the appropriate range with the segment data. foreach {addr dataL} $segmentList { set outL [lreplace $outL $addr [expr {$addr + [llength $dataL]}] {*}$dataL]] } # After the output list is completely filled, convert it to a binary # string and write it to disk. Don't forget to set the output channel to # binary too, to keep line feeds from being corrupted. set outS [binary format c* $outL] chan configure $outchan -translation binary puts $outchan $outS}