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

Overview
Comment:Titxt writer ignores HEADER & STARTADDR segments, updates comments; rawbin writer clarified that startAddr changes the address the binary block starts at, subtracting that from all segment addresses.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:e09058b48723789d388144e43e5930d4d18161e4
User & Date: erikj 2017-12-07 01:15:39
Context
2017-12-07
01:16
Regen documentation. check-in: 094858366a user: erikj tags: trunk
01:15
Titxt writer ignores HEADER & STARTADDR segments, updates comments; rawbin writer clarified that startAddr changes the address the binary block starts at, subtracting that from all segment addresses. check-in: e09058b487 user: erikj tags: trunk
2017-11-29
01:22
Discovered pkgindex.tcl wasn't properly added. Added it. check-in: 8d46527ba7 user: erikj tags: trunk
Changes

Changes to binconvert.tcl.

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
    namespace export loglevel
    namespace ensemble create

    logger::init ::binconvert
    logger::import -all -namespace ::binconvert::log ::binconvert
}

# The list of valid subtypes supplied in the package is:

# * [ihex](ihex.html)
# * i8hex
# * i16hex
# * i32hex
source [file join $dir ihex.tcl]
# * [srec](srec.html)







|







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
    namespace export loglevel
    namespace ensemble create

    logger::init ::binconvert
    logger::import -all -namespace ::binconvert::log ::binconvert
}

# The list of valid formats and subformats supplied in the package is:

# * [ihex](ihex.html)
# * i8hex
# * i16hex
# * i32hex
source [file join $dir ihex.tcl]
# * [srec](srec.html)

Changes to docs/binconvert.html.

143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
...
347
348
349
350
351
352
353

354
355
356
357
358
359
360
...
418
419
420
421
422
423
424

425
426
427
428
429
430
431
...
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
...
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
...
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-4'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-4'>#</a>
      </div>
      <p>The list of valid subtypes supplied in the package is:</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-5'>
................................................................................
If the format <em>is</em> raw binary, there's no lines to split, but we
need to read it as binary.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>        <span class="k">if</span> <span class="k">{</span><span class="nv">$datafmt</span> <span class="nv">ne</span> <span class="s2">&quot;rawbin&quot;</span><span class="k">}</span> <span class="k">{</span>
            <span class="k">set</span> dataS <span class="k">[</span><span class="nb">read</span> <span class="nv">$chan</span><span class="k">]</span>
            <span class="k">set</span> dataL <span class="k">[</span><span class="nb">split</span> <span class="nv">$dataS</span> <span class="err">\</span>n<span class="k">]</span>

        <span class="k">}</span> <span class="k">else</span> <span class="k">{</span>
            <span class="nb">chan</span> configure <span class="nv">$chan</span> <span class="o">-</span>translation <span class="k">{</span><span class="nb">binary</span> binary<span class="k">}</span> <span class="o">-</span>encoding binary
            <span class="k">set</span> dataS <span class="k">[</span><span class="nb">read</span> <span class="nv">$chan</span><span class="k">]</span>
        <span class="k">}</span>
    <span class="k">}</span> finally <span class="k">{</span>
        <span class="nb">chan</span> close <span class="nv">$chan</span>
    <span class="k">}</span></pre></div>
