Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add ability for caller args for writefile to be passed down to format-specific writer. Use this mechanism for SREC subformats.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f138c2972c42c683b7e77238ce323ae59ba860cc
User & Date: erikj 2017-11-13 10:59:47
Context
2017-11-13
11:20
Updated comments/documentation check-in: a1d097d628 user: erikj tags: trunk
10:59
Add ability for caller args for writefile to be passed down to format-specific writer. Use this mechanism for SREC subformats. check-in: f138c2972c user: erikj tags: trunk
2017-11-09
18:12
Initial implementation of titxt & rawbin. Update comments for better documentation. check-in: 3196e06200 user: erikj tags: trunk
Changes

Changes to binconvert.tcl.

306
307
308
309
310
311
312
313

314
315
316
317
318
319
320
321

322
323
324
325
326
327
328
...
359
360
361
362
363
364
365
366
367
368

369
370
371
372
373
374
375
...
379
380
381
382
383
384
385
386
387
388
389
390

391
392
}

#--------------------------------------------------------------------------
# <a name="writefile"></a>
### writefile

# *writefile* will examine the file format token, then call the appropriate
# output format writer for that file type.

proc ::binconvert::writefile {datafmt segmentList fileName} {
    if {![info exists ::binconvert::Formats($datafmt,writer)]} {
        log::error "binconvert::writefile: Unknown data format $datafmt."
        error "Unknown data format $datafmt"
    }
    set outchan [open $fileName w]
    try {
        {*}$::binconvert::Formats($datafmt,writer) $segmentList $outchan

    } finally {
        chan close $outchan
    }
}

#--------------------------------------------------------------------------
# <a name="addparser"></a>
................................................................................
# that does not normally support a tagged execution start address may be
# hazardous; the user must use their judgement in this case.
#
# N.B. that these are all in the shared ::binconvert:: namespace.
# When a user adds a new format, they must either define their procedures
# in the ::binconvert:: namespace, or must provide a fully-qualified
# namespace path to their procedures.
proc ::binconvert::addparser {formatSymbol parseProcName writeProcName} {
    set ::binconvert::Formats($formatSymbol,parser) $parseProcName
    set ::binconvert::Formats($formatSymbol,writer) $writeProcName

}

#--------------------------------------------------------------------------
#### loglevel
# simple accessor to change the level of the package's log for debugging.
proc ::binconvert::loglevel {newLevel} {
    ::binconvert::log::setlevel $newLevel
................................................................................
#--------------------------------------------------------------------------
# <a name="importformats"></a>
# Here is where we actually set up all the package-supplied formats.
::binconvert::addparser ihex ProcessIhexLine WriteIhexFile
::binconvert::addparser i8hex ProcessIhexLine WriteI8hexFile
::binconvert::addparser i16hex ProcessIhexLine WriteI16hexFile
::binconvert::addparser i32hex ProcessIhexLine WriteI32hexFile
::binconvert::addparser srec ProcessSrecLine {WriteSrecFile 00}
::binconvert::addparser S19 ProcessSrecLine {WriteSrecFile S19}
::binconvert::addparser S28 ProcessSrecLine {WriteSrecFile S28}
::binconvert::addparser S37 ProcessSrecLine {WriteSrecFile S37}
::binconvert::addparser titxt ProcessTitxtLine WriteTitxtFile


unset ::BINCONVERT_PKG_VERSION







|
>
|






|
>







 







|


>







 







|
|
|
|

>


306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
...
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
...
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
}

#--------------------------------------------------------------------------
# <a name="writefile"></a>
### writefile

# *writefile* will examine the file format token, then call the appropriate
# output format writer for that file type. Prepend any special writer arguments
# to any extra caller args when calling the writer.
proc ::binconvert::writefile {datafmt segmentList fileName args} {
    if {![info exists ::binconvert::Formats($datafmt,writer)]} {
        log::error "binconvert::writefile: Unknown data format $datafmt."
        error "Unknown data format $datafmt"
    }
    set outchan [open $fileName w]
    try {
        {*}$::binconvert::Formats($datafmt,writer) $segmentList $outchan \
                    {*}$::binconvert::Formats($datafmt,writeArgs)  {*}$args
    } finally {
        chan close $outchan
    }
}