................................................................................
new segment.
Either way, after any fix-up work, append the line data
to the current active segment.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>            <span class="k">}</span>
            <span class="nv">DATA</span> <span class="k">{</span>

                <span class="k">if</span> <span class="k">{([</span><span class="nb">lindex</span> <span class="nv">$lineL</span> <span class="mi">1</span><span class="k">]</span> <span class="o">+</span> <span class="nv">$segAddr</span><span class="k">)</span> <span class="o">!=</span> <span class="nv">$address</span><span class="k">}</span> <span class="k">{</span>
                    <span class="k">if</span> <span class="k">{[</span><span class="nb">llength</span> <span class="nv">$segData</span><span class="k">]</span> <span class="o">!=</span> <span class="nv">0</span><span class="k">}</span> <span class="k">{</span>
                        <span class="nb">lappend</span> resultL <span class="nv">$startAddress</span> <span class="nv">$segData</span>
                    <span class="k">}</span>
                    <span class="k">set</span> address <span class="k">[expr</span> <span class="k">{[</span><span class="nb">lindex</span> <span class="nv">$lineL</span> <span class="mi">1</span><span class="k">]</span> <span class="o">+</span> <span class="nv">$segAddr</span><span class="k">}]</span>
                    <span class="k">set</span> startAddress <span class="nv">$address</span>
                    <span class="k">set</span> segData <span class="k">[</span><span class="nb">list</span><span class="k">]</span>
................................................................................
<p>New segment offset address, where segAddr is an offset that will
be added to all line addresses until the next segment addr line.</p>
<p>Wrap up any ongoing segment and init a new segment.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>            <span class="k">}</span>
            <span class="nv">SEGADDR</span> <span class="k">{</span>
                <span class="nv">log</span><span class="o">::</span>debug <span class="s2">&quot;Found OFFSETADDR [lindex $lineL 1]&quot;</span>
                <span class="k">set</span> segAddr <span class="k">[</span><span class="nb">lindex</span> <span class="nv">$lineL</span> <span class="mi">1</span><span class="k">]</span>
                <span class="k">if</span> <span class="k">{[</span><span class="nb">llength</span> <span class="nv">$segData</span><span class="k">]</span> <span class="o">!=</span> <span class="nv">0</span><span class="k">}</span> <span class="k">{</span>
                    <span class="nb">lappend</span> resultL <span class="nv">$startAddress</span> <span class="nv">$segData</span>
                <span class="k">}</span>
                <span class="k">set</span> address <span class="nv">$segAddr</span>
                <span class="k">set</span> startAddress <span class="nv">$address</span>
                <span class="k">set</span> segData <span class="k">[</span><span class="nb">list</span><span class="k">]</span></pre></div>
................................................................................
  <div class='clearall'></div>
  <div class='section' id='section-21'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-21'>#</a>
      </div>
      <h4>Start Address line.</h4>
<p>Contains processor address at which to start execution from,
if this was a processor.</p>
<p>Note: All start address types map to this.  Because it's
relevant to their output format, I16hex and I32hex include an
extra field in their output with the format type.  This is
passed along and must be dealt with in the writers.</p>
<p>N.B. that the "address" for this segment is the text
string "STARTADDR", and the data is a single address number
rather than a byte list.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>            <span class="k">}</span>
            <span class="nv">STARTADDR</span> <span class="k">{</span>
                <span class="nv">log</span><span class="o">::</span>debug <span class="s2">&quot;Found STARTADDR&quot;</span>
                <span class="k">if</span> <span class="k">{[</span><span class="nb">llength</span> <span class="nv">$segData</span><span class="k">]</span> <span class="o">!=</span> <span class="nv">0</span><span class="k">}</span> <span class="k">{</span>
                    <span class="nb">lappend</span> resultL <span class="nv">$startAddress</span> <span class="nv">$segData</span>
                <span class="k">}</span>
                <span class="k">set</span> address <span class="s2">&quot;STARTADDR&quot;</span>
                <span class="k">set</span> startAddress <span class="nv">$address</span>
                <span class="k">set</span> segData <span class="k">[</span><span class="nb">lrange</span> <span class="nv">$lineL</span> <span class="mi">1</span> end<span class="k">]</span></pre></div>
    </div>
................................................................................
<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>







|







 







>







 







>







 







|







 







|






|
|




|







 







|









143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
...
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
...
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
...
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
...
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
...
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-4'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-4'>#</a>
      </div>
      <p>The list of valid formats and subformats supplied in the package is:</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-5'>
................................................................................
If the format <em>is</em> raw binary, there's no lines to split, but we
need to read it as binary.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>        <span class="k">if</span> <span class="k">{</span><span class="nv">$datafmt</span> <span class="nv">ne</span> <span class="s2">&quot;rawbin&quot;</span><span class="k">}</span> <span class="k">{</span>
            <span class="k">set</span> dataS <span class="k">[</span><span class="nb">read</span> <span class="nv">$chan</span><span class="k">]</span>
            <span class="k">set</span> dataL <span class="k">[</span><span class="nb">split</span> <span class="nv">$dataS</span> <span class="err">\</span>n<span class="k">]</span>
            <span class="nv">log</span><span class="o">::</span>debug <span class="s2">&quot;File read.  [llength $dataL] lines found.&quot;</span>
        <span class="k">}</span> <span class="k">else</span> <span class="k">{</span>
            <span class="nb">chan</span> configure <span class="nv">$chan</span> <span class="o">-</span>translation <span class="k">{</span><span class="nb">binary</span> binary<span class="k">}</span> <span class="o">-</span>encoding binary
            <span class="k">set</span> dataS <span class="k">[</span><span class="nb">read</span> <span class="nv">$chan</span><span class="k">]</span>
        <span class="k">}</span>
    <span class="k">}</span> finally <span class="k">{</span>
        <span class="nb">chan</span> close <span class="nv">$chan</span>
    <span class="k">}</span></pre></div>
................................................................................
new segment.
Either way, after any fix-up work, append the line data
to the current active segment.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>            <span class="k">}</span>
            <span class="nv">DATA</span> <span class="k">{</span>
                <span class="nv">log</span><span class="o">::</span>debug <span class="s2">&quot;DATA: $lineL&quot;</span>
                <span class="k">if</span> <span class="k">{([</span><span class="nb">lindex</span> <span class="nv">$lineL</span> <span class="mi">1</span><span class="k">]</span> <span class="o">+</span> <span class="nv">$segAddr</span><span class="k">)</span> <span class="o">!=</span> <span class="nv">$address</span><span class="k">}</span> <span class="k">{</span>
                    <span class="k">if</span> <span class="k">{[</span><span class="nb">llength</span> <span class="nv">$segData</span><span class="k">]</span> <span class="o">!=</span> <span class="nv">0</span><span class="k">}</span> <span class="k">{</span>
                        <span class="nb">lappend</span> resultL <span class="nv">$startAddress</span> <span class="nv">$segData</span>
                    <span class="k">}</span>
                    <span class="k">set</span> address <span class="k">[expr</span> <span class="k">{[</span><span class="nb">lindex</span> <span class="nv">$lineL</span> <span class="mi">1</span><span class="k">]</span> <span class="o">+</span> <span class="nv">$segAddr</span><span class="k">}]</span>
                    <span class="k">set</span> startAddress <span class="nv">$address</span>
                    <span class="k">set</span> segData <span class="k">[</span><span class="nb">list</span><span class="k">]</span>
................................................................................
<p>New segment offset address, where segAddr is an offset that will
be added to all line addresses until the next segment addr line.</p>
<p>Wrap up any ongoing segment and init a new segment.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>            <span class="k">}</span>
            <span class="nv">SEGADDR</span> <span class="k">{</span>
                <span class="nv">log</span><span class="o">::</span>debug <span class="s2">&quot;Found SEGADDR [lindex $lineL 1]&quot;</span>
                <span class="k">set</span> segAddr <span class="k">[</span><span class="nb">lindex</span> <span class="nv">$lineL</span> <span class="mi">1</span><span class="k">]</span>
                <span class="k">if</span> <span class="k">{[</span><span class="nb">llength</span> <span class="nv">$segData</span><span class="k">]</span> <span class="o">!=</span> <span class="nv">0</span><span class="k">}</span> <span class="k">{</span>
                    <span class="nb">lappend</span> resultL <span class="nv">$startAddress</span> <span class="nv">$segData</span>
                <span class="k">}</span>
                <span class="k">set</span> address <span class="nv">$segAddr</span>
                <span class="k">set</span> startAddress <span class="nv">$address</span>
                <span class="k">set</span> segData <span class="k">[</span><span class="nb">list</span><span class="k">]</span></pre></div>
................................................................................
  <div class='clearall'></div>
  <div class='section' id='section-21'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-21'>#</a>
      </div>
      <h4>Start Address line.</h4>
<p>Contains processor address from which to start execution,
if this was a processor.</p>
<p>Note: All start address types map to this.  Because it's
relevant to their output format, I16hex and I32hex include an
extra field in their output with the format type.  This is
passed along and must be dealt with in the writers.</p>
<p>N.B. that the "address" for this segment is the text
string "STARTADDR", not an actual numeric address, and the
data is a single execution address rather than a byte list.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>            <span class="k">}</span>
            <span class="nv">STARTADDR</span> <span class="k">{</span>
                <span class="nv">log</span><span class="o">::</span>debug <span class="s2">&quot;Found STARTADDR [lrange $lineL 1 end]&quot;</span>
                <span class="k">if</span> <span class="k">{[</span><span class="nb">llength</span> <span class="nv">$segData</span><span class="k">]</span> <span class="o">!=</span> <span class="nv">0</span><span class="k">}</span> <span class="k">{</span>
                    <span class="nb">lappend</span> resultL <span class="nv">$startAddress</span> <span class="nv">$segData</span>
                <span class="k">}</span>
                <span class="k">set</span> address <span class="s2">&quot;STARTADDR&quot;</span>
                <span class="k">set</span> startAddress <span class="nv">$address</span>
                <span class="k">set</span> segData <span class="k">[</span><span class="nb">lrange</span> <span class="nv">$lineL</span> <span class="mi">1</span> end<span class="k">]</span></pre></div>
    </div>
................................................................................
<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 rawbin 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.

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
      </div>
      <hr />
<h1>Procedures for Raw Binary Format</h1>
<p>This format is not really a format.  This driver is intended to be used
to input flat binary dumps, e.g. memory dumps, to be saved in another format,
or to write binary data to output channels that expect raw binary images.</p>
<hr />
<p><a name="ProcessRawbinLine"></a></p>
<h2>ProcessRawbinLine</h2>
    </div>
    <div class='code'>
      <div class="highlight"><pre></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-2'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-2'>#</a>
      </div>
      <p><em>ProcessRawbinLine</em> 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 <em>binary scan</em> to convert the whole thing to a list of byte values.</p>
<p>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.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre><span class="k">proc</span> <span class="o">::</span>binconvert::ProcessRawbinLine <span class="k">{</span><span class="nv">dataIn</span><span class="k">}</span> <span class="k">{</span>
    <span class="k">set</span> addr <span class="mi">0</span>
    <span class="nb">binary</span> scan <span class="nv">$dataIn</span> cu<span class="o">*</span> dataL
    <span class="k">return</span> <span class="k">[</span><span class="nb">list</span> DATA <span class="nv">$addr</span> <span class="nv">$dataL</span><span class="k">]</span>
<span class="k">}</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>







|
|











|






|







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
      </div>
      <hr />
<h1>Procedures for Raw Binary Format</h1>
<p>This format is not really a format.  This driver is intended to be used
to input flat binary dumps, e.g. memory dumps, to be saved in another format,
or to write binary data to output channels that expect raw binary images.</p>
<hr />
<p><a name="ProcessRawbinInput"></a></p>
<h2>ProcessRawbinInput</h2>
    </div>
    <div class='code'>
      <div class="highlight"><pre></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-2'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-2'>#</a>
      </div>
      <p><em>ProcessRawbinInput</em> 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 <em>binary scan</em> to convert the whole thing to a list of byte values.</p>
<p>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.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre><span class="k">proc</span> <span class="o">::</span>binconvert::ProcessRawbinInput <span class="k">{</span><span class="nv">dataIn</span><span class="k">}</span> <span class="k">{</span>
    <span class="k">set</span> addr <span class="mi">0</span>
    <span class="nb">binary</span> scan <span class="nv">$dataIn</span> cu<span class="o">*</span> dataL
    <span class="k">return</span> <span class="k">[</span><span class="nb">list</span> DATA <span class="nv">$addr</span> <span class="nv">$dataL</span><span class="k">]</span>
<span class="k">}</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>

Changes to docs/titxt.html.

23
24
25
26
27
28
29
30

31
32
33
34
35
36
37
..
42
43
44
45
46
47
48
49

50
51
52
53
54
55
56
..
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
...
168
169
170
171
172
173
174
175
176
177
178
179

180
181
182
183
184
185
186













187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<p>FILENAME:    titxt.tcl</p>
<p>AUTHOR:      erik.johnson@jogle.us</p>
<p>DESCRIPTION:
  titxt.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>titxt.tcl contains all the support procs for the form generated by TI's</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></pre></div>
................................................................................
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-1'>#</a>
      </div>
      <hr />
<h1>Procedures for TI Text Format</h1>
<p>For details on the TI Text format, see
<a href="http://manpages.ubuntu.com/manpages/trusty/man5/srec_ti_txt.5.html">http://manpages.ubuntu.com/manpages/trusty/man5/srec_ti_txt.5.html</a></p>

<hr />
<p><a name="ProcessTitxtLine"></a></p>
<h2>ProcessTitxtLine</h2>
    </div>
    <div class='code'>
      <div class="highlight"><pre></pre></div>
    </div>
................................................................................
      </div>
      <p>If the line starts with "@", it's an address.
Address lines are reported as segment addresses.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>    <span class="k">if</span> <span class="k">{[</span><span class="nb">string</span> range <span class="nv">$line</span> <span class="mi">0</span> <span class="mi">0</span><span class="k">]</span> <span class="nv">eq</span> <span class="s2">&quot;@&quot;</span><span class="k">}</span> <span class="k">{</span>
        <span class="k">set</span> <span class="o">::</span>binconvert::TitxtLineAddr <span class="mi">0</span>
        <span class="k">set</span> segAddr <span class="k">[expr</span> <span class="k">{[</span><span class="nb">format</span> <span class="s2">&quot;0x%x&quot;</span> <span class="k">[</span><span class="nb">string</span> range <span class="nv">$line</span> <span class="mi">1</span> end<span class="k">]]}]</span>
        <span class="k">return</span> <span class="k">[</span><span class="nb">list</span> SEGADDR <span class="nv">$segAddr</span><span class="k">]</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-4'>
    <div class='docs'>
      <div class='octowrap'>
................................................................................
      </div>
      <p>Otherwise, the line should have 1-16 two-digit hexadecimal numbers,
each representing one byte, separated by spaces.  Data lines keep a
running count of bytes processed since the last segment, to be used
as a line address.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>    <span class="k">}</span> <span class="k">else</span> <span class="k">{</span>
        <span class="nv">try</span> <span class="k">{</span>
            <span class="k">foreach</span> databyte <span class="k">[</span><span class="nb">split</span> <span class="nv">$line</span> <span class="s2">&quot; &quot;</span><span class="k">]</span> <span class="k">{</span>
                <span class="nb">lappend</span> dataL <span class="k">[expr</span> <span class="k">{[</span><span class="nb">format</span> <span class="s2">&quot;0x%x&quot;</span> <span class="nv">$databyte</span><span class="k">]</span> <span class="o">%</span> <span class="nv">256</span><span class="k">}]</span>
            <span class="k">}</span>
        <span class="k">}</span> on error <span class="k">{</span><span class="nv">result</span><span class="k">}</span> <span class="k">{</span>
            <span class="k">set</span> errMsg <span class="s2">&quot;binconvert: ValidateTitxtLine: Input file syntax error: \</span>
<span class="s2">                        could not parse line: $line&quot;</span>
            <span class="nv">log</span><span class="o">::</span>error <span class="nv">$errMsg</span>
            <span class="nb">puts</span> <span class="nv">$result</span>
            <span class="nb">puts</span> <span class="nv">$::errorCode</span>
            <span class="nb">puts</span> <span class="nv">$::errorInfo</span>
            <span class="k">error</span> <span class="nv">$errMsg</span>
        <span class="k">}</span>
        <span class="k">if</span> <span class="k">{[</span><span class="nb">llength</span> <span class="nv">$dataL</span><span class="k">]</span> <span class="o">&gt;</span> <span class="nv">16</span><span class="k">}</span> <span class="k">{</span>
            <span class="k">set</span> errMsg <span class="s2">&quot;binconvert: ValidateTitxtLine: Input file syntax error: \</span>
<span class="s2">                        data line too long (&gt;16 bytes): $line&quot;</span>
            <span class="nv">log</span><span class="o">::</span>error <span class="nv">$errMsg</span>
            <span class="k">error</span> <span class="nv">$errMsg</span>
        <span class="k">}</span>
        <span class="k">set</span> addr <span class="nv">$::binconvert::TitxtLineAddr</span>
        <span class="nb">incr</span> <span class="o">::</span>binconvert::TitxtLineAddr <span class="k">[</span><span class="nb">llength</span> <span class="nv">$dataL</span><span class="k">]</span>
        <span class="k">return</span> <span class="k">[</span><span class="nb">list</span> <span class="nv">$addr</span> <span class="nv">$dataL</span><span class="k">]</span>
    <span class="k">}</span>
<span class="k">}</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-6'>
    <div class='docs'>
      <div class='octowrap'>
................................................................................
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-8'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-8'>#</a>
      </div>
      <p>For each segment, write the address as an address line
(e.g., @5C00).</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>        <span class="nb">puts</span> <span class="nv">$outchan</span> <span class="k">[</span><span class="nb">format</span> <span class="s2">&quot;\@%x&quot;</span> <span class="nv">$addr</span><span class="k">]</span></pre></div>

    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-9'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-9'>#</a>













      </div>
      <p>The address is followed by the data in lines of 16 bytes,
with any short line at the end.  Each byte is represented by
two hex digits, separated by a space.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>        <span class="k">set</span> outS <span class="s2">&quot;&quot;</span>
        <span class="k">foreach</span> databyte <span class="nv">$dataL</span> <span class="k">{</span>
            <span class="nb">append</span> outS <span class="k">[</span><span class="nb">format</span> <span class="s2">&quot;%02x &quot;</span> <span class="nv">$databyte</span><span class="k">]</span>
            <span class="k">if</span> <span class="k">{[</span><span class="nb">string</span> length <span class="nv">$outS</span><span class="k">]</span> <span class="o">&gt;</span> <span class="nv">45</span><span class="k">}</span> <span class="k">{</span>
                <span class="nb">puts</span> <span class="nv">$outchan</span> <span class="k">[</span><span class="nb">string</span> trimright <span class="nv">$outS</span><span class="k">]</span>
                <span class="k">set</span> outS <span class="s2">&quot;&quot;</span>
            <span class="k">}</span>
        <span class="k">}</span>
        <span class="k">if</span> <span class="k">{[</span><span class="nb">string</span> length <span class="nv">$outS</span><span class="k">]</span> <span class="o">&gt;</span> <span class="nv">0</span><span class="k">}</span> <span class="k">{</span>
            <span class="nb">puts</span> <span class="nv">$outchan</span> <span class="k">[</span><span class="nb">string</span> trimright <span class="nv">$outS</span><span class="k">]</span>
        <span class="k">}</span>
    <span class="k">}</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-10'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-10'>#</a>
      </div>
      <p>After all segments are written out, write the "q" line and end.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>    <span class="nb">puts</span> <span class="nv">$outchan</span> <span class="s2">&quot;q&quot;</span>
<span class="k">}</span>

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







|
>







 







|
>







 







|







 







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<







 







|
<


<
>







>
>
>
>
>
>
>
>
>
>
>
>
>








|












|


|













23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
..
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
..
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

140
141
142
143
144
145
146
...
169
170
171
172
173
174
175
176

177
178

179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<p>FILENAME:    titxt.tcl</p>
<p>AUTHOR:      erik.johnson@jogle.us</p>
<p>DESCRIPTION:
  titxt.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>titxt.tcl contains all the support procs for the format generated by TI's
  Code Composer tools and used by TI's MSP430 programmer.</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></pre></div>
................................................................................
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-1'>#</a>
      </div>
      <hr />
<h1>Procedures for TI Text Format</h1>
<p>For details on the TI Text format, see
<a href="http://manpages.ubuntu.com/manpages/trusty/man5/srec_ti_txt.5.html">http://manpages.ubuntu.com/manpages/trusty/man5/srec_ti_txt.5.html</a> or
<a href="http://www.ti.com/lit/ug/slau101q/slau101q.pdf#[{&quot;num&quot;:96,&quot;gen&quot;:0},{&quot;name&quot;:&quot;XYZ&quot;},0,718,0]">http://www.ti.com/lit/ug/slau101q/slau101q.pdf#[{"num":96,"gen":0},{"name":"XYZ"},0,718,0]</a></p>
<hr />
<p><a name="ProcessTitxtLine"></a></p>
<h2>ProcessTitxtLine</h2>
    </div>
    <div class='code'>
      <div class="highlight"><pre></pre></div>
    </div>