#--------------------------------------------------------------------------
# <a name="addparser"></a>
................................................................................
# that does not normally support a tagged execution start address may be
# hazardous; the user must use their judgement in this case.
#
# N.B. that these are all in the shared ::binconvert:: namespace.
# When a user adds a new format, they must either define their procedures
# in the ::binconvert:: namespace, or must provide a fully-qualified
# namespace path to their procedures.
proc ::binconvert::addparser {formatSymbol parseProcName writeProcName args} {
    set ::binconvert::Formats($formatSymbol,parser) $parseProcName
    set ::binconvert::Formats($formatSymbol,writer) $writeProcName
    set ::binconvert::Formats($formatSymbol,writeArgs) $args
}

#--------------------------------------------------------------------------
#### loglevel
# simple accessor to change the level of the package's log for debugging.
proc ::binconvert::loglevel {newLevel} {
    ::binconvert::log::setlevel $newLevel
................................................................................
#--------------------------------------------------------------------------
# <a name="importformats"></a>
# Here is where we actually set up all the package-supplied formats.
::binconvert::addparser ihex ProcessIhexLine WriteIhexFile
::binconvert::addparser i8hex ProcessIhexLine WriteI8hexFile
::binconvert::addparser i16hex ProcessIhexLine WriteI16hexFile
::binconvert::addparser i32hex ProcessIhexLine WriteI32hexFile
::binconvert::addparser srec ProcessSrecLine WriteSrecFile
::binconvert::addparser S19 ProcessSrecLine WriteSrecFile S19
::binconvert::addparser S28 ProcessSrecLine WriteSrecFile S28
::binconvert::addparser S37 ProcessSrecLine WriteSrecFile S37
::binconvert::addparser titxt ProcessTitxtLine WriteTitxtFile
::binconvert::addparser titxt ProcessRawbinLine WriteRawbinFile

unset ::BINCONVERT_PKG_VERSION

Changes to docs/binconvert.html.

536
537
538
539
540
541
542
543

544
545
546
547
548
549
550
551
552
553

554
555
556
557
558
559
560
...
608
609
610
611
612
613
614
615
616
617

618
619
620
621
622
623
624
...
645
646
647
648
649
650
651
652
653
654
655
656

657
658
659
660
661
662
663
664
665
  <div class='clearall'></div>
  <div class='section' id='section-24'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-24'>#</a>
      </div>
      <p><em>writefile</em> will examine the file format token, then call the appropriate
output format writer for that file type.</p>

    </div>
    <div class='code'>
      <div class="highlight"><pre><span class="k">proc</span> <span class="o">::</span>binconvert::writefile <span class="k">{</span><span class="nv">datafmt</span> segmentList fileName<span class="k">}</span> <span class="k">{</span>
    <span class="k">if</span> <span class="k">{</span><span class="o">!</span><span class="k">[</span><span class="nb">info</span> exists <span class="o">::</span>binconvert::Formats<span class="k">(</span><span class="nv">$datafmt</span><span class="err">,</span><span class="nv">writer</span><span class="k">)]}</span> <span class="k">{</span>
        <span class="nv">log</span><span class="o">::</span>error <span class="s2">&quot;binconvert::writefile: Unknown data format $datafmt.&quot;</span>
        <span class="k">error</span> <span class="s2">&quot;Unknown data format $datafmt&quot;</span>
    <span class="k">}</span>
    <span class="k">set</span> outchan <span class="k">[</span><span class="nb">open</span> <span class="nv">$fileName</span> w<span class="k">]</span>
    <span class="nv">try</span> <span class="k">{</span>
        <span class="k">{</span><span class="o">*</span><span class="k">}</span><span class="nv">$::binconvert::Formats</span><span class="k">(</span><span class="nv">$datafmt</span><span class="err">,</span><span class="nv">writer</span><span class="k">)</span> <span class="nv">$segmentList</span> <span class="nv">$outchan</span>

    <span class="k">}</span> finally <span class="k">{</span>
        <span class="nb">chan</span> close <span class="nv">$outchan</span>
    <span class="k">}</span>
<span class="k">}</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
................................................................................
hazardous; the user must use their judgement in this case.</p>
<p>N.B. that these are all in the shared ::binconvert:: namespace.
When a user adds a new format, they must either define their procedures
in the ::binconvert:: namespace, or must provide a fully-qualified
namespace path to their procedures.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre><span class="k">proc</span> <span class="o">::</span>binconvert::addparser <span class="k">{</span><span class="nv">formatSymbol</span> parseProcName writeProcName<span class="k">}</span> <span class="k">{</span>
    <span class="k">set</span> <span class="o">::</span>binconvert::Formats<span class="k">(</span><span class="nv">$formatSymbol</span><span class="err">,</span><span class="nv">parser</span><span class="k">)</span> <span class="nv">$parseProcName</span>
    <span class="k">set</span> <span class="o">::</span>binconvert::Formats<span class="k">(</span><span class="nv">$formatSymbol</span><span class="err">,</span><span class="nv">writer</span><span class="k">)</span> <span class="nv">$writeProcName</span>

<span class="k">}</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-27'>
    <div class='docs'>
      <div class='octowrap'>
................................................................................
Here is where we actually set up all the package-supplied formats.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre><span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser ihex ProcessIhexLine WriteIhexFile
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser i8hex ProcessIhexLine WriteI8hexFile
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser i16hex ProcessIhexLine WriteI16hexFile
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser i32hex ProcessIhexLine WriteI32hexFile
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser srec ProcessSrecLine <span class="k">{</span><span class="nv">WriteSrecFile</span> <span class="mo">00</span><span class="k">}</span>
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser S19 ProcessSrecLine <span class="k">{</span><span class="nv">WriteSrecFile</span> S19<span class="k">}</span>
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser S28 ProcessSrecLine <span class="k">{</span><span class="nv">WriteSrecFile</span> S28<span class="k">}</span>
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser S37 ProcessSrecLine <span class="k">{</span><span class="nv">WriteSrecFile</span> S37<span class="k">}</span>
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser titxt ProcessTitxtLine WriteTitxtFile


<span class="k">unset</span> <span class="o">::</span>BINCONVERT_PKG_VERSION

</pre></div>
    </div>
  </div>
  <div class='clearall'></div>
</div>
</body>







|
>


|






|
>







 







|


>







 







|
|
|
|

>









536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
...
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
...
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
  <div class='clearall'></div>
  <div class='section' id='section-24'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-24'>#</a>
      </div>
      <p><em>writefile</em> will examine the file format token, then call the appropriate
output format writer for that file type. Prepend any special writer arguments
to any extra caller args when calling the writer.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre><span class="k">proc</span> <span class="o">::</span>binconvert::writefile <span class="k">{</span><span class="nv">datafmt</span> segmentList fileName args<span class="k">}</span> <span class="k">{</span>
    <span class="k">if</span> <span class="k">{</span><span class="o">!</span><span class="k">[</span><span class="nb">info</span> exists <span class="o">::</span>binconvert::Formats<span class="k">(</span><span class="nv">$datafmt</span><span class="err">,</span><span class="nv">writer</span><span class="k">)]}</span> <span class="k">{</span>
        <span class="nv">log</span><span class="o">::</span>error <span class="s2">&quot;binconvert::writefile: Unknown data format $datafmt.&quot;</span>
        <span class="k">error</span> <span class="s2">&quot;Unknown data format $datafmt&quot;</span>
    <span class="k">}</span>
    <span class="k">set</span> outchan <span class="k">[</span><span class="nb">open</span> <span class="nv">$fileName</span> w<span class="k">]</span>
    <span class="nv">try</span> <span class="k">{</span>
        <span class="k">{</span><span class="o">*</span><span class="k">}</span><span class="nv">$::binconvert::Formats</span><span class="k">(</span><span class="nv">$datafmt</span><span class="err">,</span><span class="nv">writer</span><span class="k">)</span> <span class="nv">$segmentList</span> <span class="nv">$outchan</span> <span class="err">\</span>
                    <span class="k">{</span><span class="o">*</span><span class="k">}</span><span class="nv">$::binconvert::Formats</span><span class="k">(</span><span class="nv">$datafmt</span><span class="err">,</span><span class="nv">writeArgs</span><span class="k">)</span>  <span class="k">{</span><span class="o">*</span><span class="k">}</span><span class="nv">$args</span>
    <span class="k">}</span> finally <span class="k">{</span>
        <span class="nb">chan</span> close <span class="nv">$outchan</span>
    <span class="k">}</span>
<span class="k">}</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
................................................................................
hazardous; the user must use their judgement in this case.</p>
<p>N.B. that these are all in the shared ::binconvert:: namespace.
When a user adds a new format, they must either define their procedures
in the ::binconvert:: namespace, or must provide a fully-qualified
namespace path to their procedures.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre><span class="k">proc</span> <span class="o">::</span>binconvert::addparser <span class="k">{</span><span class="nv">formatSymbol</span> parseProcName writeProcName args<span class="k">}</span> <span class="k">{</span>
    <span class="k">set</span> <span class="o">::</span>binconvert::Formats<span class="k">(</span><span class="nv">$formatSymbol</span><span class="err">,</span><span class="nv">parser</span><span class="k">)</span> <span class="nv">$parseProcName</span>
    <span class="k">set</span> <span class="o">::</span>binconvert::Formats<span class="k">(</span><span class="nv">$formatSymbol</span><span class="err">,</span><span class="nv">writer</span><span class="k">)</span> <span class="nv">$writeProcName</span>
    <span class="k">set</span> <span class="o">::</span>binconvert::Formats<span class="k">(</span><span class="nv">$formatSymbol</span><span class="err">,</span><span class="nv">writeArgs</span><span class="k">)</span> <span class="nv">$args</span>
<span class="k">}</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-27'>
    <div class='docs'>
      <div class='octowrap'>
................................................................................
Here is where we actually set up all the package-supplied formats.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre><span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser ihex ProcessIhexLine WriteIhexFile
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser i8hex ProcessIhexLine WriteI8hexFile
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser i16hex ProcessIhexLine WriteI16hexFile
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser i32hex ProcessIhexLine WriteI32hexFile
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser srec ProcessSrecLine WriteSrecFile
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser S19 ProcessSrecLine WriteSrecFile S19
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser S28 ProcessSrecLine WriteSrecFile S28
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser S37 ProcessSrecLine WriteSrecFile S37
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser titxt ProcessTitxtLine WriteTitxtFile
<span class="o">::</span><span class="nv">binconvert</span><span class="o">::</span>addparser titxt ProcessRawbinLine WriteRawbinFile

<span class="k">unset</span> <span class="o">::</span>BINCONVERT_PKG_VERSION

</pre></div>
    </div>
  </div>
  <div class='clearall'></div>
</div>
</body>

Changes to docs/rawbin.html.

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
      <div class='octowrap'>
        <a class='octothorpe' href='#section-1'>#</a>
      </div>
      <hr />
<h1>Procedures for Raw Binary Format</h1>
<p>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</p>
<hr />
<p><a name="ProcessRawbinLine"></a></p>
<h2>ProcessRawbinLine</h2>
    </div>
    <div class='code'>
      <div class="highlight"><pre></pre></div>
    </div>







|







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
      <div class='octowrap'>
        <a class='octothorpe' href='#section-1'>#</a>
      </div>
      <hr />
<h1>Procedures for Raw Binary Format</h1>
<p>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 binary data to output channels that expect it.</p>
<hr />
<p><a name="ProcessRawbinLine"></a></p>
<h2>ProcessRawbinLine</h2>
    </div>
    <div class='code'>
      <div class="highlight"><pre></pre></div>
    </div>

Changes to docs/srec.html.

372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
...
408
409
410
411
412
413
414
415

416
417
418




419
420
421
422
423
424
425
subformat is larger it will use that.</p>
<p>It starts by scanning the segment list.  If it finds a HEADER or STARTADDR
segment, it will save them for later use at the appropriate time.  Data
segments get added to a working list.  Max address is used to determine
which output format is selected.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre><span class="k">proc</span> <span class="o">::</span>binconvert::WriteSrecFile <span class="k">{</span><span class="nv">subformat</span> segmentList outchan<span class="k">}</span> <span class="k">{</span>
    <span class="k">set</span> filetype S19
    <span class="k">set</span> headerData <span class="k">{</span><span class="nv">0</span><span class="k">}</span>
    <span class="k">set</span> startAddr <span class="mi">0</span>
    <span class="k">foreach</span> <span class="k">{</span><span class="nv">addr</span> dataL<span class="k">}</span> <span class="nv">$segmentList</span> <span class="k">{</span>
        <span class="k">set</span> len <span class="k">[</span><span class="nb">llength</span> <span class="nv">$dataL</span><span class="k">]</span>
        <span class="err">;</span><span class="c"># Have to test alpha cases first as they break all the math</span>
        <span class="k">if</span> <span class="k">{</span><span class="nv">$addr</span> <span class="nv">eq</span> <span class="s2">&quot;HEADER&quot;</span><span class="k">}</span> <span class="k">{</span>
................................................................................
      <div class='octowrap'>
        <a class='octothorpe' href='#section-18'>#</a>
      </div>
      <p>If the user selected a format, override the self-detected filetype,
if and only if the data will fit in that format.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>    <span class="k">if</span> <span class="k">{(</span><span class="nv">$subformat</span> <span class="o">!=</span> <span class="s2">&quot;00&quot;</span><span class="k">)}</span> <span class="k">{</span>

        <span class="k">if</span> <span class="k">{(</span><span class="nv">$subformat</span> <span class="o">&lt;</span> <span class="nv">$filetype</span><span class="k">)}</span> <span class="k">{</span>
            <span class="nv">log</span><span class="o">::</span>error <span class="s2">&quot;binconvert: writeSrecFile: User specified output format\</span>
<span class="s2">                    cannot hold addresses found in data. Using format $filetype.&quot;</span>




        <span class="k">}</span> <span class="k">else</span> <span class="k">{</span>
            <span class="k">set</span> filetype <span class="nv">$subformat</span>
        <span class="k">}</span>
    <span class="k">}</span>
    <span class="nv">log</span><span class="o">::</span>info <span class="s2">&quot;Formatting output file as $filetype file...&quot;</span></pre></div>
    </div>
  </div>







|







 







|
>



>
>
>
>







372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
...
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
subformat is larger it will use that.</p>
<p>It starts by scanning the segment list.  If it finds a HEADER or STARTADDR
segment, it will save them for later use at the appropriate time.  Data
segments get added to a working list.  Max address is used to determine
which output format is selected.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre><span class="k">proc</span> <span class="o">::</span>binconvert::WriteSrecFile <span class="k">{</span><span class="nv">segmentList</span> outchan args<span class="k">}</span> <span class="k">{</span>
    <span class="k">set</span> filetype S19
    <span class="k">set</span> headerData <span class="k">{</span><span class="nv">0</span><span class="k">}</span>
    <span class="k">set</span> startAddr <span class="mi">0</span>
    <span class="k">foreach</span> <span class="k">{</span><span class="nv">addr</span> dataL<span class="k">}</span> <span class="nv">$segmentList</span> <span class="k">{</span>
        <span class="k">set</span> len <span class="k">[</span><span class="nb">llength</span> <span class="nv">$dataL</span><span class="k">]</span>
        <span class="err">;</span><span class="c"># Have to test alpha cases first as they break all the math</span>
        <span class="k">if</span> <span class="k">{</span><span class="nv">$addr</span> <span class="nv">eq</span> <span class="s2">&quot;HEADER&quot;</span><span class="k">}</span> <span class="k">{</span>
................................................................................
      <div class='octowrap'>
        <a class='octothorpe' href='#section-18'>#</a>
      </div>
      <p>If the user selected a format, override the self-detected filetype,
if and only if the data will fit in that format.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>    <span class="k">if</span> <span class="k">{(</span><span class="nv">$args</span> <span class="nv">ne</span> <span class="k">{})}</span> <span class="k">{</span>
        <span class="k">set</span> subformat <span class="k">[</span><span class="nb">lindex</span> <span class="nv">$args</span> <span class="mi">0</span><span class="k">]</span>
        <span class="k">if</span> <span class="k">{(</span><span class="nv">$subformat</span> <span class="o">&lt;</span> <span class="nv">$filetype</span><span class="k">)}</span> <span class="k">{</span>
            <span class="nv">log</span><span class="o">::</span>error <span class="s2">&quot;binconvert: writeSrecFile: User specified output format\</span>
<span class="s2">                    cannot hold addresses found in data. Using format $filetype.&quot;</span>
        <span class="k">}</span> <span class="k">elseif</span> <span class="k">{</span><span class="nv">$subformat</span> <span class="nv">ni</span> <span class="k">{</span><span class="nv">S19</span> S28 S37<span class="k">}}</span> <span class="k">{</span>
            <span class="nv">log</span><span class="o">::</span>error <span class="s2">&quot;binconvert: writeSrecFile: User specified subformat\</span>
<span class="s2">                    $subformat not known.  Valid subformats are S19, S28, &amp;\</span>
<span class="s2">                    S37.  Using format $filetype.&quot;</span>
        <span class="k">}</span> <span class="k">else</span> <span class="k">{</span>
            <span class="k">set</span> filetype <span class="nv">$subformat</span>
        <span class="k">}</span>
    <span class="k">}</span>
    <span class="nv">log</span><span class="o">::</span>info <span class="s2">&quot;Formatting output file as $filetype file...&quot;</span></pre></div>
    </div>
  </div>

Changes to rawbin.tcl.

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#

#--------------------------------------------------------------------------
## 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.







|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#

#--------------------------------------------------------------------------
## 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 binary data to output channels that expect it.
#
#--------------------------------------------------------------------------
# <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.

Changes to srec.tcl.

199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
...
225
226
227
228
229
230
231
232

233
234
235




236
237
238
239
240
241
242
# subformat is larger it will use that.
#
# It starts by scanning the segment list.  If it finds a HEADER or STARTADDR
# segment, it will save them for later use at the appropriate time.  Data
# segments get added to a working list.  Max address is used to determine
# which output format is selected.
#
proc ::binconvert::WriteSrecFile {subformat segmentList outchan} {
    set filetype S19
    set headerData {0}
    set startAddr 0
    foreach {addr dataL} $segmentList {
        set len [llength $dataL]
        ;# Have to test alpha cases first as they break all the math
        if {$addr eq "HEADER"} {
................................................................................
        } elseif {(($addr + $len - 1) > 0xFFFF) && ($bits < 16)} {
            set filetype S28
        }
        lappend outSegL $addr $dataL
    }
    # If the user selected a format, override the self-detected filetype,
    # if and only if the data will fit in that format.
    if {($subformat != "00")} {

        if {($subformat < $filetype)} {
            log::error "binconvert: writeSrecFile: User specified output format\
                    cannot hold addresses found in data. Using format $filetype."




        } else {
            set filetype $subformat
        }
    }
    log::info "Formatting output file as $filetype file..."

    # Our pre-scan is done.  Let's start writing the output file.







|







 







|
>



>
>
>
>







199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
...
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# subformat is larger it will use that.
#
# It starts by scanning the segment list.  If it finds a HEADER or STARTADDR
# segment, it will save them for later use at the appropriate time.  Data
# segments get added to a working list.  Max address is used to determine
# which output format is selected.
#
proc ::binconvert::WriteSrecFile {segmentList outchan args} {
    set filetype S19
    set headerData {0}
    set startAddr 0
    foreach {addr dataL} $segmentList {
        set len [llength $dataL]
        ;# Have to test alpha cases first as they break all the math
        if {$addr eq "HEADER"} {
................................................................................
        } elseif {(($addr + $len - 1) > 0xFFFF) && ($bits < 16)} {
            set filetype S28
        }
        lappend outSegL $addr $dataL
    }
    # If the user selected a format, override the self-detected filetype,
    # if and only if the data will fit in that format.
    if {($args ne {})} {
        set subformat [lindex $args 0]
        if {($subformat < $filetype)} {
            log::error "binconvert: writeSrecFile: User specified output format\
                    cannot hold addresses found in data. Using format $filetype."
        } elseif {$subformat ni {S19 S28 S37}} {
            log::error "binconvert: writeSrecFile: User specified subformat\
                    $subformat not known.  Valid subformats are S19, S28, &\
                    S37.  Using format $filetype."
        } else {
            set filetype $subformat
        }
    }
    log::info "Formatting output file as $filetype file..."

    # Our pre-scan is done.  Let's start writing the output file.