................................................................................
      </div>
      <p>If the line starts with "@", it's an address.
Address lines are reported as segment addresses.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>    <span class="k">if</span> <span class="k">{[</span><span class="nb">string</span> range <span class="nv">$line</span> <span class="mi">0</span> <span class="mi">0</span><span class="k">]</span> <span class="nv">eq</span> <span class="s2">&quot;@&quot;</span><span class="k">}</span> <span class="k">{</span>
        <span class="k">set</span> <span class="o">::</span>binconvert::TitxtLineAddr <span class="mi">0</span>
        <span class="k">set</span> segAddr <span class="k">[expr</span> <span class="k">{[</span><span class="nb">format</span> <span class="s2">&quot;0x%s&quot;</span> <span class="k">[</span><span class="nb">string</span> range <span class="nv">$line</span> <span class="mi">1</span> end<span class="k">]]}]</span>
        <span class="k">return</span> <span class="k">[</span><span class="nb">list</span> SEGADDR <span class="nv">$segAddr</span><span class="k">]</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-4'>
    <div class='docs'>
      <div class='octowrap'>
................................................................................
      </div>
      <p>Otherwise, the line should have 1-16 two-digit hexadecimal numbers,
each representing one byte, separated by spaces.  Data lines keep a
running count of bytes processed since the last segment, to be used
as a line address.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>    <span class="k">}</span>
    <span class="nv">try</span> <span class="k">{</span>
        <span class="k">foreach</span> databyte <span class="k">[</span><span class="nb">split</span> <span class="nv">$line</span> <span class="s2">&quot; &quot;</span><span class="k">]</span> <span class="k">{</span>
            <span class="nb">lappend</span> dataL <span class="k">[expr</span> <span class="k">{[</span><span class="nb">format</span> <span class="s2">&quot;0x%s&quot;</span> <span class="nv">$databyte</span><span class="k">]</span> <span class="o">%</span> <span class="nv">256</span><span class="k">}]</span>
        <span class="k">}</span>
    <span class="k">}</span> on error <span class="k">{</span><span class="nv">result</span><span class="k">}</span> <span class="k">{</span>
        <span class="k">set</span> errMsg <span class="s2">&quot;binconvert: ValidateTitxtLine: Input file syntax error: \</span>
<span class="s2">                    could not parse line: $line&quot;</span>
        <span class="nv">log</span><span class="o">::</span>error <span class="nv">$errMsg</span>
        <span class="nb">puts</span> <span class="nv">$result</span>
        <span class="nb">puts</span> <span class="nv">$::errorCode</span>
        <span class="nb">puts</span> <span class="nv">$::errorInfo</span>
        <span class="k">error</span> <span class="nv">$errMsg</span>
    <span class="k">}</span>
    <span class="k">if</span> <span class="k">{[</span><span class="nb">llength</span> <span class="nv">$dataL</span><span class="k">]</span> <span class="o">&gt;</span> <span class="nv">16</span><span class="k">}</span> <span class="k">{</span>
        <span class="k">set</span> errMsg <span class="s2">&quot;binconvert: ValidateTitxtLine: Input file syntax error: \</span>
<span class="s2">                    data line too long (&gt;16 bytes): $line&quot;</span>
        <span class="nv">log</span><span class="o">::</span>error <span class="nv">$errMsg</span>
        <span class="k">error</span> <span class="nv">$errMsg</span>
    <span class="k">}</span>
    <span class="k">set</span> addr <span class="nv">$::binconvert::TitxtLineAddr</span>
    <span class="nb">incr</span> <span class="o">::</span>binconvert::TitxtLineAddr <span class="k">[</span><span class="nb">llength</span> <span class="nv">$dataL</span><span class="k">]</span>
    <span class="k">return</span> <span class="k">[</span><span class="nb">list</span> DATA <span class="nv">$addr</span> <span class="nv">$dataL</span><span class="k">]</span>

<span class="k">}</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-6'>
    <div class='docs'>
      <div class='octowrap'>
................................................................................
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-8'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-8'>#</a>
      </div>
      <p>TI Text format can't express header or execution address segments.</p>

    </div>
    <div class='code'>

      <div class="highlight"><pre>        <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="o">||</span> <span class="k">(</span><span class="nv">$addr</span> <span class="nv">eq</span> <span class="s2">&quot;STARTADDR&quot;</span><span class="k">)}</span> <span class="k">{</span> <span class="k">continue</span> <span class="k">}</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-9'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-9'>#</a>
      </div>
      <p>For each data segment, write the address as an address line
(e.g., @5C00).</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>        <span class="nb">puts</span> <span class="nv">$outchan</span> <span class="k">[</span><span class="nb">format</span> <span class="s2">&quot;\@%X&quot;</span> <span class="nv">$addr</span><span class="k">]</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-10'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-10'>#</a>
      </div>
      <p>The address is followed by the data in lines of 16 bytes,
with any short line at the end.  Each byte is represented by
two hex digits, separated by a space.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>        <span class="k">set</span> outS <span class="s2">&quot;&quot;</span>
        <span class="k">foreach</span> databyte <span class="nv">$dataL</span> <span class="k">{</span>
            <span class="nb">append</span> outS <span class="k">[</span><span class="nb">format</span> <span class="s2">&quot;%02X &quot;</span> <span class="nv">$databyte</span><span class="k">]</span>
            <span class="k">if</span> <span class="k">{[</span><span class="nb">string</span> length <span class="nv">$outS</span><span class="k">]</span> <span class="o">&gt;</span> <span class="nv">45</span><span class="k">}</span> <span class="k">{</span>
                <span class="nb">puts</span> <span class="nv">$outchan</span> <span class="k">[</span><span class="nb">string</span> trimright <span class="nv">$outS</span><span class="k">]</span>
                <span class="k">set</span> outS <span class="s2">&quot;&quot;</span>
            <span class="k">}</span>
        <span class="k">}</span>
        <span class="k">if</span> <span class="k">{[</span><span class="nb">string</span> length <span class="nv">$outS</span><span class="k">]</span> <span class="o">&gt;</span> <span class="nv">0</span><span class="k">}</span> <span class="k">{</span>
            <span class="nb">puts</span> <span class="nv">$outchan</span> <span class="k">[</span><span class="nb">string</span> trimright <span class="nv">$outS</span><span class="k">]</span>
        <span class="k">}</span>
    <span class="k">}</span></pre></div>
    </div>
  </div>
  <div class='clearall'></div>
  <div class='section' id='section-11'>
    <div class='docs'>
      <div class='octowrap'>
        <a class='octothorpe' href='#section-11'>#</a>
      </div>
      <p>After all segments are written out, write the "q" line and end.</p>
    </div>
    <div class='code'>
      <div class="highlight"><pre>    <span class="nb">puts</span> <span class="nv">$outchan</span> <span class="s2">&quot;q&quot;</span>
<span class="k">}</span>

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

Changes to rawbin.tcl.

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62



63
64






65
66
67
68
69
70
71
72
73
74

75
76
77
78
79
80
81
82
83
## Procedures for Raw Binary Format
#
# This format is not really a format.  This driver is intended to be used
# to input flat binary dumps, e.g. memory dumps, to be saved in another format,
# or to write binary data to output channels that expect raw binary images.
#
#--------------------------------------------------------------------------
# <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 binary} -encoding binary
    puts $outchan $outS
}







|
|

|





|













|
>
>
>


>
>
>
>
>
>




|




|
>









32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
## Procedures for Raw Binary Format
#
# This format is not really a format.  This driver is intended to be used
# to input flat binary dumps, e.g. memory dumps, to be saved in another format,
# or to write binary data to output channels that expect raw binary images.
#
#--------------------------------------------------------------------------
# <a name="ProcessRawbinInput"></a>
### ProcessRawbinInput

# *ProcessRawbinInput* 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::ProcessRawbinInput {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.  Use that to create a list of byte
    # values covering all segments, filled with a value (nominally 0xFF).
    # The list starts at the input startAddr, and segments are expected to
    # be placed within it.
    set maxAddr 0
    foreach {addr dataL} $segmentList {
        if {$addr < $startAddr} {
            set errMsg "Invalid start address: segment starts at $addr,\
                        output file defined to start at $startAddr"
            log::error $errMsg
            error $errMsg
        }
        if {$maxAddr < ($addr + [llength $dataL])} {
            set maxAddr [expr {$addr + [llength $dataL]}]
        }
    }
    set outL [lrepeat [expr {$maxAddr - $startAddr}] $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 offset [expr {$addr - $startAddr}]
        set outL [lreplace $outL $offset [expr {$offset + [llength $dataL] - 1}] {*}$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 binary} -encoding binary
    puts $outchan $outS
}

Changes to titxt.tcl.

10
11
12
13
14
15
16
17

18
19
20
21
22
23
24
25
26
27
28
29
30
31

32
33
34
35
36
37
38
..
84
85
86
87
88
89
90



91
92
93
94
95
96
97
98
#
# DESCRIPTION:
#   titxt.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.
#
#   titxt.tcl contains all the support procs for the form generated by TI's

#
###########################################################################
#
# 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 TI Text Format
#
# For details on the TI Text format, see
# <http://manpages.ubuntu.com/manpages/trusty/man5/srec_ti_txt.5.html>

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

# *ProcessTitxtLine* is the parser for the readline proc.  Since TI-TXT is a
# very simple format, and since the line types do not have a common format,
................................................................................
# <a name="WriteTitxtFile"></a>
### WriteTitxtFile

# *WriteTitxtFile* iterates over the segments of the segment list.
#
proc ::binconvert::WriteTitxtFile {segmentList outchan} {
    foreach {addr dataL} $segmentList {



        # For each segment, write the address as an address line
        # (e.g., @5C00).
        puts $outchan [format "\@%X" $addr]

        # The address is followed by the data in lines of 16 bytes,
        # with any short line at the end.  Each byte is represented by
        # two hex digits, separated by a space.
        set outS ""







|
>













|
>







 







>
>
>
|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#
# DESCRIPTION:
#   titxt.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.
#
#   titxt.tcl contains all the support procs for the format generated by TI's
#   Code Composer tools and used by TI's MSP430 programmer.
#
###########################################################################
#
# 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 TI Text Format
#
# For details on the TI Text format, see
# <http://manpages.ubuntu.com/manpages/trusty/man5/srec_ti_txt.5.html> or
# <http://www.ti.com/lit/ug/slau101q/slau101q.pdf#[{"num":96,"gen":0},{"name":"XYZ"},0,718,0]>
#
#--------------------------------------------------------------------------
# <a name="ProcessTitxtLine"></a>
### ProcessTitxtLine

# *ProcessTitxtLine* is the parser for the readline proc.  Since TI-TXT is a
# very simple format, and since the line types do not have a common format,
................................................................................
# <a name="WriteTitxtFile"></a>
### WriteTitxtFile

# *WriteTitxtFile* iterates over the segments of the segment list.
#
proc ::binconvert::WriteTitxtFile {segmentList outchan} {
    foreach {addr dataL} $segmentList {
        # TI Text format can't express header or execution address segments.
        if {($addr eq "HEADER") || ($addr eq "STARTADDR")} { continue }

        # For each data segment, write the address as an address line
        # (e.g., @5C00).
        puts $outchan [format "\@%X" $addr]

        # The address is followed by the data in lines of 16 bytes,
        # with any short line at the end.  Each byte is represented by
        # two hex digits, separated by a space.
        set outS ""