]> git.wh0rd.org - patches.git/blame - uclinux-picocom.patch
scummvm random work
[patches.git] / uclinux-picocom.patch
CommitLineData
5e993f12 1Index: config/config-blackfin.in
2===================================================================
3--- config/config-blackfin.in (revision 5006)
4+++ config/config-blackfin.in (working copy)
5@@ -116,6 +116,7 @@ bool 'Bluez-utils' CONFIG_USER_BLUEZ
6 if [ "$CONFIG_USER_BLUEZ" = "y" ]; then
7 define_bool CONFIG_LIB_BLUEZ y
8 fi
9+bool 'picocom' CONFIG_USER_PICOCOM
10 endmenu
11
12
13
14Property changes on: user/blkfin-apps/picocom
15___________________________________________________________________
16Name: svn:ignore
17 + picocom
18
19
20Index: user/blkfin-apps/picocom/picocom.8.ps
21===================================================================
22--- user/blkfin-apps/picocom/picocom.8.ps (revision 0)
23+++ user/blkfin-apps/picocom/picocom.8.ps (revision 0)
24@@ -0,0 +1,578 @@
25+%!PS-Adobe-3.0
26+%%Creator: groff version 1.18.1
27+%%CreationDate: Fri Aug 13 14:26:12 2004
28+%%DocumentNeededResources: font Times-Roman
29+%%+ font Times-Bold
30+%%+ font Times-Italic
31+%%DocumentSuppliedResources: procset grops 1.18 1
32+%%Pages: 4
33+%%PageOrder: Ascend
34+%%Orientation: Portrait
35+%%EndComments
36+%%BeginProlog
37+%%BeginResource: procset grops 1.18 1
38+/setpacking where{
39+pop
40+currentpacking
41+true setpacking
42+}if
43+/grops 120 dict dup begin
44+/SC 32 def
45+/A/show load def
46+/B{0 SC 3 -1 roll widthshow}bind def
47+/C{0 exch ashow}bind def
48+/D{0 exch 0 SC 5 2 roll awidthshow}bind def
49+/E{0 rmoveto show}bind def
50+/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def
51+/G{0 rmoveto 0 exch ashow}bind def
52+/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
53+/I{0 exch rmoveto show}bind def
54+/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def
55+/K{0 exch rmoveto 0 exch ashow}bind def
56+/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
57+/M{rmoveto show}bind def
58+/N{rmoveto 0 SC 3 -1 roll widthshow}bind def
59+/O{rmoveto 0 exch ashow}bind def
60+/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
61+/Q{moveto show}bind def
62+/R{moveto 0 SC 3 -1 roll widthshow}bind def
63+/S{moveto 0 exch ashow}bind def
64+/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def
65+/SF{
66+findfont exch
67+[exch dup 0 exch 0 exch neg 0 0]makefont
68+dup setfont
69+[exch/setfont cvx]cvx bind def
70+}bind def
71+/MF{
72+findfont
73+[5 2 roll
74+0 3 1 roll
75+neg 0 0]makefont
76+dup setfont
77+[exch/setfont cvx]cvx bind def
78+}bind def
79+/level0 0 def
80+/RES 0 def
81+/PL 0 def
82+/LS 0 def
83+/MANUAL{
84+statusdict begin/manualfeed true store end
85+}bind def
86+/PLG{
87+gsave newpath clippath pathbbox grestore
88+exch pop add exch pop
89+}bind def
90+/BP{
91+/level0 save def
92+1 setlinecap
93+1 setlinejoin
94+72 RES div dup scale
95+LS{
96+90 rotate
97+}{
98+0 PL translate
99+}ifelse
100+1 -1 scale
101+}bind def
102+/EP{
103+level0 restore
104+showpage
105+}bind def
106+/DA{
107+newpath arcn stroke
108+}bind def
109+/SN{
110+transform
111+.25 sub exch .25 sub exch
112+round .25 add exch round .25 add exch
113+itransform
114+}bind def
115+/DL{
116+SN
117+moveto
118+SN
119+lineto stroke
120+}bind def
121+/DC{
122+newpath 0 360 arc closepath
123+}bind def
124+/TM matrix def
125+/DE{
126+TM currentmatrix pop
127+translate scale newpath 0 0 .5 0 360 arc closepath
128+TM setmatrix
129+}bind def
130+/RC/rcurveto load def
131+/RL/rlineto load def
132+/ST/stroke load def
133+/MT/moveto load def
134+/CL/closepath load def
135+/Fr{
136+setrgbcolor fill
137+}bind def
138+/Fk{
139+setcmykcolor fill
140+}bind def
141+/Fg{
142+setgray fill
143+}bind def
144+/FL/fill load def
145+/LW/setlinewidth load def
146+/Cr/setrgbcolor load def
147+/Ck/setcmykcolor load def
148+/Cg/setgray load def
149+/RE{
150+findfont
151+dup maxlength 1 index/FontName known not{1 add}if dict begin
152+{
153+1 index/FID ne{def}{pop pop}ifelse
154+}forall
155+/Encoding exch def
156+dup/FontName exch def
157+currentdict end definefont pop
158+}bind def
159+/DEFS 0 def
160+/EBEGIN{
161+moveto
162+DEFS begin
163+}bind def
164+/EEND/end load def
165+/CNT 0 def
166+/level1 0 def
167+/PBEGIN{
168+/level1 save def
169+translate
170+div 3 1 roll div exch scale
171+neg exch neg exch translate
172+0 setgray
173+0 setlinecap
174+1 setlinewidth
175+0 setlinejoin
176+10 setmiterlimit
177+[]0 setdash
178+/setstrokeadjust where{
179+pop
180+false setstrokeadjust
181+}if
182+/setoverprint where{
183+pop
184+false setoverprint
185+}if
186+newpath
187+/CNT countdictstack def
188+userdict begin
189+/showpage{}def
190+}bind def
191+/PEND{
192+clear
193+countdictstack CNT sub{end}repeat
194+level1 restore
195+}bind def
196+end def
197+/setpacking where{
198+pop
199+setpacking
200+}if
201+%%EndResource
202+%%IncludeResource: font Times-Roman
203+%%IncludeResource: font Times-Bold
204+%%IncludeResource: font Times-Italic
205+grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
206+def/PL 841.89 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron
207+/Zcaron/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef
208+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
209+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
210+/.notdef/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
211+/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen
212+/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
213+/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
214+/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex
215+/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y
216+/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft
217+/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl
218+/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
219+/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
220+/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen
221+/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft
222+/logicalnot/minus/registered/macron/degree/plusminus/twosuperior
223+/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior
224+/ordmasculine/guilsinglright/onequarter/onehalf/threequarters
225+/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE
226+/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
227+/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
228+/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn
229+/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
230+/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
231+/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash
232+/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def
233+/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE
234+/Times-Roman@0 ENC0/Times-Roman RE
235+%%EndProlog
236+%%Page: 1 1
237+%%BeginPageSetup
238+BP
239+%%EndPageSetup
240+/F0 10/Times-Roman@0 SF 373.3
241+<7069636f636f6d283829207069636f636f6d283829>72 48 R/F1 10.95
242+/Times-Bold@0 SF -.219<4e41>72 84 S<4d45>.219 E F0<7069636f636f6d20ad20
243+6d696e696d616c2064756d622d7465726d696e616c20656d756c6174696f6e2070726f67
244+72616d>108 96 Q F1<53594e4f50534953>72 112.8 Q/F2 10/Times-Bold@0 SF
245+<7069636f636f6d205b>108 124.8 Q/F3 10/Times-Italic@0 SF<6f7074696f6e73>
246+2.73 E F2<5d>2.77 E F3<6465>2.85 E<76696365>-.15 E F1
247+<4445534352495054494f4e>72 141.6 Q F0 1.423
248+<417320697473206e616d652073756767657374732c>108 153.6 R F2
249+<7069636f636f6d>3.923 E F0 1.423<69732061206d696e696d616c2064756d622d74
250+65726d696e616c20656d756c6174696f6e2070726f6772616d2e2049742069732c20696e
251+207072696e6369706c652c2076>3.923 F<657279>-.15 E .938<6d756368206c696b>
252+108 165.6 R<65>-.1 E F2<6d696e69636f6d283129>3.438 E F0 3.439<2c6f>3.439
253+G .939<6e6c7920697427>-3.439 F 3.439<7322>-.55 G .939
254+<7069636f2220696e7374656164206f6620226d696e6922212049742077>-3.439 F
255+.939<61732064657369676e656420746f2073657276>-.1 F 3.439<6561>-.15 G
256+3.439<736173>-3.439 G .939<696d706c652c206d616e75616c2c>-3.439 F .757<6d
257+6f64656d20636f6e8c6775726174696f6e2c2074657374696e672c20616e6420646562>
258+108 177.6 R .757
259+<756767696e6720746f6f6c2e2049742068617320616c736f2073657276>-.2 F .756
260+<6564202871756974652077656c6c292061732061206c6f>-.15 F .756
261+<772d7465636820227465726d696e616c2d>-.25 F<77696e646f>108 189.6 Q .865
262+<772220746f20616c6c6f>-.25 F 3.365<776f>-.25 G .865
263+<70657261746f7220696e74657276>-3.365 F .865<656e74696f6e20696e2050505020
264+636f6e6e656374696f6e20736372697074732028736f6d657468696e67206c696b>-.15
265+F 3.366<6574>-.1 G .866<6865206d732d77696e646f>-3.366 F .866
266+<777320226f70656e>-.25 F<7465726d696e616c2077696e646f>108 201.6 Q 2.5
267+<7762>-.25 G<65666f7265202f206166746572206469616c696e672220666561747572
268+65292e20497420636f756c6420616c736f2070726f>-2.5 E .3 -.15<76652075>-.15
269+H<736566756c20696e206d616e>.15 E 2.5<796f>-.15 G
270+<746865722073696d696c6172207461736b732e>-2.5 E<5768656e>108 220.8 Q F2
271+<7069636f636f6d>3.989 E F0 1.489<737461727473206974206f70656e7320746865
272+207465726d696e616c202873657269616c206465>3.989 F 1.489<7669636529206769>
273+-.25 F -.15<7665>-.25 G 3.989<6e61>.15 G 3.988<7369>-3.989 G 1.488
274+<7473206e6f6e2d6f7074696f6e206172>-3.988 F 1.488
275+<67756d656e742e20556e6c65737320746865>-.18 F F3<2d2d6e6f696e6974>108.01
276+232.8 Q F0 1.333<6f7074696f6e206973206769>4.513 F -.15<7665>-.25 G 1.333
277+<6e2c20697420636f6e8c677572657320746865206465>.15 F 1.333<7669636520746f
278+207468652073657474696e67732073706563698c656420627920746865206f7074696f6e
279+2d6172>-.25 F 1.334<67756d656e747320286f7220746f>-.18 F .487
280+<736f6d6520646566>108 244.8 R .487
281+<61756c742073657474696e6773292c20616e64207365747320697420746f20227261>
282+-.1 F .487<7722206d6f64652e204966>-.15 F F3<2d2d6e6f696e6974>2.996 E F0
283+.486<6973206769>3.666 F -.15<7665>-.25 G .486<6e2c2074686520696e69746961
284+6c697a6174696f6e20616e6420636f6e8c6775726174696f6e206973>.15 F .667
285+<736b69707065643b20746865206465>108 256.8 R .667
286+<76696365206973206a757374206f70656e65642e2046>-.25 F<6f6c6c6f>-.15 E
287+.667<77696e6720746869732c>-.25 F F2<7069636f636f6d>3.167 E F0 .667<7365
288+747320746865207374616e646172642d696e70757420616e64207374616e646172642d6f
289+757470757420746f>3.167 F<7261>108 268.8 Q 3.289<776d>-.15 G .789
290+<6f64652e204861>-3.289 F .789<76696e6720646f6e6520736f2c20697420676f6573
291+20696e2061206c6f6f70207768657265206974206c697374656e7320666f7220696e7075
292+742066726f6d20737464696e2c206f722066726f6d207468652073657269616c20706f72
293+742e>-.2 F .589<496e7075742066726f6d207468652073657269616c20706f72742069
294+7320636f7069656420746f20746865207374616e64617264206f7574707574207768696c
295+6520696e7075742066726f6d20746865207374616e6461726420696e7075742069732063
296+6f7069656420746f>108 280.8 R .105<7468652073657269616c20706f72742e>108
297+292.8 R F2<7069636f636f6d>5.105 E F0 .105<616c736f207363616e732069747320
298+696e7075742073747265616d20666f7220612075736572>2.605 F .105
299+<2d73706563698c656420636f6e74726f6c20636861726163746572>-.2 F 2.605
300+<2c63>-.4 G .105<616c6c6564207468652022657363617065>-2.605 F .554
301+<6368617261637465722220286265696e6720627920646566>108 304.8 R .555<6175
302+6c742022432d6122292e2049662074686520657363617065206368617261637465722069
303+73207365656e2c207468656e20696e7374656164206f662073656e64696e672069742074
304+6f207468652073657269616c2d>-.1 F<6465>108 316.8 Q .179<766963652c207468
305+652070726f6772616d20656e746572732022636f6d6d616e64206d6f64652220616e6420
306+77>-.25 F .179<6169747320666f7220746865206e65>-.1 F .178<78742063686172
307+6163746572202877686963682069732063616c6c656420746865202266756e6374696f6e>
308+-.15 F 1.572
309+<63686172616374657222292e20446570656e64696e67206f6e207468652076>108
310+328.8 R 1.573
311+<616c7565206f66207468652066756e6374696f6e20636861726163746572>-.25 F<2c>
312+-.4 E F2<7069636f636f6d>4.073 E F0 1.573
313+<706572666f726d73206f6e65206f6620746865206f7065726174696f6e73>4.073 F<64
314+657363726962656420696e207468652022436f6d6d616e6473222073656374696f6e2062
315+656c6f>108 340.8 Q -.65<772e>-.25 G F1<434f4d4d414e4453>72 364.8 Q F0
316+1.588<436f6d6d616e647320617265206769>108 376.8 R -.15<7665>-.25 G 4.088
317+<6e74>.15 G<6f>-4.088 E F2<7069636f636f6d>4.088 E F0 1.588
318+<6279208c727374206b>4.088 F -.15<6579>-.1 G 1.587<696e672074686520226573
319+70616365206368617261637465722220776869636820627920646566>.15 F 1.587
320+<61756c742069732022432d61222028736565>-.1 F .671
321+<224f7074696f6e73222062656c6f>108 388.8 R 3.171<776f>-.25 G 3.172<6e68>
322+-3.171 G 1.172 -.25<6f772074>-3.172 H 3.172<6f63>.25 G .672
323+<68616e6765206974292c20616e64207468656e206b>-3.172 F -.15<6579>-.1 G
324+.672<696e67206f6e6520666f72207468652066756e6374696f6e2028636f6d6d616e64
325+2920636861726163746572732073686f>.15 F<776e>-.25 E<686572652e>108 400.8
326+Q F2<5b657363617065206368617261637465725d>108 417.6 Q F0 1.244<53656e64
327+20746865206573636170652063686172616374657220746f207468652073657269616c20
328+706f727420616e642072657475726e20746f20227472616e73706172656e7422206d6f64
329+652e2054686973206d65616e73207468617420696620746865>123 429.6 R .358
330+<65736361706520636861726163746572202822432d61222c20627920646566>123
331+441.6 R .359<61756c74292069732074797065642074776963652c207468652070726f
332+6772616d2073656e647320746865206573636170652063686172616374657220746f2074
333+68652073657269616c>-.1 F .054<706f72742c20616e642072656d61696e7320696e20
334+7472616e73706172656e74206d6f64652e20546869732069732061206e65>123 453.6 R
335+2.553<7762>-.25 G<656861>-2.553 E .053
336+<76696f7220696d706c656d656e74656420696e2076312e342e20507265>-.2 F .053
337+<76696f75736c79207069636f636f6d>-.25 F<7573656420746f2069676e6f72652074
338+6865206573636170652d636861726163746572207768656e2069742077>123 465.6 Q
339+<617320656e746572656420617320612066756e6374696f6e20636861726163746572>
340+-.1 E<2e>-.55 E F2<432d78>108 482.4 Q F0 .567<45786974207468652070726f67
341+72616d3a2069662074686520222d2d6e6f726573657422206f7074696f6e2077>123
342+494.4 R .567<6173206e6f74206769>-.1 F -.15<7665>-.25 G 3.067<6e74>.15 G
343+.567<68656e207468652073657269616c20706f727420697320726573657420746f2069
344+7473206f726967696e616c207365742d>-3.067 F<74696e6773206265666f72652065>
345+123 506.4 Q<786974696e673b2069662069742077>-.15 E<6173206769>-.1 E -.15
346+<7665>-.25 G 2.5<6e74>.15 G
347+<68652073657269616c20706f7274206973206e6f742072657365742e>-2.5 E F2
348+<432d71>108 523.2 Q F0<51756974207468652070726f6772616d202a776974686f75
349+742a207265736574696e67207468652073657269616c20706f72742c207265>123 535.2
350+Q -.05<6761>-.15 G
351+<72646c657373206f662074686520222d2d6e6f726573657422206f7074696f6e2e>.05
352+E F2<432d70>108 552 Q F0<50756c73652074686520445452206c696e652e204c6f>
353+123 564 Q<77657220697420666f722031207365632c20616e64207468656e2072616973
354+65206974206167>-.25 E<61696e2e>-.05 E F2<432d74>108 580.8 Q F0 -.8<546f>
355+123 592.8 S<67676c652074686520445452206c696e652e204966204454522069732075
356+702c207468656e206c6f>.8 E<7765722069742e20496620697420697320646f>-.25 E
357+<776e2c207468656e2072616973652069742e>-.25 E F2<432d5c>108 609.6 Q F0
358+.026<47656e6572617465206120627265616b2073657175656e6365206f6e2074686520
359+73657269616c206c696e652e204120627265616b2073657175656e636520697320757375
360+616c6c792067656e657261746564206279206d61726b696e672028647269>123 621.6 R
361+<76696e67>-.25 E<746f206c6f676963616c206f6e6529207468652073657269616c20
362+5478206c696e6520666f7220616e20616d6f756e74206f662074696d6520636f72657370
363+6f6e64696e6720746f207365>123 633.6 Q -.15<7665>-.25 G
364+<72616c20636861726163746572206475726174696f6e732e>.15 E F2<432d75>108
365+650.4 Q F0 .601<426175642075702e20496e6372656173652074686520626175642d72
366+6174652e20546865206c697374206f6620626175642d726174657320737465707065642d
367+7468726f756768206279207468697320636f6d6d616e642069733a203330302c20363030
368+2c>123 662.4 R<313230302c20323430302c20343830302c20393630302c2031393230
369+302c2033383430302c2035373630302c203131353230302e>123 674.4 Q F2<432d64>
370+108 691.2 Q F0 1.555<4261756420646f>123 703.2 R 1.555<776e2e204465637265
371+6173652074686520626175642d726174652e20546865206c697374206f6620626175642d
372+726174657320737465707065642d7468726f756768206279207468697320636f6d6d616e
373+6420697320746865>-.25 F
374+<73616d6520617320666f72207468652022626175642d75702220636f6d6d616e642e>
375+123 715.2 Q<31>535 768 Q 0 Cg EP
376+%%Page: 2 2
377+%%BeginPageSetup
378+BP
379+%%EndPageSetup
380+/F0 10/Times-Roman@0 SF 373.3
381+<7069636f636f6d283829207069636f636f6d283829>72 48 R/F1 10/Times-Bold@0
382+SF<432d66>108 84 Q F0<4379636c65207468726f756768208d6f>123 96 Q
383+<772d636f6e74726f6c2073657474696e6773202852>-.25 E
384+<54532f4354532c20584f4e2f584f4646>-.6 E 2.5<2c6e>-.8 G<6f6e65292e>-2.5 E
385+F1<432d79>108 112.8 Q F0
386+<4379636c65207468726f756768207061726974792073657474696e6773202865>123
387+124.8 Q -.15<7665>-.25 G<6e2c206f64642c206e6f6e65292e>.15 E F1<432d62>
388+108 141.6 Q F0<4379636c65207468726f7567682064617461626974732d6e756d6265
389+722073657474696e67732028352c20362c20372c2038292e>123 153.6 Q F1<432d76>
390+108 170.4 Q F0<53686f>123 182.4 Q 4.02<7770>-.25 G 1.52
391+<726f6772616d206f7074696f6e7320286c696b>-4.02 F 4.02<6562>-.1 G 1.521<61
392+756420726174652c206461746120626974732c20657463292e204f6e6c7920746865206f
393+7074696f6e7320746861742063616e206265206d6f64698c6564206f6e6c696e65>-4.02
394+F<287468726f75676820636f6d6d616e647329206172652073686f>123 194.4 Q<776e
395+2c206e6f742074686f736520746861742063616e206f6e6c792062652073657420617420
396+74686520636f6d6d616e642d6c696e652e>-.25 E F1<432d73>108 211.2 Q F0<5365
397+6e64202875706c6f6164292061208c6c652028736565202253656e64696e6720616e6420
398+5265636569>123 223.2 Q<76696e672046696c6573222062656c6f>-.25 E<7729>-.25
399+E F1<432d72>108 240 Q F0<5265636569>123 252 Q .3 -.15<76652028>-.25 H
400+<646f>.15 E<776e6c6f6164292061208c6c652028736565202253656e64696e6720616e
401+64205265636569>-.25 E<76696e672046696c6573222062656c6f>-.25 E<7729>-.25
402+E .054<416674657220706572666f726d696e67206f6e65206f66207468652061626f>
403+108 268.8 R .354 -.15<7665206f>-.15 H .054
404+<7065726174696f6e73207468652070726f6772616d206c6561>.15 F -.15<7665>-.2
405+G 2.554<7374>.15 G .054<686520636f6d6d616e64206d6f646520616e6420656e7465
406+7273207472616e73706172656e74>-2.554 F<6d6f64652e204578616d706c653a2054>
407+108 280.8 Q 2.5<6f69>-.8 G
408+<6e6372656173652074686520626175642d72617465206279207477>-2.5 E 2.5<6f73>
409+-.1 G<746570732c20796f75206861>-2.5 E .3 -.15<76652074>-.2 H 2.5<6f74>
410+.15 G<7970653a>-2.5 E<432d612c20432d752c20432d612c20432d75>108 300 Q<61
411+7373756d696e67206f662d636f7572736520746861742022432d61222069732074686520
412+65736361706520636861726163746572>108 319.2 Q<2e>-.55 E/F2 10.95
413+/Times-Bold@0 SF<53454e44494e4720414e4420524543454956494e472046494c4553>
414+72 343.2 Q F1<7069636f636f6d>108 355.2 Q F0 .427
415+<63616e2073656e6420616e64207265636569>2.926 F .727 -.15<7665208c>-.25 H
416+.427<6c6573206f>.15 F -.15<7665>-.15 G 2.927<7274>.15 G .427
417+<68652073657269616c20706f7274207573696e672065>-2.927 F .427<787465726e61
418+6c2070726f6772616d73207468617420696d706c656d656e742074686520726573706563
419+2d>-.15 F<7469>108 367.2 Q .3 -.15<76652070>-.25 H<726f746f636f6c732e20
420+496e204c696e7578207479706963616c2070726f6772616d7320666f7220746869732070
421+7572706f7365206172653a>.15 E<8a>108 384 Q F1<7278283129>5 E F0 2.5<2d72>
422+2.5 G<65636569>-2.5 E .3 -.15<76652075>-.25 H
423+<73696e672074686520582d4d4f44454d2070726f746f636f6c>.15 E<8a>108 400.8 Q
424+F1<7262283129>5 E F0 2.5<2d72>2.5 G<65636569>-2.5 E .3 -.15<76652075>
425+-.25 H<73696e67207468652059>.15 E<2d4d4f44454d2070726f746f636f6c>-1.11 E
426+<8a>108 417.6 Q F1<727a283129>5 E F0 2.5<2d72>2.5 G<65636569>-2.5 E .3
427+-.15<76652075>-.25 H<73696e6720746865205a2d4d4f44454d2070726f746f636f6c>
428+.15 E<8a>108 434.4 Q F1<7378283129>5 E F0 2.5<2d73>2.5 G
429+<656e64207573696e672074686520582d4d4f44454d2070726f746f636f6c>-2.5 E<8a>
430+108 451.2 Q F1<7362283129>5 E F0 2.5<2d73>2.5 G
431+<656e64207573696e67207468652059>-2.5 E<2d4d4f44454d2070726f746f636f6c>
432+-1.11 E<8a>108 468 Q F1<737a283129>5 E F0 2.5<2d73>2.5 G
433+<656e64207573696e6720746865205a2d4d4f44454d2070726f746f636f6c>-2.5 E<8a>
434+108 484.8 Q F1<61736369692d786672283129>5 E F0 2.5<2d72>2.5 G<65636569>
435+-2.5 E .3 -.15<7665206f>-.25 H 2.5<7274>.15 G
436+<72616e736d6974204153434949208c6c6573>-2.5 E .692<546865206e616d65206f66
437+2c20616e642074686520636f6d6d616e642d6c696e65206f7074696f6e7320746f2c2074
438+68652070726f6772616d20746f206265207573656420666f72207472616e736d69747469
439+6e67208c6c657320617265206769>108 501.6 R -.15<7665>-.25 G 3.191<6e62>.15
440+G<79>-3.191 E 2.843<74686520222d2d73656e642d636d6422206f7074696f6e2e2053
441+696d696c61726c79207468652070726f6772616d20746f207265636569>108 513.6 R
442+3.143 -.15<7665208c>-.25 H 2.843<6c65732c20616e6420697473206172>.15 F
443+2.844<67756d6574732c20617265206769>-.18 F -.15<7665>-.25 G 5.344<6e62>
444+.15 G 5.344<7974>-5.344 G<6865>-5.344 E<222d2d7265636569>108 525.6 Q
445+-.15<7665>-.25 G .118<2d636d6422206f7074696f6e2e2046>.15 F .117
446+<6f722065>-.15 F .117
447+<78616d706c652c20696e206f7264657220746f2073746172742061>-.15 F F1
448+<7069636f636f6d>2.617 E F0 .117<73657373696f6e20746861742075736573202273
449+7a2220746f207472616e736d6974208c6c65732c20616e64>2.617 F
450+<22727a2220746f207265636569>108 537.6 Q -.15<7665>-.25 G 2.5<2c79>.15 G
451+<6f75206861>-2.5 E .3 -.15<76652074>-.2 H 2.5<6f73>.15 G
452+<617920736f6d657468696e67206c696b>-2.5 E 2.5<6574>-.1 G<6869733a>-2.5 E
453+<7069636f636f6d202d2d73656e642d636d642022737a202d767622202d2d7265636569>
454+108 556.8 Q -.15<7665>-.25 G<2d636d642022727a202d767622>.15 E .309<4475
455+72696e6720746865207069636f636f6d2073657373696f6e2c20696620796f75206b>108
456+576 R .609 -.15<65792074>-.1 H .309
457+<6865202273656e6422206f7220227265636569>.15 F -.15<7665>-.25 G 2.809
458+<2263>.15 G .309<6f6d6d616e64732028652e672e206279207072657373696e672043
459+2d612c20432d732c206f7220432d>-2.809 F .431<612c20432d722920796f75207769
460+6c6c2062652070726f6d7074656420666f722061208c6c656e616d652e20417420746869
461+732070726f6d707420796f752063616e20656e746572206f6e65206f72206d6f7265208c
462+6c652d6e616d65732c20616e6420616e>108 588 R<79>-.15 E .487
463+<6164646974696f6e616c206172>108 600 R .487<67756d656e747320746f20746865
464+207472616e736d697373696f6e206f7220726563657074696f6e2070726f6772616d2e20
465+416674657220746861742c207069636f636f6d2077696c6c207374617274207468652074
466+68652065>-.18 F<78746572>-.15 E<2d>-.2 E .403<6e616c2070726f6772616d2061
467+732073706563698c65642062792074686520222d2d73656e642d636d64222c206f722022
468+2d2d7265636569>108 612 R -.15<7665>-.25 G .403
469+<2d636d6422206f7074696f6e2c20616e64207769746820616e>.15 F 2.902<798c>
470+-.15 G .402<6c656e616d657320616e6420616464692d>-2.902 F 1.195
471+<74696f6e616c206172>108 624 R 1.195
472+<67756d656e747320796f75206d6179206861>-.18 F 1.495 -.15<76652073>-.2 H
473+1.195<7570706c6965642e20546865207374616e6461726420696e70757420616e64206f
474+7574707574206f66207468652065>.15 F 1.195
475+<787465726e616c2070726f6772616d2077696c6c206265>-.15 F .851<636f6e6e6563
476+74656420746f207468652073657269616c20706f72742e20546865207374616e64617264
477+206572726f72206f66207468652065>108 636 R .851<787465726e616c2070726f6772
478+616d2077696c6c20626520636f6e6e656374656420746f20746865207465726d696e616c>
479+-.15 F 1.399<77686963682d2d2d7768696c65207468652070726f6772616d20697320
480+72756e6e696e672d2d2d77696c6c207265>108 648 R -.15<7665>-.25 G 1.399<7274
481+20746f2063616e6f6e6963616c206d6f64652e205072657373696e672027432d63272077
482+68696c65207468652065>.15 F<787465726e616c>-.15 E<70726f6772616d20697320
483+72756e6e696e672077696c6c207072656d61747572656c79207465726d696e6174652069
484+742c20616e642072657475726e20636f6e74726f6c20746f>108 660 Q F1
485+<7069636f636f6d>2.5 E F2<4f5054494f4e53>72 684 Q F1<7069636f636f6d>108
486+696 Q F0<616363657074732074686520666f6c6c6f>2.5 E
487+<77696e6720636f6d6d616e642d6c696e65206f7074696f6e73>-.25 E<32>535 768 Q
488+0 Cg EP
489+%%Page: 3 3
490+%%BeginPageSetup
491+BP
492+%%EndPageSetup
493+/F0 10/Times-Roman@0 SF 373.3
494+<7069636f636f6d283829207069636f636f6d283829>72 48 R/F1 10/Times-Bold@0
495+SF<2d2d62617564207c202d62>108 84 Q F0<44658c6e65732074686520626175642d72
496+61746520746f20736574207468652073657269616c2d706f727420287465726d696e616c
497+2920746f2e>123 96 Q F1<2d2d8d6f>108 112.8 Q 2.5<777c2d>-.1 G<66>-2.5 E
498+F0<44658c6e657320746865208d6f>123 124.8 Q<772d636f6e74726f6c206d6f646520
499+746f20736574207468652073657269616c2d706f727420746f2e204d757374206265206f
500+6e65206f663a>-.25 E 5<8ab4>123 141.6 S<782720666f7220786f6e2f786f66>-5 E
501+2.5<6628>-.25 G<736f667477>-2.5 E<61726529206d6f6465>-.1 E 5<8ab4>123
502+158.4 S<682720666f72206861726477>-5 E<617265208d6f>-.1 E 2.5<7763>-.25 G
503+<6f6e74726f6c202852>-2.5 E<54532f43545329>-.6 E 5<8ab4>123 175.2 S
504+<6e2720666f72206e6f208d6f>-5 E 2.5<7763>-.25 G<6f6e74726f6c>-2.5 E
505+<28446566>123 192 Q<61756c743a20276e2729>-.1 E F1
506+<2d2d706172697479207c202d70>108 208.8 Q F0<44658c6e65732074686520706172
507+697479206d6f646520746f20736574207468652073657269616c2d706f727420746f2e20
508+4d757374206265206f6e65206f663a>123 220.8 Q 5<8ab4>123 237.6 S
509+<6f2720666f72206f646420706172697479206d6f64652e>-5 E 5<8ab4>123 254.4 S
510+<652720666f722065>-5 E -.15<7665>-.25 G 2.5<6e70>.15 G
511+<6172697479206d6f64652e>-2.5 E 5<8ab4>123 271.2 S
512+<6e2720666f72206e6f20706172697479>-5 E 2.5<2c6d>-.65 G<6f64652e>-2.5 E
513+<28446566>123 288 Q<61756c743a20276e2729>-.1 E F1
514+<2d2d6461746162697473207c202d64>108 304.8 Q F0
515+<44658c6e657320746865206e756d626572206f662064617461206269747320696e2065>
516+123 316.8 Q -.15<7665>-.25 G<727920636861726163746572>.15 E 2.5<2e4d>
517+-.55 G<757374206265206f6e65206f663a20352c20362c20372c2038>-2.5 E
518+<28446566>123 336 Q<61756c743a203829>-.1 E F1
519+<2d2d657361637065207c202d65>108 352.8 Q F0 1.151
520+<44658c6e6573207468652063686172616374657220746861742077696c6c206d616b>
521+123 364.8 R 3.651<6570>-.1 G 1.151<69636f636f6d20656e74657220636f6d6d61
522+6e642d6d6f64652028736565206465736372697074696f6e2061626f>-3.651 F -.15
523+<7665>-.15 G 1.15<292e20496620277827206973>.15 F<6769>123 376.8 Q -.15
524+<7665>-.25 G<6e2c207468656e20432d782077696c6c206d616b>.15 E 2.5<6570>-.1
525+G<69636f636f6d20656e74657220636f6d6d616e64206d6f64652e>-2.5 E<28446566>
526+123 396 Q<61756c743a2027612729>-.1 E F1<2d2d6e6f696e6974207c202d69>108
527+412.8 Q F0 .846<4966206769>123 424.8 R -.15<7665>-.25 G<6e2c>.15 E F1
528+<7069636f636f6d>3.346 E F0 .847<77696c6c206e6f7420696e697469616c697a652c
529+2072657365742c206f72206f7468657277697365206d6564646c65207769746820746865
530+2073657269616c20706f72742061742073746172742d75702e2049742077696c6c>3.346
531+F 1.706
532+<6a757374206f70656e2069742e20546869732069732075736566756c2c20666f722065>
533+123 436.8 R 1.706<78616d706c652c20666f7220636f6e6e656374696e67>-.15 F F1
534+<7069636f636f6d>4.206 E F0 1.705
535+<746f20616c72656164792d636f6e6e6563746564206d6f64656d732c206f72>4.205 F
536+.864<616c726561647920636f6e8c677572656420706f72747320776974686f75742074
537+65726d696e6174696e672074686520636f6e6e656374696f6e2c206f7220616c74657269
538+6e67207468652073657474696e67732e2049662072657175697265642073657269616c>
539+123 448.8 R<706f727420706172616d65746572732063616e207468656e206265206164
540+6a75737465642061742072756e2d74696d6520627920636f6d6d616e64732e>123 460.8
541+Q F1<2d2d6e6f72>108 477.6 Q<65736574207c202d72>-.18 E F0 .18<4966206769>
542+123 489.6 R -.15<7665>-.25 G<6e2c>.15 E F1<7069636f636f6d>2.68 E F0 .18<
543+77696c6c206e6f74202a72657365742a207468652073657269616c20706f727420776865
544+6e2065>2.68 F .18<786974696e672e2049742077696c6c206a75737420636c6f736520
545+746865208c6c6564657320616e6420646f206e6f74682d>-.15 F .798
546+<696e67206d6f72652e20546869732069732075736566756c2c20666f722065>123
547+501.6 R .798<78616d706c652c20666f72206c6561>-.15 F .798
548+<76696e67206d6f64656d7320636f6e6e6563746564207768656e2065>-.2 F
549+<786974696e67>-.15 E F1 .798<7069636f636f6d207069636f636f6d>3.298 F F0
550+.42<7573696e67207468652022517569742220636f6d6d616e642028696e737465616420
551+6f6620224578697422292c207768696368206e65>123 513.6 R -.15<7665>-.25 G
552+2.92<7272>.15 G .42<6573657473207468652073657269616c20706f72742e20496620
553+222d2d6e6f726573657422206973206769>-2.92 F -.15<7665>-.25 G<6e>.15 E
554+<7468656e2022517569742220616e64202245786974222062656861>123 525.6 Q .3
555+-.15<76652065>-.2 H<7373656e7469616c6c79207468652073616d652e>.15 E F1
556+<2d2d6e6f6c6f636b207c202d6c>108 542.4 Q F0 2.07<4966206769>123 554.4 R
557+-.15<7665>-.25 G<6e2c>.15 E F1<7069636f636f6d>4.57 E F0 2.07<77696c6c20
558+2a6e6f742a20617474656d707420746f206c6f636b207468652073657269616c20706f72
559+74206265666f7265206f70656e696e672069742e204e6f726d616c6c79207069636f636f
560+6d>4.57 F .456<617474656d70747320746f20676574206120555543502d7374796c65
561+206c6f636b2d8c6c652028652e672e20222f76>123 566.4 R .456<61722f6c6f636b2f
562+4c434b2e2e74747953302229206265666f7265206f70656e696e672074686520706f7274
563+2e2046>-.25 F .456<61696c696e6720746f>-.15 F .913
564+<646f20736f2c20726573756c747320696e207468652070726f6772616d2065>123
565+578.4 R .914
566+<786974696e6720616674657220656d697474696e6720616e206572726f72>-.15 F
567+.914<2d6d6573736167652e20497420697320706f737369626c65207468617420796f75
568+72207069636f636f6d>-.2 F<62696e61727920697320636f6d70696c65642077697468
569+6f75742074686973206f7074696f6e2e>123 590.4 Q F1
570+<2d2d73656e642d636d64207c202d73>108 607.2 Q F0
571+<53706563698c6573207468652065>123 619.2 Q
572+<787465726e616c2070726f6772616d2028616e6420616e>-.15 E 2.5<7961>-.15 G
573+-.18<7267>-2.5 G<756d656e747320746f2069742920746861742077696c6c20626520
574+7573656420666f72207472616e736d697474696e67208c6c65732e>.18 E<446566>123
575+638.4 Q<61756c743a2022737a202d767622>-.1 E F1<2d2d72>108 655.2 Q
576+<65636569>-.18 E -.1<7665>-.1 G<2d636d64207c202d76>.1 E F0
577+<53706563698c6573207468652065>123 667.2 Q
578+<787465726e616c2070726f6772616d2028616e6420616e>-.15 E 2.5<7961>-.15 G
579+-.18<7267>-2.5 G<756d656e747320746f2069742920746861742077696c6c20626520
580+7573656420666f72207265636569>.18 E<76696e67208c6c65732e>-.25 E<28446566>
581+123 686.4 Q<61756c743a2022727a202d76762229>-.1 E F1
582+<2d2d68656c70207c202d68>108 703.2 Q F0<5072696e7420612073686f7274206865
583+6c70206d6573736167652064657363726962696e672074686520636f6d6d616e642d6c69
584+6e65206f7074696f6e732e>123 715.2 Q<33>535 768 Q 0 Cg EP
585+%%Page: 4 4
586+%%BeginPageSetup
587+BP
588+%%EndPageSetup
589+/F0 10/Times-Roman@0 SF 373.3
590+<7069636f636f6d283829207069636f636f6d283829>72 48 R/F1 10.95
591+/Times-Bold@0 SF -.548<4155>72 84 S<54484f52>.548 E F0
592+<7069636f636f6d2077>108 96 Q<6173207772697474656e206279204e69636b2050>
593+-.1 E<617461>-.15 E -.25<7661>-.2 G<6c697320286e706174406566>.25 E
594+<61756c742e6e657429>-.1 E F1 -1.04 -1.588<41562041>72 120 T
595+<494c4142494c495459>1.588 E F0<546865206c61746573742076>108 132 Q
596+<657273696f6e206f6620227069636f636f6d222063616e20626520646f>-.15 E
597+<776e6c6f616465642066726f6d3a>-.25 E/F2 10/Times-Bold@0 SF<687474703a2f
598+2f656661756c742e6e65742f6e7061742f6861636b732f7069636f636f6d2f>2.5 E F0
599+<34>535 768 Q 0 Cg EP
600+%%Trailer
601+end
602+%%EOF
603Index: user/blkfin-apps/picocom/term.c
604===================================================================
605--- user/blkfin-apps/picocom/term.c (revision 0)
606+++ user/blkfin-apps/picocom/term.c (revision 0)
607@@ -0,0 +1,1193 @@
608+/* vi: set sw=4 ts=4:
609+ *
610+ * term.c
611+ *
612+ * General purpose terminal handling library.
613+ *
614+ * Nick Patavalis (npat@inaccessnetworks.com)
615+ *
616+ * originaly by Pantelis Antoniou (panto@intranet.gr), Nick Patavalis
617+ *
618+ * Documentation can be found in the header file "term.h".
619+ *
620+ * This program is free software; you can redistribute it and/or
621+ * modify it under the terms of the GNU General Public License as
622+ * published by the Free Software Foundation; either version 2 of the
623+ * License, or (at your option) any later version.
624+ *
625+ * This program is distributed in the hope that it will be useful, but
626+ * WITHOUT ANY WARRANTY; without even the implied warranty of
627+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
628+ * General Public License for more details.
629+ *
630+ * You should have received a copy of the GNU General Public License
631+ * along with this program; if not, write to the Free Software
632+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
633+ * USA
634+ *
635+ * $Id$
636+ */
637+
638+#include <stdlib.h>
639+#include <stdio.h>
640+#include <string.h>
641+#include <errno.h>
642+#include <unistd.h>
643+#ifdef __linux__
644+#include <termio.h>
645+#else
646+#include <termios.h>
647+#endif /* of __linux__ */
648+
649+#include "term.h"
650+
651+/***************************************************************************/
652+
653+static struct term_s {
654+ int init;
655+ int fd[MAX_TERMS];
656+ struct termios origtermios[MAX_TERMS];
657+ struct termios currtermios[MAX_TERMS];
658+ struct termios nexttermios[MAX_TERMS];
659+} term;
660+
661+/***************************************************************************/
662+
663+int term_errno;
664+
665+static const char * const term_err_str[] = {
666+ [TERM_EOK] = "No error",
667+ [TERM_ENOINIT] = "Framework is uninitialized",
668+ [TERM_EFULL] = "Framework is full",
669+ [TERM_ENOTFOUND] = "Filedes not in the framework",
670+ [TERM_EEXISTS] = "Filedes already in the framework",
671+ [TERM_EATEXIT] = "Cannot install atexit handler",
672+ [TERM_EISATTY] = "Filedes is not a tty",
673+ [TERM_EFLUSH] = "Cannot flush the device",
674+ [TERM_EGETATTR] = "Cannot get the device attributes",
675+ [TERM_ESETATTR] = "Cannot set the device attributes",
676+ [TERM_EBAUD] = "Invalid baud rate",
677+ [TERM_ESETOSPEED] = "Cannot set the output speed",
678+ [TERM_ESETISPEED] = "Cannot set the input speed",
679+ [TERM_EPARITY] = "Invalid parity mode",
680+ [TERM_EDATABITS] = "Invalid number of databits",
681+ [TERM_EFLOW] = "Invalid flowcontrol mode",
682+ [TERM_EDTRDOWN] = "Cannot lower DTR",
683+ [TERM_EDTRUP] = "Cannot raise DTR",
684+ [TERM_EDRAIN] = "Cannot drain the device",
685+ [TERM_EBREAK] = "Cannot send break sequence"
686+};
687+
688+static char term_err_buff[1024];
689+
690+const char *
691+term_strerror (int terrnum, int errnum)
692+{
693+ const char *rval;
694+
695+ switch(terrnum) {
696+ case TERM_EFLUSH:
697+ case TERM_EGETATTR:
698+ case TERM_ESETATTR:
699+ case TERM_ESETOSPEED:
700+ case TERM_ESETISPEED:
701+ case TERM_EDRAIN:
702+ case TERM_EBREAK:
703+ snprintf(term_err_buff, sizeof(term_err_buff),
704+ "%s: %s", term_err_str[terrnum], strerror(errnum));
705+ rval = term_err_buff;
706+ break;
707+ case TERM_EOK:
708+ case TERM_ENOINIT:
709+ case TERM_EFULL:
710+ case TERM_ENOTFOUND:
711+ case TERM_EEXISTS:
712+ case TERM_EATEXIT:
713+ case TERM_EISATTY:
714+ case TERM_EBAUD:
715+ case TERM_EPARITY:
716+ case TERM_EDATABITS:
717+ case TERM_EFLOW:
718+ case TERM_EDTRDOWN:
719+ case TERM_EDTRUP:
720+ snprintf(term_err_buff, sizeof(term_err_buff),
721+ "%s", term_err_str[terrnum]);
722+ rval = term_err_buff;
723+ break;
724+ default:
725+ rval = NULL;
726+ break;
727+ }
728+
729+ return rval;
730+}
731+
732+int
733+term_perror (const char *prefix)
734+{
735+ return fprintf(stderr, "%s %s\n",
736+ prefix, term_strerror(term_errno, errno));
737+}
738+
739+/***************************************************************************/
740+
741+static int
742+term_find_next_free (void)
743+{
744+ int rval, i;
745+
746+ do { /* dummy */
747+ if ( ! term.init ) {
748+ term_errno = TERM_ENOINIT;
749+ rval = -1;
750+ break;
751+ }
752+
753+ for (i = 0; i < MAX_TERMS; i++)
754+ if ( term.fd[i] == -1 ) break;
755+
756+ if ( i == MAX_TERMS ) {
757+ term_errno = TERM_EFULL;
758+ rval = -1;
759+ break;
760+ }
761+
762+ rval = i;
763+ } while (0);
764+
765+ return rval;
766+}
767+
768+/***************************************************************************/
769+
770+static int
771+term_find (int fd)
772+{
773+ int rval, i;
774+
775+ do { /* dummy */
776+ if ( ! term.init ) {
777+ term_errno = TERM_ENOINIT;
778+ rval = -1;
779+ break;
780+ }
781+
782+ for (i = 0; i < MAX_TERMS; i++)
783+ if (term.fd[i] == fd) break;
784+
785+ if ( i == MAX_TERMS ) {
786+ term_errno = TERM_ENOTFOUND;
787+ rval = -1;
788+ break;
789+ }
790+
791+ rval = i;
792+ } while (0);
793+
794+ return rval;
795+}
796+
797+/***************************************************************************/
798+
799+static void
800+term_exitfunc (void)
801+{
802+ int r, i;
803+
804+ do { /* dummy */
805+ if ( ! term.init )
806+ break;
807+
808+ for (i = 0; i < MAX_TERMS; i++) {
809+ if (term.fd[i] == -1)
810+ continue;
811+ do { /* dummy */
812+ r = tcflush(term.fd[i], TCIOFLUSH);
813+ if ( r < 0 ) break;
814+ r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]);
815+ if ( r < 0 ) break;
816+ } while (0);
817+ if ( r < 0 ) {
818+ char *tname;
819+
820+ tname = ttyname(term.fd[i]);
821+ if ( ! tname ) tname = "UNKNOWN";
822+ fprintf(stderr, "%s: reset failed for dev %s: %s\n",
823+ __FUNCTION__, tname, strerror(errno));
824+ }
825+ term.fd[i] = -1;
826+ }
827+ } while (0);
828+}
829+
830+/***************************************************************************/
831+
832+int
833+term_lib_init (void)
834+{
835+ int rval, r, i;
836+
837+ rval = 0;
838+
839+ do { /* dummy */
840+ if ( term.init ) {
841+ /* reset all terms back to their original settings */
842+ for (i = 0; i < MAX_TERMS; i++) {
843+ if (term.fd[i] == -1)
844+ continue;
845+ do {
846+ r = tcflush(term.fd[i], TCIOFLUSH);
847+ if ( r < 0 ) break;
848+ r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]);
849+ if ( r < 0 ) break;
850+ } while (0);
851+ if ( r < 0 ) {
852+ char *tname;
853+
854+ tname = ttyname(term.fd[i]);
855+ if ( ! tname ) tname = "UNKNOWN";
856+ fprintf(stderr, "%s: reset failed for dev %s: %s\n",
857+ __FUNCTION__, tname, strerror(errno));
858+ }
859+ term.fd[i] = -1;
860+ }
861+ } else {
862+ /* initialize term structure. */
863+ for (i = 0; i < MAX_TERMS; i++)
864+ term.fd[i] = -1;
865+ if ( atexit(term_exitfunc) != 0 ) {
866+ term_errno = TERM_EATEXIT;
867+ rval = -1;
868+ break;
869+ }
870+ /* ok. term struct is now initialized. */
871+ term.init = 1;
872+ }
873+ } while(0);
874+
875+ return rval;
876+}
877+
878+/***************************************************************************/
879+
880+int
881+term_add (int fd)
882+{
883+ int rval, r, i;
884+
885+ rval = 0;
886+
887+ do { /* dummy */
888+ i = term_find(fd);
889+ if ( i >= 0 ) {
890+ term_errno = TERM_EEXISTS;
891+ rval = -1;
892+ break;
893+ }
894+
895+ if ( ! isatty(fd) ) {
896+ term_errno = TERM_EISATTY;
897+ rval = -1;
898+ break;
899+ }
900+
901+ i = term_find_next_free();
902+ if ( i < 0 ) {
903+ rval = -1;
904+ break;
905+ }
906+
907+ r = tcgetattr(fd, &term.origtermios[i]);
908+ if ( r < 0 ) {
909+ term_errno = TERM_EGETATTR;
910+ rval = -1;
911+ break;
912+ }
913+
914+ term.currtermios[i] = term.origtermios[i];
915+ term.nexttermios[i] = term.origtermios[i];
916+ term.fd[i] = fd;
917+ } while (0);
918+
919+ return rval;
920+}
921+
922+/***************************************************************************/
923+
924+int
925+term_remove(int fd)
926+{
927+ int rval, r, i;
928+
929+ rval = 0;
930+
931+ do { /* dummy */
932+ i = term_find(fd);
933+ if ( i < 0 ) {
934+ rval = -1;
935+ break;
936+ }
937+
938+ do { /* dummy */
939+ r = tcflush(term.fd[i], TCIOFLUSH);
940+ if ( r < 0 ) {
941+ term_errno = TERM_EFLUSH;
942+ rval = -1;
943+ break;
944+ }
945+ r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]);
946+ if ( r < 0 ) {
947+ term_errno = TERM_ESETATTR;
948+ rval = -1;
949+ break;
950+ }
951+ } while (0);
952+
953+ term.fd[i] = -1;
954+ } while (0);
955+
956+ return rval;
957+}
958+
959+/***************************************************************************/
960+
961+int
962+term_erase(int fd)
963+{
964+ int rval, i;
965+
966+ rval = 0;
967+
968+ do { /* dummy */
969+ i = term_find(fd);
970+ if ( i < 0 ) {
971+ rval = -1;
972+ break;
973+ }
974+
975+ term.fd[i] = -1;
976+ } while (0);
977+
978+ return rval;
979+}
980+
981+/***************************************************************************/
982+
983+int
984+term_replace (int oldfd, int newfd)
985+{
986+ int rval, r, i;
987+
988+ rval = 0;
989+
990+ do { /* dummy */
991+
992+ i = term_find(oldfd);
993+ if ( i < 0 ) {
994+ rval = -1;
995+ break;
996+ }
997+
998+ r = tcsetattr(newfd, TCSAFLUSH, &term.currtermios[i]);
999+ if ( r < 0 ) {
1000+ term_errno = TERM_ESETATTR;
1001+ rval = -1;
1002+ break;
1003+ }
1004+
1005+ term.fd[i] = newfd;
1006+
1007+ } while (0);
1008+
1009+ return rval;
1010+}
1011+
1012+/***************************************************************************/
1013+
1014+int
1015+term_reset (int fd)
1016+{
1017+ int rval, r, i;
1018+
1019+ rval = 0;
1020+
1021+ do { /* dummy */
1022+
1023+ i = term_find(fd);
1024+ if ( i < 0 ) {
1025+ rval = -1;
1026+ break;
1027+ }
1028+
1029+ r = tcflush(term.fd[i], TCIOFLUSH);
1030+ if ( r < 0 ) {
1031+ term_errno = TERM_EFLUSH;
1032+ rval = -1;
1033+ break;
1034+ }
1035+ r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]);
1036+ if ( r < 0 ) {
1037+ term_errno = TERM_ESETATTR;
1038+ rval = -1;
1039+ break;
1040+ }
1041+
1042+ term.currtermios[i] = term.origtermios[i];
1043+ term.nexttermios[i] = term.origtermios[i];
1044+ } while (0);
1045+
1046+ return rval;
1047+}
1048+
1049+/***************************************************************************/
1050+
1051+int
1052+term_revert (int fd)
1053+{
1054+ int rval, i;
1055+
1056+ rval = 0;
1057+
1058+ do { /* dummy */
1059+
1060+ i = term_find(fd);
1061+ if ( i < 0 ) {
1062+ rval = -1;
1063+ break;
1064+ }
1065+
1066+ term.nexttermios[i] = term.currtermios[i];
1067+
1068+ } while (0);
1069+
1070+ return rval;
1071+}
1072+
1073+/***************************************************************************/
1074+
1075+int
1076+term_refresh (int fd)
1077+{
1078+ int rval, r, i;
1079+
1080+ rval = 0;
1081+
1082+ do { /* dummy */
1083+
1084+ i = term_find(fd);
1085+ if ( i < 0 ) {
1086+ rval = -1;
1087+ break;
1088+ }
1089+
1090+ r = tcgetattr(fd, &term.currtermios[i]);
1091+ if ( r < 0 ) {
1092+ term_errno = TERM_EGETATTR;
1093+ rval = -1;
1094+ break;
1095+ }
1096+
1097+ } while (0);
1098+
1099+ return rval;
1100+}
1101+
1102+/***************************************************************************/
1103+
1104+int
1105+term_apply (int fd)
1106+{
1107+ int rval, r, i;
1108+
1109+ rval = 0;
1110+
1111+ do { /* dummy */
1112+
1113+ i = term_find(fd);
1114+ if ( i < 0 ) {
1115+ rval = -1;
1116+ break;
1117+ }
1118+
1119+ r = tcsetattr(term.fd[i], TCSAFLUSH, &term.nexttermios[i]);
1120+ if ( r < 0 ) {
1121+ term_errno = TERM_ESETATTR;
1122+ rval = -1;
1123+ break;
1124+ }
1125+
1126+ term.currtermios[i] = term.nexttermios[i];
1127+
1128+ } while (0);
1129+
1130+ return rval;
1131+}
1132+
1133+/***************************************************************************/
1134+
1135+int
1136+term_set_raw (int fd)
1137+{
1138+ int rval, i;
1139+
1140+ rval = 0;
1141+
1142+ do { /* dummy */
1143+
1144+ i = term_find(fd);
1145+ if ( i < 0 ) {
1146+ rval = -1;
1147+ break;
1148+ }
1149+
1150+ /* BSD raw mode */
1151+ cfmakeraw(&term.nexttermios[i]);
1152+ /* one byte at a time, no timer */
1153+ term.nexttermios[i].c_cc[VMIN] = 1;
1154+ term.nexttermios[i].c_cc[VTIME] = 0;
1155+
1156+ } while (0);
1157+
1158+ return rval;
1159+}
1160+
1161+/***************************************************************************/
1162+
1163+int
1164+term_set_baudrate (int fd, int baudrate)
1165+{
1166+ int rval, r, i;
1167+ speed_t spd;
1168+ struct termios tio;
1169+
1170+ rval = 0;
1171+
1172+ do { /* dummy */
1173+
1174+ i = term_find(fd);
1175+ if ( i < 0 ) {
1176+ rval = -1;
1177+ break;
1178+ }
1179+
1180+ tio = term.nexttermios[i];
1181+
1182+ switch (baudrate) {
1183+ case 0:
1184+ spd = B0;
1185+ break;
1186+ case 50:
1187+ spd = B50;
1188+ break;
1189+ case 75:
1190+ spd = B75;
1191+ break;
1192+ case 110:
1193+ spd = B110;
1194+ break;
1195+ case 134:
1196+ spd = B134;
1197+ break;
1198+ case 150:
1199+ spd = B150;
1200+ break;
1201+ case 200:
1202+ spd = B200;
1203+ break;
1204+ case 300:
1205+ spd = B300;
1206+ break;
1207+ case 600:
1208+ spd = B600;
1209+ break;
1210+ case 1200:
1211+ spd = B1200;
1212+ break;
1213+ case 1800:
1214+ spd = B1800;
1215+ break;
1216+ case 2400:
1217+ spd = B2400;
1218+ break;
1219+ case 4800:
1220+ spd = B4800;
1221+ break;
1222+ case 9600:
1223+ spd = B9600;
1224+ break;
1225+ case 19200:
1226+ spd = B19200;
1227+ break;
1228+ case 38400:
1229+ spd = B38400;
1230+ break;
1231+ case 57600:
1232+ spd = B57600;
1233+ break;
1234+ case 115200:
1235+ spd = B115200;
1236+ break;
1237+ case 230400:
1238+ spd = B230400;
1239+ break;
1240+ default:
1241+ term_errno = TERM_EBAUD;
1242+ rval = -1;
1243+ break;
1244+ }
1245+ if ( rval < 0 ) break;
1246+
1247+ r = cfsetospeed(&tio, spd);
1248+ if ( r < 0 ) {
1249+ term_errno = TERM_ESETOSPEED;
1250+ rval = -1;
1251+ break;
1252+ }
1253+
1254+ r = cfsetispeed(&tio, spd);
1255+ if ( r < 0 ) {
1256+ term_errno = TERM_ESETISPEED;
1257+ rval = -1;
1258+ break;
1259+ }
1260+
1261+ term.nexttermios[i] = tio;
1262+
1263+ } while (0);
1264+
1265+ return rval;
1266+}
1267+
1268+/***************************************************************************/
1269+
1270+int
1271+term_set_parity (int fd, enum parity_e parity)
1272+{
1273+ int rval, i;
1274+ struct termios *tiop;
1275+
1276+ rval = 0;
1277+
1278+ do { /* dummy */
1279+
1280+ i = term_find(fd);
1281+ if ( i < 0 ) {
1282+ rval = -1;
1283+ break;
1284+ }
1285+
1286+ tiop = &term.nexttermios[i];
1287+
1288+ switch (parity) {
1289+ case P_EVEN:
1290+ tiop->c_cflag = (tiop->c_cflag & ~(PARENB | PARODD)) | PARENB;
1291+ break;
1292+ case P_ODD:
1293+ tiop->c_cflag = (tiop->c_cflag & ~(PARENB | PARODD)) | PARODD;
1294+ break;
1295+ case P_NONE:
1296+ tiop->c_cflag = (tiop->c_cflag & ~(PARENB | PARODD));
1297+ break;
1298+ default:
1299+ term_errno = TERM_EPARITY;
1300+ rval = -1;
1301+ break;
1302+ }
1303+ if ( rval < 0 ) break;
1304+
1305+ } while (0);
1306+
1307+ return rval;
1308+}
1309+
1310+/***************************************************************************/
1311+
1312+int
1313+term_set_databits (int fd, int databits)
1314+{
1315+ int rval, i;
1316+ struct termios *tiop;
1317+
1318+ rval = 0;
1319+
1320+ do { /* dummy */
1321+
1322+ i = term_find(fd);
1323+ if ( i < 0 ) {
1324+ rval = -1;
1325+ break;
1326+ }
1327+
1328+ tiop = &term.nexttermios[i];
1329+
1330+ switch (databits) {
1331+ case 5:
1332+ tiop->c_cflag = (tiop->c_cflag & ~CSIZE) | CS5;
1333+ break;
1334+ case 6:
1335+ tiop->c_cflag = (tiop->c_cflag & ~CSIZE) | CS6;
1336+ break;
1337+ case 7:
1338+ tiop->c_cflag = (tiop->c_cflag & ~CSIZE) | CS7;
1339+ break;
1340+ case 8:
1341+ tiop->c_cflag = (tiop->c_cflag & ~CSIZE) | CS8;
1342+ break;
1343+ default:
1344+ term_errno = TERM_EDATABITS;
1345+ rval = -1;
1346+ break;
1347+ }
1348+ if ( rval < 0 ) break;
1349+
1350+ } while (0);
1351+
1352+ return rval;
1353+}
1354+
1355+/***************************************************************************/
1356+
1357+int
1358+term_set_flowcntrl (int fd, enum flowcntrl_e flowcntl)
1359+{
1360+ int rval, i;
1361+ struct termios *tiop;
1362+
1363+ rval = 0;
1364+
1365+ do { /* dummy */
1366+
1367+ i = term_find(fd);
1368+ if ( i < 0 ) {
1369+ rval = -1;
1370+ break;
1371+ }
1372+
1373+ tiop = &term.nexttermios[i];
1374+
1375+ switch (flowcntl) {
1376+ case FC_RTSCTS:
1377+ tiop->c_cflag |= CRTSCTS;
1378+ tiop->c_iflag &= ~(IXON | IXOFF | IXANY);
1379+ break;
1380+ case FC_XONXOFF:
1381+ tiop->c_cflag &= ~(CRTSCTS);
1382+ tiop->c_iflag |= IXON | IXOFF;
1383+ break;
1384+ case FC_NONE:
1385+ tiop->c_cflag &= ~(CRTSCTS);
1386+ tiop->c_iflag &= ~(IXON | IXOFF | IXANY);
1387+ break;
1388+ default:
1389+ term_errno = TERM_EFLOW;
1390+ rval = -1;
1391+ break;
1392+ }
1393+ if ( rval < 0 ) break;
1394+
1395+ } while (0);
1396+
1397+ return rval;
1398+}
1399+
1400+/***************************************************************************/
1401+
1402+int
1403+term_set_local(int fd, int local)
1404+{
1405+ int rval, i;
1406+ struct termios *tiop;
1407+
1408+ rval = 0;
1409+
1410+ do { /* dummy */
1411+
1412+ i = term_find(fd);
1413+ if ( i < 0 ) {
1414+ rval = -1;
1415+ break;
1416+ }
1417+
1418+ tiop = &term.nexttermios[i];
1419+
1420+ if ( local )
1421+ tiop->c_cflag |= CLOCAL;
1422+ else
1423+ tiop->c_cflag &= ~CLOCAL;
1424+
1425+ } while (0);
1426+
1427+ return rval;
1428+}
1429+
1430+/***************************************************************************/
1431+
1432+int
1433+term_set_hupcl (int fd, int on)
1434+{
1435+ int rval, i;
1436+ struct termios *tiop;
1437+
1438+ rval = 0;
1439+
1440+ do { /* dummy */
1441+
1442+ i = term_find(fd);
1443+ if ( i < 0 ) {
1444+ rval = -1;
1445+ break;
1446+ }
1447+
1448+ tiop = &term.nexttermios[i];
1449+
1450+ if ( on )
1451+ tiop->c_cflag |= HUPCL;
1452+ else
1453+ tiop->c_cflag &= ~HUPCL;
1454+
1455+ } while (0);
1456+
1457+ return rval;
1458+}
1459+
1460+/***************************************************************************/
1461+
1462+int
1463+term_set(int fd,
1464+ int raw,
1465+ int baud, enum parity_e parity, int bits, enum flowcntrl_e fc,
1466+ int local, int hup_close)
1467+{
1468+ int rval, r, i, ni;
1469+ struct termios tio;
1470+
1471+ rval = 0;
1472+
1473+ do { /* dummy */
1474+
1475+ i = term_find(fd);
1476+ if ( i < 0 ) {
1477+ ni = term_add(fd);
1478+ if ( ni < 0 ) {
1479+ rval = -1;
1480+ break;
1481+ }
1482+ } else {
1483+ ni = i;
1484+ }
1485+
1486+ tio = term.nexttermios[ni];
1487+
1488+ do { /* dummy */
1489+
1490+ if (raw) {
1491+ r = term_set_raw(fd);
1492+ if ( r < 0 ) { rval = -1; break; }
1493+ }
1494+
1495+ r = term_set_baudrate(fd, baud);
1496+ if ( r < 0 ) { rval = -1; break; }
1497+
1498+ r = term_set_parity(fd, parity);
1499+ if ( r < 0 ) { rval = -1; break; }
1500+
1501+ r = term_set_databits(fd, bits);
1502+ if ( r < 0 ) { rval = -1; break; }
1503+
1504+ r = term_set_flowcntrl(fd, fc);
1505+ if ( r < 0 ) { rval = -1; break; }
1506+
1507+ r = term_set_local(fd, local);
1508+ if ( r < 0 ) { rval = -1; break; }
1509+
1510+ r = term_set_hupcl(fd, hup_close);
1511+ if ( r < 0 ) { rval = -1; break; }
1512+
1513+ } while (0);
1514+
1515+ if ( rval < 0 ) {
1516+ if ( i < 0 )
1517+ /* new addition. must be removed */
1518+ term.fd[ni] = -1;
1519+ else
1520+ /* just revert to previous settings */
1521+ term.nexttermios[ni] = tio;
1522+ }
1523+
1524+ } while (0);
1525+
1526+ return rval;
1527+}
1528+
1529+/***************************************************************************/
1530+
1531+int
1532+term_pulse_dtr (int fd)
1533+{
1534+ int rval, r, i;
1535+
1536+ rval = 0;
1537+
1538+ do { /* dummy */
1539+
1540+ i = term_find(fd);
1541+ if ( i < 0 ) {
1542+ rval = -1;
1543+ break;
1544+ }
1545+
1546+#ifdef __linux__
1547+ {
1548+ int opins = TIOCM_DTR;
1549+
1550+ r = ioctl(fd, TIOCMBIC, &opins);
1551+ if ( r < 0 ) {
1552+ term_errno = TERM_EDTRDOWN;
1553+ rval = -1;
1554+ break;
1555+ }
1556+
1557+ sleep(1);
1558+
1559+ r = ioctl(fd, TIOCMBIS, &opins);
1560+ if ( r < 0 ) {
1561+ term_errno = TERM_EDTRUP;
1562+ rval = -1;
1563+ break;
1564+ }
1565+ }
1566+#else
1567+ {
1568+ struct termios tio, tioold;
1569+
1570+ r = tcgetattr(fd, &tio);
1571+ if ( r < 0 ) {
1572+ term_errno = TERM_ESETATTR;
1573+ rval = -1;
1574+ break;
1575+ }
1576+
1577+ tioold = tio;
1578+
1579+ cfsetospeed(&tio, B0);
1580+ cfsetispeed(&tio, B0);
1581+ r = tcsetattr(fd, TCSANOW, &tio);
1582+ if ( r < 0 ) {
1583+ term_errno = TERM_ESETATTR;
1584+ rval = -1;
1585+ break;
1586+ }
1587+
1588+ sleep(1);
1589+
1590+ r = tcsetattr(fd, TCSANOW, &tioold);
1591+ if ( r < 0 ) {
1592+ term.currtermios[i] = tio;
1593+ term_errno = TERM_ESETATTR;
1594+ rval = -1;
1595+ break;
1596+ }
1597+ }
1598+#endif /* of __linux__ */
1599+
1600+ } while (0);
1601+
1602+ return rval;
1603+}
1604+
1605+/***************************************************************************/
1606+
1607+int
1608+term_raise_dtr(int fd)
1609+{
1610+ int rval, r, i;
1611+
1612+ rval = 0;
1613+
1614+ do { /* dummy */
1615+
1616+ i = term_find(fd);
1617+ if ( i < 0 ) {
1618+ rval = -1;
1619+ break;
1620+ }
1621+
1622+#ifdef __linux__
1623+ {
1624+ int opins = TIOCM_DTR;
1625+
1626+ r = ioctl(fd, TIOCMBIS, &opins);
1627+ if ( r < 0 ) {
1628+ term_errno = TERM_EDTRUP;
1629+ rval = -1;
1630+ break;
1631+ }
1632+ }
1633+#else
1634+ r = tcsetattr(fd, TCSANOW, &term.currtermios[i]);
1635+ if ( r < 0 ) {
1636+ /* FIXME: perhaps try to update currtermios */
1637+ term_errno = TERM_ESETATTR;
1638+ rval = -1;
1639+ break;
1640+ }
1641+#endif /* of __linux__ */
1642+ } while (0);
1643+
1644+ return rval;
1645+}
1646+
1647+/***************************************************************************/
1648+\f
1649+
1650+int
1651+term_lower_dtr(int fd)
1652+{
1653+ int rval, r, i;
1654+
1655+ rval = 0;
1656+
1657+ do { /* dummy */
1658+
1659+ i = term_find(fd);
1660+ if ( i < 0 ) {
1661+ rval = -1;
1662+ break;
1663+ }
1664+
1665+#ifdef __linux__
1666+ {
1667+ int opins = TIOCM_DTR;
1668+
1669+ r = ioctl(fd, TIOCMBIC, &opins);
1670+ if ( r < 0 ) {
1671+ term_errno = TERM_EDTRDOWN;
1672+ rval = -1;
1673+ break;
1674+ }
1675+ }
1676+#else
1677+ {
1678+ struct termios tio;
1679+
1680+ r = tcgetattr(fd, &tio);
1681+ if ( r < 0 ) {
1682+ term_errno = TERM_EGETATTR;
1683+ rval = -1;
1684+ break;
1685+ }
1686+ term.currtermios[i] = tio;
1687+
1688+ cfsetospeed(&tio, B0);
1689+ cfsetispeed(&tio, B0);
1690+
1691+ r = tcsetattr(fd, TCSANOW, &tio);
1692+ if ( r < 0 ) {
1693+ term_errno = TERM_ESETATTR;
1694+ rval = -1;
1695+ break;
1696+ }
1697+ }
1698+#endif /* of __linux__ */
1699+ } while (0);
1700+
1701+ return rval;
1702+}
1703+
1704+/***************************************************************************/
1705+
1706+int
1707+term_drain(int fd)
1708+{
1709+ int rval, r;
1710+
1711+ rval = 0;
1712+
1713+ do { /* dummy */
1714+
1715+ r = term_find(fd);
1716+ if ( r < 0 ) {
1717+ rval = -1;
1718+ break;
1719+ }
1720+
1721+ do {
1722+ r = tcdrain(fd);
1723+ } while ( r < 0 && errno == EINTR);
1724+ if ( r < 0 ) {
1725+ term_errno = TERM_EDRAIN;
1726+ rval = -1;
1727+ break;
1728+ }
1729+
1730+ } while (0);
1731+
1732+ return rval;
1733+}
1734+
1735+/***************************************************************************/
1736+
1737+int
1738+term_flush(int fd)
1739+{
1740+ int rval, r;
1741+
1742+ rval = 0;
1743+
1744+ do { /* dummy */
1745+
1746+ r = term_find(fd);
1747+ if ( r < 0 ) {
1748+ rval = -1;
1749+ break;
1750+ }
1751+
1752+ r = tcflush(fd, TCIOFLUSH);
1753+ if ( r < 0 ) {
1754+ rval = -1;
1755+ break;
1756+ }
1757+
1758+ } while (0);
1759+
1760+ return rval;
1761+}
1762+
1763+/***************************************************************************/
1764+
1765+int
1766+term_break(int fd)
1767+{
1768+ int rval, r;
1769+
1770+ rval = 0;
1771+
1772+ do { /* dummy */
1773+
1774+ r = term_find(fd);
1775+ if ( r < 0 ) {
1776+ rval = -1;
1777+ break;
1778+ }
1779+
1780+ r = tcsendbreak(fd, 0);
1781+ if ( r < 0 ) {
1782+ term_errno = TERM_EBREAK;
1783+ rval = -1;
1784+ break;
1785+ }
1786+
1787+ } while (0);
1788+
1789+ return rval;
1790+}
1791+
1792+/**************************************************************************/
1793+
1794+/*
1795+ * Local Variables:
1796+ * mode:c
1797+ * tab-width: 4
1798+ * c-basic-offset: 4
1799+ * End:
1800+ */
1801Index: user/blkfin-apps/picocom/pcasc
1802===================================================================
1803--- user/blkfin-apps/picocom/pcasc (revision 0)
1804+++ user/blkfin-apps/picocom/pcasc (revision 0)
1805@@ -0,0 +1,4 @@
1806+#!/bin/sh
1807+exec picocom \
1808+ --send-cmd="ascii-xfr -sv -l5" \
1809+ --receive-cmd="ascii-xfr -rv" "$@"
1810Index: user/blkfin-apps/picocom/CONTRIBUTORS
1811===================================================================
1812--- user/blkfin-apps/picocom/CONTRIBUTORS (revision 0)
1813+++ user/blkfin-apps/picocom/CONTRIBUTORS (revision 0)
1814@@ -0,0 +1,11 @@
1815+
1816+The following people contributed suggestions, comments, and fixes:
1817+
1818+- Oliver Kurth (oku@debian.org) contributed bug fixes and the manual
1819+ page for picocm.
1820+
1821+- Julius P. Malkiewicz (julius@sonartech.com.au) contributed FreeBSD
1822+ portablity fixes, the C-\ command implementation, the UUCP locks
1823+ implementation, and other minor fixes
1824+
1825+
1826Index: user/blkfin-apps/picocom/README
1827===================================================================
1828--- user/blkfin-apps/picocom/README (revision 0)
1829+++ user/blkfin-apps/picocom/README (revision 0)
1830@@ -0,0 +1,37 @@
1831+
1832+picocom
1833+
1834+by Nick Patavalis (npat@efault.net)
1835+
1836+As its name suggests, [picocom] is a minimal dumb-terminal emulation
1837+program. It is, in principle, very much like minicom, only it's "pico"
1838+instead of "mini"! It was designed to serve as a simple, manual, modem
1839+configuration, testing, and debugging tool. It has also served (quite
1840+well) as a low-tech "terminal-window" to allow operator intervention
1841+in PPP connection scripts (something like the ms-windows "open
1842+terminal window before / after dialing" feature). It could also prove
1843+useful in many other similar tasks. It is ideal for embedded systems
1844+since its memory footprint is minimal (less than 20K, when
1845+stripped). Apart from being a handy little tool, [picocom] source
1846+distribution includes a simple, easy to use, and thoroughly documented
1847+terminal-management library, which could serve other projects as
1848+well. This library hides the termios(3) calls, and provides a less
1849+complex and safer (though certainly less feature-rich)
1850+interface. [picocom] runs on Linux, and with minor modifications it
1851+could run on any Unix system with the termios(3) library.
1852+
1853+For a description of picocom's operation, its command line options,
1854+and usage examples, see the manual page included in the source
1855+distribution as "picocom.8", and also html-ized as "picocom.8.html".
1856+
1857+People who have contibuted to picocom, by offering feature
1858+implementations, bug-fixes, corrections, and suggestions are listed in
1859+the "CONTRIBUTORS" file.
1860+
1861+The latest version of "picocom" can be downloaded from:
1862+
1863+ http://efault.net/npat/hacks/picocom/
1864+
1865+Please feel free to send comments, requests for new features (no
1866+promisses, though!), bug-fixes and rants, to the author's email
1867+address shown at the top of this file.
1868Index: user/blkfin-apps/picocom/term.h
1869===================================================================
1870--- user/blkfin-apps/picocom/term.h (revision 0)
1871+++ user/blkfin-apps/picocom/term.h (revision 0)
1872@@ -0,0 +1,543 @@
1873+/* vi: set sw=4 ts=4:
1874+ *
1875+ * term.h
1876+ *
1877+ * Simple terminal management library. Wraps termios(3), and
1878+ * simplifies the logistics required for the reliable management and
1879+ * control of terminals.
1880+ *
1881+ * Principles of operation:
1882+ *
1883+ * After the library is initialized one or more file-descriptors, can
1884+ * be added to (and latter removed from) the list managed by the
1885+ * library (framework). These file descriptos must be opened on
1886+ * terminal devices. For every fd, the original settings of the
1887+ * associated terminal device are saved by the library. These settings
1888+ * are restored when the fd is removed from the framework, or at
1889+ * porgram termination [by means of an atexit(3) handler installed by
1890+ * the library], or at user request. The library maintains three
1891+ * structures for every fd in the framework: The original settings
1892+ * structure ("origtermios"), keeping the setings of the terminal
1893+ * device when the respective filedes was added to the framework. The
1894+ * current settings structure ("currtermios"), keeping the current
1895+ * setings of the associated terminal device; and the next settings
1896+ * structure ("nexttermios") which keeps settings to be applied to the
1897+ * associated terminal device at a latter time, upon user request.
1898+ * The "term_set_*" functions can be used to modify the device
1899+ * settings stored in the nexttermios structure. Using functions
1900+ * provided by the library the user can: Apply the nexttermios
1901+ * settings to the device. Revert all changes made on nexttermios by
1902+ * copying the currtermios structure to nexttermios. Reset the device,
1903+ * by configuring it to the original settings, and copying origtermios
1904+ * to currtermios and nexttermios. Refresh the device by rereading the
1905+ * current settings from it and updating currtermios (to catch up with
1906+ * changes made to the device by means outside of this framework).
1907+ *
1908+ * Interface summary:
1909+ *
1910+ * F term_lib_init - library initialization
1911+ * F term_add - add a filedes to the framework
1912+ * F term_remove - remove a filedes from the framework
1913+ * F term_erase - remove a filedes from the framework without reset
1914+ * F term_replace - replace a fd w/o affecting the settings stuctures
1915+ * F term_reset - revert a device to the settings in "origtermios"
1916+ * F term_apply - configure a device to the settings in "nexttermios"
1917+ * F term_revert - discard "nexttermios" by copying-over "currtermios"
1918+ * F term_refresh - update "currtermios" from the device
1919+ * F term_set_raw - set "nexttermios" to raw mode
1920+ * F term_set_baudrate - set the baudrate in "nexttermios"
1921+ * F term_set_parity - set the parity mode in "nexttermios"
1922+ * F term_set_databits - set the databits in "nexttermios"
1923+ * F term_set_flowcntrl - set the flowcntl mode in "nexttermios"
1924+ * F term_set_hupcl - enable or disable hupcl in "nexttermios"
1925+ * F term_set_local - set "nexttermios" to local or non-local mode
1926+ * F term_set - set all params of "nexttermios" in a single stroke
1927+ * F term_pulse_dtr - pulse the DTR line a device
1928+ * F term_lower_dtr - lower the DTR line of a device
1929+ * F term_raise_dtr - raise the DTR line of a device
1930+ * F term_drain - drain the output from the terminal buffer
1931+ * F term_flush - discard terminal input and output queue contents
1932+ * F term_break - generate a break condition on a device
1933+ * F term_strerror - return a string describing current error condition
1934+ * F term_perror - print a string describing the current error condition
1935+ * G term_errno - current error condition of the library
1936+ * E term_errno_e - error condition codes
1937+ * E parity_t - library supported parity types
1938+ * E flocntrl_t - library supported folw-control modes
1939+ * M MAX_TERM - maximum number of fds that can be managed
1940+ *
1941+ * by Nick Patavalis (npat@inaccessnetworks.com)
1942+ *
1943+ * originaly by Pantelis Antoniou (panto@intranet.gr), Nick Patavalis
1944+ *
1945+ * This program is free software; you can redistribute it and/or
1946+ * modify it under the terms of the GNU General Public License as
1947+ * published by the Free Software Foundation; either version 2 of the
1948+ * License, or (at your option) any later version.
1949+ *
1950+ * This program is distributed in the hope that it will be useful, but
1951+ * WITHOUT ANY WARRANTY; without even the implied warranty of
1952+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1953+ * General Public License for more details.
1954+ *
1955+ * You should have received a copy of the GNU General Public License
1956+ * along with this program; if not, write to the Free Software
1957+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
1958+ * USA
1959+ *
1960+ * $Id: term.h,v 1.1 2003/05/07 18:00:05 npat Exp $
1961+ */
1962+
1963+
1964+#ifndef TERM_H
1965+#define TERM_H
1966+
1967+/* M MAX_TERMS
1968+ *
1969+ * Maximum nuber of terminals that can be managed by the library. Keep
1970+ * relatively low, since linear searches are used. Reasonable values
1971+ * would be: 16, 32, 64, etc.
1972+ */
1973+#define MAX_TERMS 16
1974+
1975+/*
1976+ * E term_errno_e
1977+ *
1978+ * Library error-condition codes. These marked with "see errno"
1979+ * correspond to system errors, so it makes sense to also check the
1980+ * system's error-condition code (errno) in order to fully determine
1981+ * what went wrong.
1982+ *
1983+ * See the error strings in "term.c" for a description of each.
1984+ */
1985+enum term_errno_e {
1986+ TERM_EOK = 0,
1987+ TERM_ENOINIT,
1988+ TERM_EFULL,
1989+ TERM_ENOTFOUND,
1990+ TERM_EEXISTS,
1991+ TERM_EATEXIT,
1992+ TERM_EISATTY,
1993+ TERM_EFLUSH, /* see errno */
1994+ TERM_EGETATTR, /* see errno */
1995+ TERM_ESETATTR, /* see errno */
1996+ TERM_EBAUD,
1997+ TERM_ESETOSPEED,
1998+ TERM_ESETISPEED,
1999+ TERM_EPARITY,
2000+ TERM_EDATABITS,
2001+ TERM_EFLOW,
2002+ TERM_EDTRDOWN,
2003+ TERM_EDTRUP,
2004+ TERM_EDRAIN, /* see errno */
2005+ TERM_EBREAK
2006+};
2007+
2008+/* E parity_e
2009+ *
2010+ * Parity modes supported by the library:
2011+ *
2012+ * P_NONE - no patiry
2013+ * P_EVEN - even parity
2014+ * P_ODD - odd parity
2015+ */
2016+enum parity_e {
2017+ P_NONE,
2018+ P_EVEN,
2019+ P_ODD
2020+};
2021+
2022+/*
2023+ * E flowcntrl_e
2024+ *
2025+ * Flow control modes, supported by the library.
2026+ *
2027+ * FC_NONE - no flow control
2028+ * FC_RTSCTS - RTS/CTS handshaking, also known as hardware
2029+ * flow-control.
2030+ * FC_XONXOFF - xon/xoff flow control.
2031+ */
2032+enum flowcntrl_e {
2033+ FC_NONE,
2034+ FC_RTSCTS,
2035+ FC_XONXOFF
2036+};
2037+
2038+/***************************************************************************/
2039+
2040+/*
2041+ * G term_errno
2042+ *
2043+ * Keeps the current library error-condtion code
2044+ */
2045+extern int term_errno;
2046+
2047+/***************************************************************************/
2048+
2049+/*
2050+ * F term_strerror
2051+ *
2052+ * Return a string descibing the current library error condition. If
2053+ * the error condition reflects a system error, then the respective
2054+ * system-error description is appended at the end of the returned
2055+ * string. The returned string points to a statically allocated buffer
2056+ * that is overwritten with every call to term_strerror()
2057+ *
2058+ * Returns a string describing the current library (and possibly
2059+ * system) error condition.
2060+ */
2061+const char *term_strerror (int terrnum, int errnum);
2062+
2063+/*
2064+ * F term_perror
2065+ *
2066+ * Emit a description of the current library (and possibly system)
2067+ * error condition to the standard-error stream. The description is
2068+ * prefixed by a user-supplied string. What is actually emmited is:
2069+ *
2070+ * <prefix><space><description>\n
2071+ *
2072+ * The description emitted is the string returned by term_strerror().
2073+ *
2074+ * Returns the number of characters emmited to the standard-error
2075+ * stream or a neagative on failure.
2076+ */
2077+int term_perror (const char *prefix);
2078+
2079+/* F term_lib_init
2080+ *
2081+ * Initialize the library
2082+ *
2083+ * Initialize the library. This function must be called before any
2084+ * attemt to use the library. If this function is called and the
2085+ * library is already initialized, all terminals associated with the
2086+ * file-descriptors in the framework will be reset to their original
2087+ * settings, and the file-descriptors will be removed from the
2088+ * framework. An atexit(3) handler is installed by the library which
2089+ * resets and removes all managed terminals.
2090+ *
2091+ * Returns negative on failure, non-negative on success. This function
2092+ * will only fail if the atexit(3) handler cannot be
2093+ * installed. Failure to reset a terminal to the original settings is
2094+ * not considered an error.
2095+ */
2096+int term_lib_init (void);
2097+
2098+/* F term_add
2099+ *
2100+ * Add the filedes "fd" to the framework. The filedes must be opened
2101+ * on a terminal device or else the addition will fail. The settings
2102+ * of the terminal device associated with the filedes are read and
2103+ * stored in the origtermios structure.
2104+ *
2105+ * Returns negative on failure, non-negative on success.
2106+ */
2107+int term_add (int fd);
2108+
2109+/* F term_remove
2110+ *
2111+ * Remove the filedes "fd" from the framework. The device associated
2112+ * with the filedes is reset to its original settings (those it had
2113+ * when it was added to the framework)
2114+ *
2115+ * Return negative on failure, non-negative on success. The filedes is
2116+ * always removed form the framework even if this function returns
2117+ * failure, indicating that the device reset failed.
2118+ */
2119+int term_remove (int fd);
2120+
2121+/* F term_erase
2122+ *
2123+ * Remove the filedes "fd" from the framework. The device associated
2124+ * with the filedes is *not* reset to its original settings.
2125+ *
2126+ * Return negative on failure, non-negative on success. The only
2127+ * reason for failure is the filedes not to be found.
2128+ */
2129+int term_erase (int fd);
2130+
2131+/* F term_replace
2132+ *
2133+ * Replace a managed filedes without affecting the associated settings
2134+ * structures. The "newfd" takes the place of "oldfd". "oldfd" is
2135+ * removed from the framework without the associated device beign
2136+ * reset (it is most-likely no longer connected to a device anyway,
2137+ * and reset would fail). The device associated with "newfd" is
2138+ * configured with "oldfd"s current settings.
2139+ *
2140+ * Returns negative on failure, non-negative on success. In case of
2141+ * failure "oldfd" is not removed from the framework, and no
2142+ * replacement takes place.
2143+ *
2144+ * The usual reason to replace the filedes of a managed terminal is
2145+ * because the device was closed and re-opened. This function gives
2146+ * you a way to do transparent "open"s and "close"s: Before you close
2147+ * a device, it has certain settings managed by the library. When you
2148+ * close it and then re-open it many of these settings are lost, since
2149+ * the device reverts to system-default settings. By calling movefd,
2150+ * you conceptually _maintain_ the old (pre-close) settings to the new
2151+ * (post-open) filedes.
2152+ */
2153+int term_replace (int oldfd, int newfd);
2154+
2155+/*
2156+ * F term_apply
2157+ *
2158+ * Applies the settings stored in the nexttermios structure associated
2159+ * with the managed filedes "fd", to the respective terminal device.
2160+ * It then copies nexttermios to currtermios.
2161+ *
2162+ * Returns negative on failure, non negative on success. In case of
2163+ * failure the currtermios structure is not affected.
2164+ */
2165+int term_apply (int fd);
2166+
2167+/*
2168+ * F term_revert
2169+ *
2170+ * Discards all the changes made to the nexttermios structure
2171+ * associated with the managed filedes "fd" that have not been applied
2172+ * to the device. It does this by copying currtermios to nexttermios.
2173+ *
2174+ * Returns negative on failure, non negative on success. Returns
2175+ * failure only to indicate invalid arguments, so the return value can
2176+ * be safely ignored.
2177+ */
2178+int term_revert (int fd);
2179+
2180+/* F term_reset
2181+ *
2182+ * Reset the terminal device associated with the managed filedes "fd"
2183+ * to its "original" settings. This function applies the settings in
2184+ * the "origtermios" structure to the actual device. It also discards
2185+ * the settings in the "currtermios" and "nexttermios" stuctures by
2186+ * making them equal to "origtermios".
2187+ *
2188+ * Returns negative on failure, non-negative of success. On failure
2189+ * the the "origtermios", "currtermios", and "nexttermios" stuctures
2190+ * associated with the filedes remain unaffected.
2191+ */
2192+int term_reset (int fd);
2193+
2194+/*
2195+ * F term_refresh
2196+ *
2197+ * Updates the contents of the currtermios structure associated with
2198+ * the managed filedes "fd", by reading the settings from the
2199+ * respective terminal device.
2200+ *
2201+ * Returns negative on failure, non negative on success. On failure
2202+ * the currtermios structure remains unaffected.
2203+ */
2204+int term_refresh (int fd);
2205+
2206+/* F term_set_raw
2207+ *
2208+ * Sets the "nexttermios" structure associated with the managed
2209+ * filedes "fd" to raw mode. The effective settings of the device are
2210+ * not affected by this function.
2211+ *
2212+ * Returns negative on failure, non-negative on success. Returns
2213+ * failure only to indicate invalid arguments, so the return value can
2214+ * be safely ignored.
2215+ *
2216+ * When in raw mode, no characters are processed by the terminal
2217+ * driver and there is no line-discipline or buffering. More
2218+ * technically setting to raw mode means, affecting the following
2219+ * terminal settings as indicated:
2220+ *
2221+ * -ignbrk -brkint -parmrk -istrip -inlcr -igncr -icrnl -ixon
2222+ * -opost -echo -echonl -icannon -isig -iexten -csize -parenb
2223+ * cs8 min=1 time=0
2224+ */
2225+int term_set_raw (int fd);
2226+
2227+/* F term_set_baudrate
2228+ *
2229+ * Sets the baudrate in the "nexttermios" structure associated with
2230+ * the managed filedes "fd" to "baudrate". The effective settings of
2231+ * the device are not affected by this function.
2232+ *
2233+ * Supported baudrates: 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
2234+ * 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400
2235+ *
2236+ * Returns negative on failure, non negative on success. Returns
2237+ * failure only to indicate invalid arguments, so the return value can
2238+ * be safely ignored.
2239+ */
2240+int term_set_baudrate (int fd, int baudrate);
2241+
2242+/* F term_set_parity
2243+ *
2244+ * Sets the parity mode in the "nexttermios" structure associated with
2245+ * the managed filedes "fd" to "parity". The effective settings of the
2246+ * device are not affected by this function.
2247+ *
2248+ * Supported parity modes are: p_even, p_odd, p_none.
2249+ *
2250+ * Returns negative on failure, non negative on success. Returns
2251+ * failure only to indicate invalid arguments, so the return value can
2252+ * be safely ignored.
2253+ */
2254+int term_set_parity (int fd, enum parity_e parity);
2255+
2256+/* F term_set_databits
2257+ *
2258+ * Sets the databits number in the "nexttermios" structure associated
2259+ * with the managed filedes "fd" to "databits". The effective settings
2260+ * of the device are not affected by this function.
2261+ *
2262+ * 5, 6, 7, and 8 databits are supported by the library.
2263+ *
2264+ * Returns negative on failure, non negative on success. Returns
2265+ * failure only to indicate invalid arguments, so the return value can
2266+ * be safely ignored.
2267+ */
2268+int term_set_databits (int fd, int databits);
2269+
2270+/* F term_set_flowcntrl
2271+ *
2272+ * Sets the folwcontrol mode in the "nexttermios" structure associated
2273+ * with the managed filedes "fd" to "flowcntl". The effective settings
2274+ * of the device are not affected by this function.
2275+ *
2276+ * The following flow control modes are supportd by the library:
2277+ * FC_NONE, FC_RTSCTS, FC_XONXOFF.
2278+ *
2279+ * Returns negative on failure, non negative on success. Returns
2280+ * failure only to indicate invalid arguments, so the return value can
2281+ * be safely ignored.
2282+ */
2283+int term_set_flowcntrl (int fd, enum flowcntrl_e flowcntl);
2284+
2285+/* F term_set_hupcl
2286+ *
2287+ * Enables ("on" = nonzero) or disables ("on" = zero) the
2288+ * "HUP-on-close" setting in the "nexttermios" structure associated
2289+ * with the managed filedes "fd". The effective settings of the device
2290+ * are not affected by this function.
2291+ *
2292+ * Returns negative on failure, non negative on success. Returns
2293+ * failure only to indicate invalid arguments, so the return value can
2294+ * be safely ignored.
2295+ */
2296+int term_set_hupcl (int fd, int on);
2297+
2298+/* F term_set_local.
2299+ *
2300+ * Enables ("local" = nonzero) or disables ("local" = zero) the
2301+ * "local-mode" setting in the "nexttermios" structure associated with
2302+ * the managed filedes "fd". The effective settings of the device are
2303+ * not affected by this function.
2304+ *
2305+ * Returns negative on failure, non negative on success. Returns
2306+ * failure only to indicate invalid arguments, so the return value can
2307+ * be safely ignored.
2308+ */
2309+int term_set_local (int fd, int local);
2310+
2311+/* F temr_set
2312+ *
2313+ * Sets most of the parameters in the "nexttermios" structure
2314+ * associated with the managed filedes "fd". Actually sets the
2315+ * following:
2316+ *
2317+ * Raw mode if "raw" is nonzero.
2318+ * Baudrate to "baud".
2319+ * Parity mode to "parity".
2320+ * Flow control mode to "fc".
2321+ * Enables local mode if "local" is nonzero, dis. otherwise.
2322+ * Enables HUP-on-close if "hupcl" is nonzero, dis. otherwise
2323+ *
2324+ * The effective settings of the device are not affected by this
2325+ * function. Additionally if the filedes "fd" is not managed, it is
2326+ * added to the framework.
2327+ *
2328+ * Returns negative on failure, non negative on success. On failure
2329+ * none of the settings of "nexttermios" is affected. *If* the filedes
2330+ * "fd" is already in the framework, then the function returns failure
2331+ * only to indicate invalid arguments, so, in this case, the return
2332+ * value can be safely ignored. If the function successfully adds the
2333+ * filedes to the framework, and following this it fails, then it will
2334+ * remove the filedes before returning.
2335+ */
2336+int term_set (int fd,
2337+ int raw,
2338+ int baud,
2339+ enum parity_e parity, int bits, enum flowcntrl_e fc,
2340+ int local, int hupcl);
2341+
2342+/* F term_pulse_dtr
2343+ *
2344+ * Pulses the DTR line of the device associated with the managed
2345+ * filedes "fd". The DTR line is lowered for 1sec and then raised
2346+ * again.
2347+ *
2348+ * Returns negative on failure, non negative on success.
2349+ */
2350+int term_pulse_dtr (int fd);
2351+
2352+/* F term_lower_dtr
2353+ *
2354+ * Lowers the DTR line of the device associated with the managed
2355+ * filedes "fd".
2356+ *
2357+ * Returns negative on failure, non negative on success.
2358+ */
2359+int term_lower_dtr (int fd);
2360+
2361+/* F term_raise_dtr
2362+ *
2363+ * Raises the DTR line of the device associated with the managed
2364+ * filedes "fd".
2365+ *
2366+ * Returns negative on failure, non negative on success.
2367+ */
2368+int term_raise_dtr (int fd);
2369+
2370+/* F term_drain
2371+ *
2372+ * Drains (flushes) the output queue of the device associated with the
2373+ * managed filedes "fd". This functions blocks until all the contents
2374+ * of output queue have been transmited.
2375+ *
2376+ * Returns negative on failure, non negative on success.
2377+ */
2378+int term_drain (int fd);
2379+
2380+/* F term_flush
2381+ *
2382+ * Discards all the contents of the input AND output queues of the
2383+ * device associated with the managed filedes "fd". Although it is
2384+ * called flush this functions does NOT FLUSHES the terminal
2385+ * queues. It just DISCARDS their contents. The name has stuck from
2386+ * the POSIX terminal call: "tcflush".
2387+ *
2388+ * Returns negative on failure, non negative on success.
2389+ */
2390+int term_flush (int fd);
2391+
2392+/* F term_break
2393+ *
2394+ * This function generates a break condition on the device associated
2395+ * with the managed filedes "fd", by transmiting a stream of
2396+ * zero-bits. The stream of zero-bits has a duriation typically
2397+ * between 0.25 and 0.5 seconds.
2398+ *
2399+ * Returns negative on failure, non negative on success.
2400+ */
2401+int term_break(int fd);
2402+
2403+/***************************************************************************/
2404+
2405+#endif /* of TERM_H */
2406+
2407+/***************************************************************************/
2408+
2409+/*
2410+ * Local Variables:
2411+ * mode:c
2412+ * tab-width: 4
2413+ * c-basic-offset: 4
2414+ * End:
2415+ */
2416Index: user/blkfin-apps/picocom/picocom.8.xml
2417===================================================================
2418--- user/blkfin-apps/picocom/picocom.8.xml (revision 0)
2419+++ user/blkfin-apps/picocom/picocom.8.xml (revision 0)
2420@@ -0,0 +1,403 @@
2421+<?xml version="1.0" standalone='no'?>
2422+<!DOCTYPE manpage SYSTEM "http://efault.net/npat/dtds/xmlmp/xmlmp-1.1.dtd">
2423+
2424+<manpage
2425+ title="picocom"
2426+ section="8"
2427+ desc="minimal dumb-terminal emulation program">
2428+
2429+ <synopsis>
2430+ <synel>
2431+ picocom [ <arg>options</arg> ] <arg>device</arg>
2432+ </synel>
2433+ </synopsis>
2434+
2435+ <description>
2436+
2437+ <p>
2438+ As its name suggests, <cmd>picocom</cmd> is a minimal
2439+ dumb-terminal emulation program. It is, in principle, very much
2440+ like <manref name="minicom" section="1"/>, only it's "pico"
2441+ instead of "mini"! It was designed to serve as a simple, manual,
2442+ modem configuration, testing, and debugging tool. It has also
2443+ served (quite well) as a low-tech "terminal-window" to allow
2444+ operator intervention in PPP connection scripts (something like
2445+ the ms-windows "open terminal window before / after dialing"
2446+ feature). It could also prove useful in many other similar
2447+ tasks.
2448+ </p>
2449+
2450+ <p>
2451+ When <cmd>picocom</cmd> starts it opens the terminal (serial
2452+ device) given as its non-option argument. Unless the
2453+ <arg>--noinit</arg> option is given, it configures the device to
2454+ the settings specified by the option-arguments (or to some
2455+ default settings), and sets it to "raw" mode. If
2456+ <arg>--noinit</arg> is given, the initialization and
2457+ configuration is skipped; the device is just opened. Following
2458+ this, <cmd>picocom</cmd> sets the standard-input and
2459+ standard-output to raw mode. Having done so, it goes in a loop
2460+ where it listens for input from stdin, or from the serial
2461+ port. Input from the serial port is copied to the standard
2462+ output while input from the standard input is copied to the
2463+ serial port. <cmd>picocom</cmd> also scans its input stream for
2464+ a user-specified control character, called the "escape
2465+ character" (being by default "C-a"). If the escape character is
2466+ seen, then instead of sending it to the serial-device, the
2467+ program enters "command mode" and waits for the next character
2468+ (which is called the "function character"). Depending on the
2469+ value of the function character, <cmd>picocom</cmd> performs one
2470+ of the operations described in the "Commands" section below.
2471+ </p>
2472+ </description>
2473+
2474+ <section name="COMMANDS">
2475+
2476+ <p>
2477+ Commands are given to <cmd>picocom</cmd> by first keying the
2478+ "espace character" which by default is "C-a" (see "Options"
2479+ below on how to change it), and then keying one for the function
2480+ (command) characters shown here.
2481+ </p>
2482+
2483+ <dl>
2484+ <dt>[escape character]</dt>
2485+ <dd>
2486+ <p>
2487+ Send the escape character to the serial port and return to
2488+ "transparent" mode. This means that if the escape character
2489+ ("C-a", by default) is typed twice, the program sends the
2490+ escape character to the serial port, and remains in
2491+ transparent mode. This is a new behavior implemented in
2492+ v1.4. Previously picocom used to ignore the escape-character
2493+ when it was entered as a function character.
2494+ </p>
2495+ </dd>
2496+
2497+ <dt>C-x</dt>
2498+ <dd>
2499+ <p>
2500+ Exit the program: if the "--noreset" option was not given
2501+ then the serial port is reset to its original settings
2502+ before exiting; if it was given the serial port is not
2503+ reset.
2504+ </p>
2505+ </dd>
2506+
2507+ <dt>C-q</dt>
2508+ <dd>
2509+ <p>
2510+ Quit the program *without* reseting the serial port,
2511+ regardless of the "--noreset" option.
2512+ </p>
2513+ </dd>
2514+
2515+ <dt>C-p</dt>
2516+ <dd>
2517+ <p>
2518+ Pulse the DTR line. Lower it for 1 sec, and then raise it
2519+ again.
2520+ </p>
2521+ </dd>
2522+
2523+ <dt>C-t</dt>
2524+ <dd>
2525+ <p>
2526+ Toggle the DTR line. If DTR is up, then lower it. If it is
2527+ down, then raise it.
2528+ </p>
2529+ </dd>
2530+
2531+ <dt>C-\e</dt>
2532+ <dd>
2533+ <p>
2534+ Generate a break sequence on the serial line. A break
2535+ sequence is usually generated by marking (driving to logical
2536+ one) the serial Tx line for an amount of time coresponding
2537+ to several character durations.
2538+ </p>
2539+ </dd>
2540+
2541+ <dt>C-u</dt>
2542+ <dd>
2543+ <p>
2544+ Baud up. Increase the baud-rate. The list of baud-rates
2545+ stepped-through by this command is: 300, 600, 1200, 2400,
2546+ 4800, 9600, 19200, 38400, 57600, 115200.
2547+ </p>
2548+ </dd>
2549+
2550+ <dt>C-d</dt>
2551+ <dd>
2552+ <p>
2553+ Baud down. Decrease the baud-rate. The list of baud-rates
2554+ stepped-through by this command is the same as for the
2555+ "baud-up" command.
2556+ </p>
2557+ </dd>
2558+
2559+ <dt>C-f</dt>
2560+ <dd>
2561+ <p>
2562+ Cycle through flow-control settings (RTS/CTS, XON/XOFF, none).
2563+ </p>
2564+ </dd>
2565+
2566+ <dt>C-y</dt>
2567+ <dd>
2568+ <p>
2569+ Cycle through parity settings (even, odd, none).
2570+ </p>
2571+ </dd>
2572+
2573+ <dt>C-b</dt>
2574+ <dd>
2575+ <p>
2576+ Cycle through databits-number settings (5, 6, 7, 8).
2577+ </p>
2578+ </dd>
2579+
2580+ <dt>C-v</dt>
2581+ <dd>
2582+ <p>
2583+ Show program options (like baud rate, data bits, etc). Only
2584+ the options that can be modified online (through commands)
2585+ are shown, not those that can only be set at the
2586+ command-line.
2587+ </p>
2588+ </dd>
2589+
2590+ <dt>C-s</dt>
2591+ <dd>
2592+ <p>
2593+ Send (upload) a file (see "Sending and Receiving Files"
2594+ below)
2595+ </p>
2596+ </dd>
2597+
2598+ <dt>C-r</dt>
2599+ <dd>
2600+ <p>
2601+ Receive (download) a file (see "Sending and Receiving Files"
2602+ below)
2603+ </p>
2604+ </dd>
2605+ </dl>
2606+
2607+ <p>
2608+ After performing one of the above operations the program leaves
2609+ the command mode and enters transparent mode. Example: To
2610+ increase the baud-rate by two steps, you have to type:
2611+ </p>
2612+ <p>
2613+ C-a, C-u, C-a, C-u
2614+ </p>
2615+ <p>
2616+ assuming of-course that "C-a" is the escape character.
2617+ </p>
2618+ </section>
2619+
2620+ <section name = "SENDING AND RECEIVING FILES">
2621+ <p>
2622+ <cmd>picocom</cmd> can send and receive files over the serial
2623+ port using external programs that implement the respective
2624+ protocols. In Linux typical programs for this purpose are:
2625+ </p>
2626+
2627+ <ul>
2628+ <li><p><manref name="rx" section="1"/>
2629+ - receive using the X-MODEM protocol</p></li>
2630+ <li><p><manref name="rb" section="1"/>
2631+ - receive using the Y-MODEM protocol</p></li>
2632+ <li><p><manref name="rz" section="1"/>
2633+ - receive using the Z-MODEM protocol</p></li>
2634+ <li><p><manref name="sx" section="1"/>
2635+ - send using the X-MODEM protocol</p></li>
2636+ <li><p><manref name="sb" section="1"/>
2637+ - send using the Y-MODEM protocol</p></li>
2638+ <li><p><manref name="sz" section="1"/>
2639+ - send using the Z-MODEM protocol</p></li>
2640+ <li><p><manref name="ascii-xfr" section="1"/>
2641+ - receive or transmit ASCII files</p></li>
2642+ </ul>
2643+
2644+ <p>
2645+ The name of, and the command-line options to, the program to be
2646+ used for transmitting files are given by the "--send-cmd"
2647+ option. Similarly the program to receive files, and its
2648+ argumets, are given by the "--receive-cmd" option. For example,
2649+ in order to start a <cmd>picocom</cmd> session that uses "sz" to
2650+ transmit files, and "rz" to receive, you have to say something
2651+ like this:
2652+ </p>
2653+
2654+ <p>
2655+ picocom --send-cmd "sz -vv" --receive-cmd "rz -vv"
2656+ </p>
2657+
2658+ <p>
2659+ During the picocom session, if you key the "send" or "receive"
2660+ commands (e.g. by pressing C-a, C-s, or C-a, C-r) you will be
2661+ prompted for a filename. At this prompt you can enter one or
2662+ more file-names, and any additional arguments to the
2663+ transmission or reception program. After that, picocom will
2664+ start the the external program as specified by the "--send-cmd",
2665+ or "--receive-cmd" option, and with any filenames and additional
2666+ arguments you may have supplied. The standard input and output
2667+ of the external program will be connected to the serial
2668+ port. The standard error of the external program will be
2669+ connected to the terminal which---while the program is
2670+ running---will revert to canonical mode. Pressing 'C-c' while
2671+ the external program is running will prematurely terminate it,
2672+ and return control to <cmd>picocom</cmd>. Pressing 'C-c' at any other
2673+ time, has no special effect; the character is normally passed to
2674+ the serial port.
2675+ </p>
2676+
2677+ </section>
2678+
2679+ <section name = "OPTIONS">
2680+ <p>
2681+ <cmd>picocom</cmd> accepts the following command-line options
2682+ </p>
2683+
2684+ <dl>
2685+ <dt>--baud | -b</dt>
2686+ <dd>
2687+ <p>
2688+ Defines the baud-rate to set the serial-port (terminal) to.
2689+ </p>
2690+ </dd>
2691+
2692+ <dt>--flow | -f</dt>
2693+ <dd>
2694+ <p>
2695+ Defines the flow-control mode to set the serial-port to. Must be
2696+ one of:
2697+ </p>
2698+ <ul>
2699+ <li><p>\'x' for xon/xoff (software) mode</p></li>
2700+ <li><p>\'h' for hardware flow control (RTS/CTS)</p></li>
2701+ <li><p>\'n' for no flow control</p></li>
2702+ </ul>
2703+ <p>(Default: 'n')</p>
2704+ </dd>
2705+
2706+ <dt>--parity | -p</dt>
2707+ <dd>
2708+ <p>
2709+ Defines the parity mode to set the serial-port to.
2710+ Must be one of:
2711+ </p>
2712+ <ul>
2713+ <li><p>\'o' for odd parity mode.</p></li>
2714+ <li><p>\'e' for even parity mode.</p></li>
2715+ <li><p>\'n' for no parity, mode.</p></li>
2716+ </ul>
2717+ <p>(Default: 'n')</p>
2718+ </dd>
2719+
2720+ <dt>--databits | -d</dt>
2721+ <dd>
2722+ <p>
2723+ Defines the number of data bits in every character. Must be one of:
2724+ 5, 6, 7, 8
2725+ </p>
2726+ <p>(Default: 8)</p>
2727+ </dd>
2728+
2729+ <dt>--esacpe | -e</dt>
2730+ <dd>
2731+ <p>
2732+ Defines the character that will make picocom enter command-mode
2733+ (see description above). If 'x' is given, then C-x will
2734+ make picocom enter command mode.
2735+ </p>
2736+ <p>
2737+ (Default: 'a')
2738+ </p>
2739+ </dd>
2740+
2741+ <dt>--noinit | -i</dt>
2742+ <dd>
2743+ <p>
2744+ If given, <cmd>picocom</cmd> will not initialize, reset, or
2745+ otherwise meddle with the serial port at start-up. It will
2746+ just open it. This is useful, for example, for connecting
2747+ <cmd>picocom</cmd> to already-connected modems, or already
2748+ configured ports without terminating the connection, or
2749+ altering the settings. If required serial port parameters
2750+ can then be adjusted at run-time by commands.
2751+ </p>
2752+ </dd>
2753+
2754+ <dt>--noreset | -r</dt>
2755+ <dd>
2756+ <p>
2757+ If given, <cmd>picocom</cmd> will not *reset* the serial
2758+ port when exiting. It will just close the filedes and do
2759+ nothing more. This is useful, for example, for leaving
2760+ modems connected when exiting <cmd>picocom</cmd>. Regardless
2761+ whether the "--noreset" option is given the user can exit
2762+ <cmd>picocom</cmd> using the "Quit" command (instead of
2763+ "Exit"), which never resets the serial port. If "--noreset"
2764+ is given then "Quit" and "Exit" behave essentially the same.
2765+ </p>
2766+ </dd>
2767+
2768+ <dt>--nolock | -l</dt>
2769+ <dd>
2770+ <p>
2771+ If given, <cmd>picocom</cmd> will *not* attempt to lock the
2772+ serial port before opening it. Normally picocom attempts to
2773+ get a UUCP-style lock-file (e.g. "/var/lock/LCK..ttyS0")
2774+ before opening the port. Failing to do so, results in the
2775+ program exiting after emitting an error-message. It is
2776+ possible that your picocom binary is compiled without this
2777+ option.
2778+ </p>
2779+ </dd>
2780+
2781+ <dt>--send-cmd | -s</dt>
2782+ <dd>
2783+ <p>
2784+ Specifies the external program (and any arguments to it)
2785+ that will be used for transmitting files.
2786+ </p>
2787+ <p>
2788+ Default: "sz -vv"
2789+ </p>
2790+ </dd>
2791+
2792+ <dt>--receive-cmd | -v</dt>
2793+ <dd>
2794+ <p>
2795+ Specifies the external program (and any arguments to it)
2796+ that will be used for receiving files.
2797+ </p>
2798+ <p>
2799+ (Default: "rz -vv")
2800+ </p>
2801+ </dd>
2802+
2803+ <dt>--help | -h</dt>
2804+ <dd>
2805+ <p>
2806+ Print a short help message describing the command-line
2807+ options.
2808+ </p>
2809+ </dd>
2810+ </dl>
2811+ </section>
2812+
2813+ <section name="AUTHOR">
2814+ <p>picocom was written by Nick Patavalis (npat@efault.net)</p>
2815+ </section>
2816+
2817+ <section name="AVAILABILITY">
2818+ <p>The latest version of "picocom" can be downloaded from: <url
2819+ href="http://efault.net/npat/hacks/picocom/"/>
2820+ </p>
2821+ </section>
2822+
2823+</manpage>
2824\ No newline at end of file
2825Index: user/blkfin-apps/picocom/picocom.8
2826===================================================================
2827--- user/blkfin-apps/picocom/picocom.8 (revision 0)
2828+++ user/blkfin-apps/picocom/picocom.8 (revision 0)
2829@@ -0,0 +1,214 @@
2830+.TH "picocom" "8" "" "" ""
2831+.SH NAME
2832+picocom \- minimal dumb-terminal emulation program
2833+.SH SYNOPSIS
2834+.B picocom [
2835+.I options
2836+.B ]
2837+.I device
2838+.br
2839+.SH DESCRIPTION
2840+As its name suggests,
2841+.B picocom
2842+is a minimal dumb-terminal emulation program. It is, in principle, very much like
2843+.B minicom(1)
2844+, only it's "pico" instead of "mini"! It was designed to serve as a simple, manual, modem configuration, testing, and debugging tool. It has also served (quite well) as a low-tech "terminal-window" to allow operator intervention in PPP connection scripts (something like the ms-windows "open terminal window before / after dialing" feature). It could also prove useful in many other similar tasks.
2845+.br
2846+.sp 0.6v
2847+When
2848+.B picocom
2849+starts it opens the terminal (serial device) given as its non-option argument. Unless the
2850+.I --noinit
2851+option is given, it configures the device to the settings specified by the option-arguments (or to some default settings), and sets it to "raw" mode. If
2852+.I --noinit
2853+is given, the initialization and configuration is skipped; the device is just opened. Following this,
2854+.B picocom
2855+sets the standard-input and standard-output to raw mode. Having done so, it goes in a loop where it listens for input from stdin, or from the serial port. Input from the serial port is copied to the standard output while input from the standard input is copied to the serial port.
2856+.B picocom
2857+also scans its input stream for a user-specified control character, called the "escape character" (being by default "C-a"). If the escape character is seen, then instead of sending it to the serial-device, the program enters "command mode" and waits for the next character (which is called the "function character"). Depending on the value of the function character,
2858+.B picocom
2859+performs one of the operations described in the "Commands" section below.
2860+.br
2861+.sp 0.6v
2862+.SH COMMANDS
2863+Commands are given to
2864+.B picocom
2865+by first keying the "espace character" which by default is "C-a" (see "Options" below on how to change it), and then keying one for the function (command) characters shown here.
2866+.TP 3
2867+.B [escape character]
2868+Send the escape character to the serial port and return to "transparent" mode. This means that if the escape character ("C-a", by default) is typed twice, the program sends the escape character to the serial port, and remains in transparent mode. This is a new behavior implemented in v1.4. Previously picocom used to ignore the escape-character when it was entered as a function character.
2869+.TP 3
2870+.B C-x
2871+Exit the program: if the "--noreset" option was not given then the serial port is reset to its original settings before exiting; if it was given the serial port is not reset.
2872+.TP 3
2873+.B C-q
2874+Quit the program *without* reseting the serial port, regardless of the "--noreset" option.
2875+.TP 3
2876+.B C-p
2877+Pulse the DTR line. Lower it for 1 sec, and then raise it again.
2878+.TP 3
2879+.B C-t
2880+Toggle the DTR line. If DTR is up, then lower it. If it is down, then raise it.
2881+.TP 3
2882+.B C-\e
2883+Generate a break sequence on the serial line. A break sequence is usually generated by marking (driving to logical one) the serial Tx line for an amount of time coresponding to several character durations.
2884+.TP 3
2885+.B C-u
2886+Baud up. Increase the baud-rate. The list of baud-rates stepped-through by this command is: 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200.
2887+.TP 3
2888+.B C-d
2889+Baud down. Decrease the baud-rate. The list of baud-rates stepped-through by this command is the same as for the "baud-up" command.
2890+.TP 3
2891+.B C-f
2892+Cycle through flow-control settings (RTS/CTS, XON/XOFF, none).
2893+.TP 3
2894+.B C-y
2895+Cycle through parity settings (even, odd, none).
2896+.TP 3
2897+.B C-b
2898+Cycle through databits-number settings (5, 6, 7, 8).
2899+.TP 3
2900+.B C-v
2901+Show program options (like baud rate, data bits, etc). Only the options that can be modified online (through commands) are shown, not those that can only be set at the command-line.
2902+.TP 3
2903+.B C-s
2904+Send (upload) a file (see "Sending and Receiving Files" below)
2905+.TP 3
2906+.B C-r
2907+Receive (download) a file (see "Sending and Receiving Files" below)
2908+.PP
2909+After performing one of the above operations the program leaves the command mode and enters transparent mode. Example: To increase the baud-rate by two steps, you have to type:
2910+.br
2911+.sp 0.6v
2912+C-a, C-u, C-a, C-u
2913+.br
2914+.sp 0.6v
2915+assuming of-course that "C-a" is the escape character.
2916+.br
2917+.sp 0.6v
2918+.SH SENDING AND RECEIVING FILES
2919+.B picocom
2920+can send and receive files over the serial port using external programs that implement the respective protocols. In Linux typical programs for this purpose are:
2921+.IP \(em 3
2922+.B rx(1)
2923+- receive using the X-MODEM protocol
2924+.IP \(em 3
2925+.B rb(1)
2926+- receive using the Y-MODEM protocol
2927+.IP \(em 3
2928+.B rz(1)
2929+- receive using the Z-MODEM protocol
2930+.IP \(em 3
2931+.B sx(1)
2932+- send using the X-MODEM protocol
2933+.IP \(em 3
2934+.B sb(1)
2935+- send using the Y-MODEM protocol
2936+.IP \(em 3
2937+.B sz(1)
2938+- send using the Z-MODEM protocol
2939+.IP \(em 3
2940+.B ascii-xfr(1)
2941+- receive or transmit ASCII files
2942+.PP
2943+The name of, and the command-line options to, the program to be used for transmitting files are given by the "--send-cmd" option. Similarly the program to receive files, and its argumets, are given by the "--receive-cmd" option. For example, in order to start a
2944+.B picocom
2945+session that uses "sz" to transmit files, and "rz" to receive, you have to say something like this:
2946+.br
2947+.sp 0.6v
2948+picocom --send-cmd "sz -vv" --receive-cmd "rz -vv"
2949+.br
2950+.sp 0.6v
2951+During the picocom session, if you key the "send" or "receive" commands (e.g. by pressing C-a, C-s, or C-a, C-r) you will be prompted for a filename. At this prompt you can enter one or more file-names, and any additional arguments to the transmission or reception program. After that, picocom will start the the external program as specified by the "--send-cmd", or "--receive-cmd" option, and with any filenames and additional arguments you may have supplied. The standard input and output of the external program will be connected to the serial port. The standard error of the external program will be connected to the terminal which---while the program is running---will revert to canonical mode. Pressing 'C-c' while the external program is running will prematurely terminate it, and return control to
2952+.B picocom
2953+. Pressing 'C-c' at any other time, has no special effect; the character is normally passed to the serial port.
2954+.br
2955+.sp 0.6v
2956+.SH OPTIONS
2957+.B picocom
2958+accepts the following command-line options
2959+.TP 3
2960+.B --baud | -b
2961+Defines the baud-rate to set the serial-port (terminal) to.
2962+.TP 3
2963+.B --flow | -f
2964+Defines the flow-control mode to set the serial-port to. Must be one of:
2965+.RS 3
2966+.IP \(em 3
2967+\'x' for xon/xoff (software) mode
2968+.IP \(em 3
2969+\'h' for hardware flow control (RTS/CTS)
2970+.IP \(em 3
2971+\'n' for no flow control
2972+.PP
2973+(Default: 'n')
2974+.RE
2975+.TP 3
2976+.B --parity | -p
2977+Defines the parity mode to set the serial-port to. Must be one of:
2978+.RS 3
2979+.IP \(em 3
2980+\'o' for odd parity mode.
2981+.IP \(em 3
2982+\'e' for even parity mode.
2983+.IP \(em 3
2984+\'n' for no parity, mode.
2985+.PP
2986+(Default: 'n')
2987+.RE
2988+.TP 3
2989+.B --databits | -d
2990+Defines the number of data bits in every character. Must be one of: 5, 6, 7, 8
2991+.br
2992+.sp 0.6v
2993+(Default: 8)
2994+.TP 3
2995+.B --esacpe | -e
2996+Defines the character that will make picocom enter command-mode (see description above). If 'x' is given, then C-x will make picocom enter command mode.
2997+.br
2998+.sp 0.6v
2999+(Default: 'a')
3000+.TP 3
3001+.B --noinit | -i
3002+If given,
3003+.B picocom
3004+will not initialize, reset, or otherwise meddle with the serial port at start-up. It will just open it. This is useful, for example, for connecting
3005+.B picocom
3006+to already-connected modems, or already configured ports without terminating the connection, or altering the settings. If required serial port parameters can then be adjusted at run-time by commands.
3007+.TP 3
3008+.B --noreset | -r
3009+If given,
3010+.B picocom
3011+will not *reset* the serial port when exiting. It will just close the filedes and do nothing more. This is useful, for example, for leaving modems connected when exiting
3012+.B picocom
3013+. Regardless whether the "--noreset" option is given the user can exit
3014+.B picocom
3015+using the "Quit" command (instead of "Exit"), which never resets the serial port. If "--noreset" is given then "Quit" and "Exit" behave essentially the same.
3016+.TP 3
3017+.B --nolock | -l
3018+If given,
3019+.B picocom
3020+will *not* attempt to lock the serial port before opening it. Normally picocom attempts to get a UUCP-style lock-file (e.g. "/var/lock/LCK..ttyS0") before opening the port. Failing to do so, results in the program exiting after emitting an error-message. It is possible that your picocom binary is compiled without this option.
3021+.TP 3
3022+.B --send-cmd | -s
3023+Specifies the external program (and any arguments to it) that will be used for transmitting files.
3024+.br
3025+.sp 0.6v
3026+Default: "sz -vv"
3027+.TP 3
3028+.B --receive-cmd | -v
3029+Specifies the external program (and any arguments to it) that will be used for receiving files.
3030+.br
3031+.sp 0.6v
3032+(Default: "rz -vv")
3033+.TP 3
3034+.B --help | -h
3035+Print a short help message describing the command-line options.
3036+.PP
3037+.SH AUTHOR
3038+picocom was written by Nick Patavalis (npat@efault.net)
3039+.br
3040+.sp 0.6v
3041+.SH AVAILABILITY
3042+The latest version of "picocom" can be downloaded from:
3043+.B http://efault.net/npat/hacks/picocom/
3044Index: user/blkfin-apps/picocom/LICENSE.txt
3045===================================================================
3046--- user/blkfin-apps/picocom/LICENSE.txt (revision 0)
3047+++ user/blkfin-apps/picocom/LICENSE.txt (revision 0)
3048@@ -0,0 +1,340 @@
3049+ GNU GENERAL PUBLIC LICENSE
3050+ Version 2, June 1991
3051+
3052+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
3053+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3054+ Everyone is permitted to copy and distribute verbatim copies
3055+ of this license document, but changing it is not allowed.
3056+
3057+ Preamble
3058+
3059+ The licenses for most software are designed to take away your
3060+freedom to share and change it. By contrast, the GNU General Public
3061+License is intended to guarantee your freedom to share and change free
3062+software--to make sure the software is free for all its users. This
3063+General Public License applies to most of the Free Software
3064+Foundation's software and to any other program whose authors commit to
3065+using it. (Some other Free Software Foundation software is covered by
3066+the GNU Library General Public License instead.) You can apply it to
3067+your programs, too.
3068+
3069+ When we speak of free software, we are referring to freedom, not
3070+price. Our General Public Licenses are designed to make sure that you
3071+have the freedom to distribute copies of free software (and charge for
3072+this service if you wish), that you receive source code or can get it
3073+if you want it, that you can change the software or use pieces of it
3074+in new free programs; and that you know you can do these things.
3075+
3076+ To protect your rights, we need to make restrictions that forbid
3077+anyone to deny you these rights or to ask you to surrender the rights.
3078+These restrictions translate to certain responsibilities for you if you
3079+distribute copies of the software, or if you modify it.
3080+
3081+ For example, if you distribute copies of such a program, whether
3082+gratis or for a fee, you must give the recipients all the rights that
3083+you have. You must make sure that they, too, receive or can get the
3084+source code. And you must show them these terms so they know their
3085+rights.
3086+
3087+ We protect your rights with two steps: (1) copyright the software, and
3088+(2) offer you this license which gives you legal permission to copy,
3089+distribute and/or modify the software.
3090+
3091+ Also, for each author's protection and ours, we want to make certain
3092+that everyone understands that there is no warranty for this free
3093+software. If the software is modified by someone else and passed on, we
3094+want its recipients to know that what they have is not the original, so
3095+that any problems introduced by others will not reflect on the original
3096+authors' reputations.
3097+
3098+ Finally, any free program is threatened constantly by software
3099+patents. We wish to avoid the danger that redistributors of a free
3100+program will individually obtain patent licenses, in effect making the
3101+program proprietary. To prevent this, we have made it clear that any
3102+patent must be licensed for everyone's free use or not licensed at all.
3103+
3104+ The precise terms and conditions for copying, distribution and
3105+modification follow.
3106+\f
3107+ GNU GENERAL PUBLIC LICENSE
3108+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
3109+
3110+ 0. This License applies to any program or other work which contains
3111+a notice placed by the copyright holder saying it may be distributed
3112+under the terms of this General Public License. The "Program", below,
3113+refers to any such program or work, and a "work based on the Program"
3114+means either the Program or any derivative work under copyright law:
3115+that is to say, a work containing the Program or a portion of it,
3116+either verbatim or with modifications and/or translated into another
3117+language. (Hereinafter, translation is included without limitation in
3118+the term "modification".) Each licensee is addressed as "you".
3119+
3120+Activities other than copying, distribution and modification are not
3121+covered by this License; they are outside its scope. The act of
3122+running the Program is not restricted, and the output from the Program
3123+is covered only if its contents constitute a work based on the
3124+Program (independent of having been made by running the Program).
3125+Whether that is true depends on what the Program does.
3126+
3127+ 1. You may copy and distribute verbatim copies of the Program's
3128+source code as you receive it, in any medium, provided that you
3129+conspicuously and appropriately publish on each copy an appropriate
3130+copyright notice and disclaimer of warranty; keep intact all the
3131+notices that refer to this License and to the absence of any warranty;
3132+and give any other recipients of the Program a copy of this License
3133+along with the Program.
3134+
3135+You may charge a fee for the physical act of transferring a copy, and
3136+you may at your option offer warranty protection in exchange for a fee.
3137+
3138+ 2. You may modify your copy or copies of the Program or any portion
3139+of it, thus forming a work based on the Program, and copy and
3140+distribute such modifications or work under the terms of Section 1
3141+above, provided that you also meet all of these conditions:
3142+
3143+ a) You must cause the modified files to carry prominent notices
3144+ stating that you changed the files and the date of any change.
3145+
3146+ b) You must cause any work that you distribute or publish, that in
3147+ whole or in part contains or is derived from the Program or any
3148+ part thereof, to be licensed as a whole at no charge to all third
3149+ parties under the terms of this License.
3150+
3151+ c) If the modified program normally reads commands interactively
3152+ when run, you must cause it, when started running for such
3153+ interactive use in the most ordinary way, to print or display an
3154+ announcement including an appropriate copyright notice and a
3155+ notice that there is no warranty (or else, saying that you provide
3156+ a warranty) and that users may redistribute the program under
3157+ these conditions, and telling the user how to view a copy of this
3158+ License. (Exception: if the Program itself is interactive but
3159+ does not normally print such an announcement, your work based on
3160+ the Program is not required to print an announcement.)
3161+\f
3162+These requirements apply to the modified work as a whole. If
3163+identifiable sections of that work are not derived from the Program,
3164+and can be reasonably considered independent and separate works in
3165+themselves, then this License, and its terms, do not apply to those
3166+sections when you distribute them as separate works. But when you
3167+distribute the same sections as part of a whole which is a work based
3168+on the Program, the distribution of the whole must be on the terms of
3169+this License, whose permissions for other licensees extend to the
3170+entire whole, and thus to each and every part regardless of who wrote it.
3171+
3172+Thus, it is not the intent of this section to claim rights or contest
3173+your rights to work written entirely by you; rather, the intent is to
3174+exercise the right to control the distribution of derivative or
3175+collective works based on the Program.
3176+
3177+In addition, mere aggregation of another work not based on the Program
3178+with the Program (or with a work based on the Program) on a volume of
3179+a storage or distribution medium does not bring the other work under
3180+the scope of this License.
3181+
3182+ 3. You may copy and distribute the Program (or a work based on it,
3183+under Section 2) in object code or executable form under the terms of
3184+Sections 1 and 2 above provided that you also do one of the following:
3185+
3186+ a) Accompany it with the complete corresponding machine-readable
3187+ source code, which must be distributed under the terms of Sections
3188+ 1 and 2 above on a medium customarily used for software interchange; or,
3189+
3190+ b) Accompany it with a written offer, valid for at least three
3191+ years, to give any third party, for a charge no more than your
3192+ cost of physically performing source distribution, a complete
3193+ machine-readable copy of the corresponding source code, to be
3194+ distributed under the terms of Sections 1 and 2 above on a medium
3195+ customarily used for software interchange; or,
3196+
3197+ c) Accompany it with the information you received as to the offer
3198+ to distribute corresponding source code. (This alternative is
3199+ allowed only for noncommercial distribution and only if you
3200+ received the program in object code or executable form with such
3201+ an offer, in accord with Subsection b above.)
3202+
3203+The source code for a work means the preferred form of the work for
3204+making modifications to it. For an executable work, complete source
3205+code means all the source code for all modules it contains, plus any
3206+associated interface definition files, plus the scripts used to
3207+control compilation and installation of the executable. However, as a
3208+special exception, the source code distributed need not include
3209+anything that is normally distributed (in either source or binary
3210+form) with the major components (compiler, kernel, and so on) of the
3211+operating system on which the executable runs, unless that component
3212+itself accompanies the executable.
3213+
3214+If distribution of executable or object code is made by offering
3215+access to copy from a designated place, then offering equivalent
3216+access to copy the source code from the same place counts as
3217+distribution of the source code, even though third parties are not
3218+compelled to copy the source along with the object code.
3219+\f
3220+ 4. You may not copy, modify, sublicense, or distribute the Program
3221+except as expressly provided under this License. Any attempt
3222+otherwise to copy, modify, sublicense or distribute the Program is
3223+void, and will automatically terminate your rights under this License.
3224+However, parties who have received copies, or rights, from you under
3225+this License will not have their licenses terminated so long as such
3226+parties remain in full compliance.
3227+
3228+ 5. You are not required to accept this License, since you have not
3229+signed it. However, nothing else grants you permission to modify or
3230+distribute the Program or its derivative works. These actions are
3231+prohibited by law if you do not accept this License. Therefore, by
3232+modifying or distributing the Program (or any work based on the
3233+Program), you indicate your acceptance of this License to do so, and
3234+all its terms and conditions for copying, distributing or modifying
3235+the Program or works based on it.
3236+
3237+ 6. Each time you redistribute the Program (or any work based on the
3238+Program), the recipient automatically receives a license from the
3239+original licensor to copy, distribute or modify the Program subject to
3240+these terms and conditions. You may not impose any further
3241+restrictions on the recipients' exercise of the rights granted herein.
3242+You are not responsible for enforcing compliance by third parties to
3243+this License.
3244+
3245+ 7. If, as a consequence of a court judgment or allegation of patent
3246+infringement or for any other reason (not limited to patent issues),
3247+conditions are imposed on you (whether by court order, agreement or
3248+otherwise) that contradict the conditions of this License, they do not
3249+excuse you from the conditions of this License. If you cannot
3250+distribute so as to satisfy simultaneously your obligations under this
3251+License and any other pertinent obligations, then as a consequence you
3252+may not distribute the Program at all. For example, if a patent
3253+license would not permit royalty-free redistribution of the Program by
3254+all those who receive copies directly or indirectly through you, then
3255+the only way you could satisfy both it and this License would be to
3256+refrain entirely from distribution of the Program.
3257+
3258+If any portion of this section is held invalid or unenforceable under
3259+any particular circumstance, the balance of the section is intended to
3260+apply and the section as a whole is intended to apply in other
3261+circumstances.
3262+
3263+It is not the purpose of this section to induce you to infringe any
3264+patents or other property right claims or to contest validity of any
3265+such claims; this section has the sole purpose of protecting the
3266+integrity of the free software distribution system, which is
3267+implemented by public license practices. Many people have made
3268+generous contributions to the wide range of software distributed
3269+through that system in reliance on consistent application of that
3270+system; it is up to the author/donor to decide if he or she is willing
3271+to distribute software through any other system and a licensee cannot
3272+impose that choice.
3273+
3274+This section is intended to make thoroughly clear what is believed to
3275+be a consequence of the rest of this License.
3276+\f
3277+ 8. If the distribution and/or use of the Program is restricted in
3278+certain countries either by patents or by copyrighted interfaces, the
3279+original copyright holder who places the Program under this License
3280+may add an explicit geographical distribution limitation excluding
3281+those countries, so that distribution is permitted only in or among
3282+countries not thus excluded. In such case, this License incorporates
3283+the limitation as if written in the body of this License.
3284+
3285+ 9. The Free Software Foundation may publish revised and/or new versions
3286+of the General Public License from time to time. Such new versions will
3287+be similar in spirit to the present version, but may differ in detail to
3288+address new problems or concerns.
3289+
3290+Each version is given a distinguishing version number. If the Program
3291+specifies a version number of this License which applies to it and "any
3292+later version", you have the option of following the terms and conditions
3293+either of that version or of any later version published by the Free
3294+Software Foundation. If the Program does not specify a version number of
3295+this License, you may choose any version ever published by the Free Software
3296+Foundation.
3297+
3298+ 10. If you wish to incorporate parts of the Program into other free
3299+programs whose distribution conditions are different, write to the author
3300+to ask for permission. For software which is copyrighted by the Free
3301+Software Foundation, write to the Free Software Foundation; we sometimes
3302+make exceptions for this. Our decision will be guided by the two goals
3303+of preserving the free status of all derivatives of our free software and
3304+of promoting the sharing and reuse of software generally.
3305+
3306+ NO WARRANTY
3307+
3308+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
3309+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
3310+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
3311+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
3312+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
3313+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
3314+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
3315+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
3316+REPAIR OR CORRECTION.
3317+
3318+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
3319+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
3320+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
3321+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
3322+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
3323+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
3324+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
3325+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
3326+POSSIBILITY OF SUCH DAMAGES.
3327+
3328+ END OF TERMS AND CONDITIONS
3329+\f
3330+ How to Apply These Terms to Your New Programs
3331+
3332+ If you develop a new program, and you want it to be of the greatest
3333+possible use to the public, the best way to achieve this is to make it
3334+free software which everyone can redistribute and change under these terms.
3335+
3336+ To do so, attach the following notices to the program. It is safest
3337+to attach them to the start of each source file to most effectively
3338+convey the exclusion of warranty; and each file should have at least
3339+the "copyright" line and a pointer to where the full notice is found.
3340+
3341+ <one line to give the program's name and a brief idea of what it does.>
3342+ Copyright (C) <year> <name of author>
3343+
3344+ This program is free software; you can redistribute it and/or modify
3345+ it under the terms of the GNU General Public License as published by
3346+ the Free Software Foundation; either version 2 of the License, or
3347+ (at your option) any later version.
3348+
3349+ This program is distributed in the hope that it will be useful,
3350+ but WITHOUT ANY WARRANTY; without even the implied warranty of
3351+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3352+ GNU General Public License for more details.
3353+
3354+ You should have received a copy of the GNU General Public License
3355+ along with this program; if not, write to the Free Software
3356+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3357+
3358+
3359+Also add information on how to contact you by electronic and paper mail.
3360+
3361+If the program is interactive, make it output a short notice like this
3362+when it starts in an interactive mode:
3363+
3364+ Gnomovision version 69, Copyright (C) year name of author
3365+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
3366+ This is free software, and you are welcome to redistribute it
3367+ under certain conditions; type `show c' for details.
3368+
3369+The hypothetical commands `show w' and `show c' should show the appropriate
3370+parts of the General Public License. Of course, the commands you use may
3371+be called something other than `show w' and `show c'; they could even be
3372+mouse-clicks or menu items--whatever suits your program.
3373+
3374+You should also get your employer (if you work as a programmer) or your
3375+school, if any, to sign a "copyright disclaimer" for the program, if
3376+necessary. Here is a sample; alter the names:
3377+
3378+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
3379+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
3380+
3381+ <signature of Ty Coon>, 1 April 1989
3382+ Ty Coon, President of Vice
3383+
3384+This General Public License does not permit incorporating your program into
3385+proprietary programs. If your program is a subroutine library, you may
3386+consider it more useful to permit linking proprietary applications with the
3387+library. If this is what you want to do, use the GNU Library General
3388+Public License instead of this License.
3389Index: user/blkfin-apps/picocom/picocom.8.html
3390===================================================================
3391--- user/blkfin-apps/picocom/picocom.8.html (revision 0)
3392+++ user/blkfin-apps/picocom/picocom.8.html (revision 0)
3393@@ -0,0 +1,495 @@
3394+<html>
3395+<head>
3396+<title>picocom(8)</title>
3397+</head>
3398+
3399+<body>
3400+
3401+<center><table width="100%"><tr>
3402+ <td align="left">picocom(8)</td>
3403+ <td align="center"></td>
3404+ <td align="right">picocom(8)</td>
3405+</tr></table></center>
3406+
3407+<h2>NAME</h2>
3408+<center><table width="90%"><tr><td>
3409+picocom -- minimal dumb-terminal emulation program
3410+</td></tr></table></center>
3411+
3412+<h2>SYNOPSIS</h2>
3413+<center><table width="90%"><tr><td>
3414+<ul>
3415+ <li><b>
3416+ picocom [ <i>options</i> ] <i>device</i>
3417+ </b></li>
3418+</ul>
3419+</td></tr></table></center>
3420+
3421+<h2>DESCRIPTION</h2>
3422+<center><table width="90%"><tr><td>
3423+ <p>
3424+ As its name suggests, <b>picocom</b> is a minimal dumb-terminal
3425+ emulation program. It is, in principle, very much like
3426+ <a href=""><b>minicom</b>(1)</a>, only it's "pico" instead of
3427+ "mini"! It was designed to serve as a simple, manual, modem
3428+ configuration, testing, and debugging tool. It has also served
3429+ (quite well) as a low-tech "terminal-window" to allow operator
3430+ intervention in PPP connection scripts (something like the
3431+ ms-windows "open terminal window before / after dialing" feature).
3432+ It could also prove useful in many other similar tasks.
3433+ </p>
3434+ <p>
3435+ When <b>picocom</b> starts it opens the terminal (serial device)
3436+ given as its non-option argument. Unless the <i>--noinit</i>
3437+ option is given, it configures the device to the settings
3438+ specified by the option-arguments (or to some default settings),
3439+ and sets it to "raw" mode. If <i>--noinit</i> is given, the
3440+ initialization and configuration is skipped; the device is just
3441+ opened. Following this, <b>picocom</b> sets the standard-input and
3442+ standard-output to raw mode. Having done so, it goes in a loop
3443+ where it listens for input from stdin, or from the serial port.
3444+ Input from the serial port is copied to the standard output while
3445+ input from the standard input is copied to the serial port. <b>picocom</b>
3446+ also scans its input stream for a user-specified control
3447+ character, called the "escape character" (being by default "C-a").
3448+ If the escape character is seen, then instead of sending it to the
3449+ serial-device, the program enters "command mode" and waits for the
3450+ next character (which is called the "function character").
3451+ Depending on the value of the function character, <b>picocom</b>
3452+ performs one of the operations described in the "Commands" section
3453+ below.
3454+ </p>
3455+</td></tr></table></center>
3456+
3457+<h2>COMMANDS</h2>
3458+<center><table width="90%"><tr><td>
3459+ <p>
3460+ Commands are given to <b>picocom</b> by first keying the "espace
3461+ character" which by default is "C-a" (see "Options" below on how
3462+ to change it), and then keying one for the function (command)
3463+ characters shown here.
3464+ </p>
3465+ <dl>
3466+ <dt><b>
3467+ [escape character]
3468+ </b></dt>
3469+ <dd>
3470+ <p>
3471+ Send the escape character to the serial port and return to
3472+ "transparent" mode. This means that if the escape character
3473+ ("C-a", by default) is typed twice, the program sends the
3474+ escape character to the serial port, and remains in
3475+ transparent mode. This is a new behavior implemented in v1.4.
3476+ Previously picocom used to ignore the escape-character when it
3477+ was entered as a function character.
3478+ </p>
3479+ </dd>
3480+ <dt><b>
3481+ C-x
3482+ </b></dt>
3483+ <dd>
3484+ <p>
3485+ Exit the program: if the "--noreset" option was not given then
3486+ the serial port is reset to its original settings before
3487+ exiting; if it was given the serial port is not reset.
3488+ </p>
3489+ </dd>
3490+ <dt><b>
3491+ C-q
3492+ </b></dt>
3493+ <dd>
3494+ <p>
3495+ Quit the program *without* reseting the serial port,
3496+ regardless of the "--noreset" option.
3497+ </p>
3498+ </dd>
3499+ <dt><b>
3500+ C-p
3501+ </b></dt>
3502+ <dd>
3503+ <p>
3504+ Pulse the DTR line. Lower it for 1 sec, and then raise it
3505+ again.
3506+ </p>
3507+ </dd>
3508+ <dt><b>
3509+ C-t
3510+ </b></dt>
3511+ <dd>
3512+ <p>
3513+ Toggle the DTR line. If DTR is up, then lower it. If it is
3514+ down, then raise it.
3515+ </p>
3516+ </dd>
3517+ <dt><b>
3518+ C-\e
3519+ </b></dt>
3520+ <dd>
3521+ <p>
3522+ Generate a break sequence on the serial line. A break sequence
3523+ is usually generated by marking (driving to logical one) the
3524+ serial Tx line for an amount of time coresponding to several
3525+ character durations.
3526+ </p>
3527+ </dd>
3528+ <dt><b>
3529+ C-u
3530+ </b></dt>
3531+ <dd>
3532+ <p>
3533+ Baud up. Increase the baud-rate. The list of baud-rates
3534+ stepped-through by this command is: 300, 600, 1200, 2400,
3535+ 4800, 9600, 19200, 38400, 57600, 115200.
3536+ </p>
3537+ </dd>
3538+ <dt><b>
3539+ C-d
3540+ </b></dt>
3541+ <dd>
3542+ <p>
3543+ Baud down. Decrease the baud-rate. The list of baud-rates
3544+ stepped-through by this command is the same as for the
3545+ "baud-up" command.
3546+ </p>
3547+ </dd>
3548+ <dt><b>
3549+ C-f
3550+ </b></dt>
3551+ <dd>
3552+ <p>
3553+ Cycle through flow-control settings (RTS/CTS, XON/XOFF, none).
3554+ </p>
3555+ </dd>
3556+ <dt><b>
3557+ C-y
3558+ </b></dt>
3559+ <dd>
3560+ <p>
3561+ Cycle through parity settings (even, odd, none).
3562+ </p>
3563+ </dd>
3564+ <dt><b>
3565+ C-b
3566+ </b></dt>
3567+ <dd>
3568+ <p>
3569+ Cycle through databits-number settings (5, 6, 7, 8).
3570+ </p>
3571+ </dd>
3572+ <dt><b>
3573+ C-v
3574+ </b></dt>
3575+ <dd>
3576+ <p>
3577+ Show program options (like baud rate, data bits, etc). Only
3578+ the options that can be modified online (through commands) are
3579+ shown, not those that can only be set at the command-line.
3580+ </p>
3581+ </dd>
3582+ <dt><b>
3583+ C-s
3584+ </b></dt>
3585+ <dd>
3586+ <p>
3587+ Send (upload) a file (see "Sending and Receiving Files" below)
3588+ </p>
3589+ </dd>
3590+ <dt><b>
3591+ C-r
3592+ </b></dt>
3593+ <dd>
3594+ <p>
3595+ Receive (download) a file (see "Sending and Receiving Files"
3596+ below)
3597+ </p>
3598+ </dd>
3599+ </dl>
3600+ <p>
3601+ After performing one of the above operations the program leaves
3602+ the command mode and enters transparent mode. Example: To increase
3603+ the baud-rate by two steps, you have to type:
3604+ </p>
3605+ <p>
3606+ C-a, C-u, C-a, C-u
3607+ </p>
3608+ <p>
3609+ assuming of-course that "C-a" is the escape character.
3610+ </p>
3611+</td></tr></table></center>
3612+
3613+<h2>SENDING AND RECEIVING FILES</h2>
3614+<center><table width="90%"><tr><td>
3615+ <p>
3616+ <b>picocom</b> can send and receive files over the serial port
3617+ using external programs that implement the respective protocols.
3618+ In Linux typical programs for this purpose are:
3619+ </p>
3620+ <ul>
3621+ <li>
3622+ <p>
3623+ <a href=""><b>rx</b>(1)</a> - receive using the X-MODEM
3624+ protocol
3625+ </p>
3626+ </li>
3627+ <li>
3628+ <p>
3629+ <a href=""><b>rb</b>(1)</a> - receive using the Y-MODEM
3630+ protocol
3631+ </p>
3632+ </li>
3633+ <li>
3634+ <p>
3635+ <a href=""><b>rz</b>(1)</a> - receive using the Z-MODEM
3636+ protocol
3637+ </p>
3638+ </li>
3639+ <li>
3640+ <p>
3641+ <a href=""><b>sx</b>(1)</a> - send using the X-MODEM protocol
3642+ </p>
3643+ </li>
3644+ <li>
3645+ <p>
3646+ <a href=""><b>sb</b>(1)</a> - send using the Y-MODEM protocol
3647+ </p>
3648+ </li>
3649+ <li>
3650+ <p>
3651+ <a href=""><b>sz</b>(1)</a> - send using the Z-MODEM protocol
3652+ </p>
3653+ </li>
3654+ <li>
3655+ <p>
3656+ <a href=""><b>ascii-xfr</b>(1)</a> - receive or transmit ASCII
3657+ files
3658+ </p>
3659+ </li>
3660+ </ul>
3661+ <p>
3662+ The name of, and the command-line options to, the program to be
3663+ used for transmitting files are given by the "--send-cmd" option.
3664+ Similarly the program to receive files, and its argumets, are
3665+ given by the "--receive-cmd" option. For example, in order to
3666+ start a <b>picocom</b> session that uses "sz" to transmit files,
3667+ and "rz" to receive, you have to say something like this:
3668+ </p>
3669+ <p>
3670+ picocom --send-cmd "sz -vv" --receive-cmd "rz -vv"
3671+ </p>
3672+ <p>
3673+ During the picocom session, if you key the "send" or "receive"
3674+ commands (e.g. by pressing C-a, C-s, or C-a, C-r) you will be
3675+ prompted for a filename. At this prompt you can enter one or more
3676+ file-names, and any additional arguments to the transmission or
3677+ reception program. After that, picocom will start the the external
3678+ program as specified by the "--send-cmd", or "--receive-cmd"
3679+ option, and with any filenames and additional arguments you may
3680+ have supplied. The standard input and output of the external
3681+ program will be connected to the serial port. The standard error
3682+ of the external program will be connected to the terminal
3683+ which---while the program is running---will revert to canonical
3684+ mode. Pressing 'C-c' while the external program is running will
3685+ prematurely terminate it, and return control to <b>picocom</b>.
3686+ Pressing 'C-c' at any other time, has no special effect; the
3687+ character is normally passed to the serial port.
3688+ </p>
3689+</td></tr></table></center>
3690+
3691+<h2>OPTIONS</h2>
3692+<center><table width="90%"><tr><td>
3693+ <p>
3694+ <b>picocom</b> accepts the following command-line options
3695+ </p>
3696+ <dl>
3697+ <dt><b>
3698+ --baud | -b
3699+ </b></dt>
3700+ <dd>
3701+ <p>
3702+ Defines the baud-rate to set the serial-port (terminal) to.
3703+ </p>
3704+ </dd>
3705+ <dt><b>
3706+ --flow | -f
3707+ </b></dt>
3708+ <dd>
3709+ <p>
3710+ Defines the flow-control mode to set the serial-port to. Must
3711+ be one of:
3712+ </p>
3713+ <ul>
3714+ <li>
3715+ <p>
3716+ \'x' for xon/xoff (software) mode
3717+ </p>
3718+ </li>
3719+ <li>
3720+ <p>
3721+ \'h' for hardware flow control (RTS/CTS)
3722+ </p>
3723+ </li>
3724+ <li>
3725+ <p>
3726+ \'n' for no flow control
3727+ </p>
3728+ </li>
3729+ </ul>
3730+ <p>
3731+ (Default: 'n')
3732+ </p>
3733+ </dd>
3734+ <dt><b>
3735+ --parity | -p
3736+ </b></dt>
3737+ <dd>
3738+ <p>
3739+ Defines the parity mode to set the serial-port to. Must be one
3740+ of:
3741+ </p>
3742+ <ul>
3743+ <li>
3744+ <p>
3745+ \'o' for odd parity mode.
3746+ </p>
3747+ </li>
3748+ <li>
3749+ <p>
3750+ \'e' for even parity mode.
3751+ </p>
3752+ </li>
3753+ <li>
3754+ <p>
3755+ \'n' for no parity, mode.
3756+ </p>
3757+ </li>
3758+ </ul>
3759+ <p>
3760+ (Default: 'n')
3761+ </p>
3762+ </dd>
3763+ <dt><b>
3764+ --databits | -d
3765+ </b></dt>
3766+ <dd>
3767+ <p>
3768+ Defines the number of data bits in every character. Must be
3769+ one of: 5, 6, 7, 8
3770+ </p>
3771+ <p>
3772+ (Default: 8)
3773+ </p>
3774+ </dd>
3775+ <dt><b>
3776+ --esacpe | -e
3777+ </b></dt>
3778+ <dd>
3779+ <p>
3780+ Defines the character that will make picocom enter
3781+ command-mode (see description above). If 'x' is given, then
3782+ C-x will make picocom enter command mode.
3783+ </p>
3784+ <p>
3785+ (Default: 'a')
3786+ </p>
3787+ </dd>
3788+ <dt><b>
3789+ --noinit | -i
3790+ </b></dt>
3791+ <dd>
3792+ <p>
3793+ If given, <b>picocom</b> will not initialize, reset, or
3794+ otherwise meddle with the serial port at start-up. It will
3795+ just open it. This is useful, for example, for connecting <b>picocom</b>
3796+ to already-connected modems, or already configured ports
3797+ without terminating the connection, or altering the settings.
3798+ If required serial port parameters can then be adjusted at
3799+ run-time by commands.
3800+ </p>
3801+ </dd>
3802+ <dt><b>
3803+ --noreset | -r
3804+ </b></dt>
3805+ <dd>
3806+ <p>
3807+ If given, <b>picocom</b> will not *reset* the serial port when
3808+ exiting. It will just close the filedes and do nothing more.
3809+ This is useful, for example, for leaving modems connected when
3810+ exiting <b>picocom</b>. Regardless whether the "--noreset"
3811+ option is given the user can exit <b>picocom</b> using the
3812+ "Quit" command (instead of "Exit"), which never resets the
3813+ serial port. If "--noreset" is given then "Quit" and "Exit"
3814+ behave essentially the same.
3815+ </p>
3816+ </dd>
3817+ <dt><b>
3818+ --nolock | -l
3819+ </b></dt>
3820+ <dd>
3821+ <p>
3822+ If given, <b>picocom</b> will *not* attempt to lock the serial
3823+ port before opening it. Normally picocom attempts to get a
3824+ UUCP-style lock-file (e.g. "/var/lock/LCK..ttyS0") before
3825+ opening the port. Failing to do so, results in the program
3826+ exiting after emitting an error-message. It is possible that
3827+ your picocom binary is compiled without this option.
3828+ </p>
3829+ </dd>
3830+ <dt><b>
3831+ --send-cmd | -s
3832+ </b></dt>
3833+ <dd>
3834+ <p>
3835+ Specifies the external program (and any arguments to it) that
3836+ will be used for transmitting files.
3837+ </p>
3838+ <p>
3839+ Default: "sz -vv"
3840+ </p>
3841+ </dd>
3842+ <dt><b>
3843+ --receive-cmd | -v
3844+ </b></dt>
3845+ <dd>
3846+ <p>
3847+ Specifies the external program (and any arguments to it) that
3848+ will be used for receiving files.
3849+ </p>
3850+ <p>
3851+ (Default: "rz -vv")
3852+ </p>
3853+ </dd>
3854+ <dt><b>
3855+ --help | -h
3856+ </b></dt>
3857+ <dd>
3858+ <p>
3859+ Print a short help message describing the command-line
3860+ options.
3861+ </p>
3862+ </dd>
3863+ </dl>
3864+</td></tr></table></center>
3865+
3866+<h2>AUTHOR</h2>
3867+<center><table width="90%"><tr><td>
3868+ <p>
3869+ picocom was written by Nick Patavalis (npat@efault.net)
3870+ </p>
3871+</td></tr></table></center>
3872+
3873+<h2>AVAILABILITY</h2>
3874+<center><table width="90%"><tr><td>
3875+ <p>
3876+ The latest version of "picocom" can be downloaded from:
3877+ <a href="http://efault.net/npat/hacks/picocom/">http://efault.net/npat/hacks/picocom/</a>
3878+ </p>
3879+</td></tr></table></center>
3880+
3881+<center><table width="100%"><tr>
3882+ <td align="left"></td>
3883+ <td align="center"></td>
3884+ <td align="right">picocom(8)</td>
3885+</tr></table></center>
3886+
3887+</body>
3888+</html>
3889Index: user/blkfin-apps/picocom/TODO
3890===================================================================
3891--- user/blkfin-apps/picocom/TODO (revision 0)
3892+++ user/blkfin-apps/picocom/TODO (revision 0)
3893@@ -0,0 +1 @@
3894+
3895Index: user/blkfin-apps/picocom/pcxm
3896===================================================================
3897--- user/blkfin-apps/picocom/pcxm (revision 0)
3898+++ user/blkfin-apps/picocom/pcxm (revision 0)
3899@@ -0,0 +1,4 @@
3900+#!/bin/sh
3901+exec picocom \
3902+ --send-cmd="sx -vv" \
3903+ --receive-cmd="rx -vv" "$@"
3904Index: user/blkfin-apps/picocom/CHANGES
3905===================================================================
3906--- user/blkfin-apps/picocom/CHANGES (revision 0)
3907+++ user/blkfin-apps/picocom/CHANGES (revision 0)
3908@@ -0,0 +1,157 @@
3909+------------------------------------------------------------------------
3910+r35 | npat | 2004-08-13 14:18:38 +0300 (Fri, 13 Aug 2004) | 3 lines
3911+Changed paths:
3912+ M /picocom/trunk/Makefile
3913+
3914+picocom version 1.4
3915+
3916+
3917+------------------------------------------------------------------------
3918+r34 | npat | 2004-08-13 14:15:23 +0300 (Fri, 13 Aug 2004) | 4 lines
3919+Changed paths:
3920+ M /picocom/trunk/Makefile
3921+
3922+Added the "changes" target that generates the CHANGES file from the
3923+svn (version control) commit logs.
3924+
3925+
3926+------------------------------------------------------------------------
3927+r33 | npat | 2004-08-13 05:48:26 +0300 (Fri, 13 Aug 2004) | 4 lines
3928+Changed paths:
3929+ M /picocom/trunk/Makefile
3930+ M /picocom/trunk/picocom.8.xml
3931+
3932+Converted the manpage sources to use the xmlmp-1.1 DTD, and hence the
3933+xmlmp tools (see http://npat.efault.net/hacks/xmlmp)
3934+
3935+
3936+------------------------------------------------------------------------
3937+r28 | npat | 2004-08-12 15:17:54 +0300 (Thu, 12 Aug 2004) | 2 lines
3938+Changed paths:
3939+ M /picocom/trunk/TODO
3940+
3941+Removed stale tasks from TODO. (Now it's empty).
3942+
3943+------------------------------------------------------------------------
3944+r27 | npat | 2004-08-12 15:16:03 +0300 (Thu, 12 Aug 2004) | 5 lines
3945+Changed paths:
3946+ M /picocom/trunk/CONTRIBUTORS
3947+ M /picocom/trunk/picocom.8.xml
3948+
3949+Added Julius P. Malkiewicz in the contributors list
3950+
3951+Updated documentation to comply with the changes made since r13
3952+
3953+
3954+------------------------------------------------------------------------
3955+r26 | npat | 2004-08-12 14:45:11 +0300 (Thu, 12 Aug 2004) | 9 lines
3956+Changed paths:
3957+ M /picocom/trunk/Makefile
3958+ M /picocom/trunk/picocom.c
3959+
3960+Added support for UUCP-style locks. Lock handling is compiled-in if
3961+the macro UUCP_LOCK_DIR is defined; if it is, it must contain the name
3962+of the lock directory. Locking can be disabled at runtime using the
3963+"--no<l>ock" option.
3964+
3965+UUCP-locks support is based on a patch submitted by Julius
3966+P. Malkiewicz <julius@sonartech.com.au>
3967+
3968+
3969+------------------------------------------------------------------------
3970+r25 | npat | 2004-08-12 11:55:56 +0300 (Thu, 12 Aug 2004) | 4 lines
3971+Changed paths:
3972+ M /picocom/trunk/picocom.c
3973+
3974+Implemented th C-\ command, which generates a break sequence. Patch
3975+submitted by Julius P. Malkiewicz <julius@sonartech.com.au>
3976+
3977+
3978+------------------------------------------------------------------------
3979+r24 | npat | 2004-08-12 11:52:39 +0300 (Thu, 12 Aug 2004) | 5 lines
3980+Changed paths:
3981+ M /picocom/trunk/picocom.c
3982+
3983+If two escape-characters are sent in a row, the second is
3984+passed-through, and picocom returns to transparrent mode. Patch
3985+submitteb by Julius P. Malkiewicz <julius@sonartech.com.au>
3986+
3987+
3988+------------------------------------------------------------------------
3989+r23 | npat | 2004-08-12 11:45:57 +0300 (Thu, 12 Aug 2004) | 7 lines
3990+Changed paths:
3991+ M /picocom/trunk/term.c
3992+
3993+Fixed "term.c" to compile under FreeBSD (and probably other BSDs
3994+also). "term.c" now includes "termios.h" instead of "termio.h" in
3995+non-linux system. Added a declaration for "tioold"---that was
3996+missing---in the non-linux part of the DTR toggling code. Patch
3997+submitted by Julius P. Malkiewicz <julius@sonartech.com.au>
3998+
3999+
4000+------------------------------------------------------------------------
4001+r12 | npat | 2004-08-11 19:03:48 +0300 (Wed, 11 Aug 2004) | 2 lines
4002+Changed paths:
4003+ M /picocom/trunk/CONTRIBUTORS
4004+ M /picocom/trunk/Makefile
4005+ M /picocom/trunk/README
4006+ A /picocom/trunk/picocom.8.xml
4007+
4008+Added r1.3
4009+
4010+------------------------------------------------------------------------
4011+r10 | npat | 2004-08-11 19:02:35 +0300 (Wed, 11 Aug 2004) | 3 lines
4012+Changed paths:
4013+ A /picocom/trunk/CONTRIBUTORS
4014+ M /picocom/trunk/Makefile
4015+ A /picocom/trunk/TODO
4016+ M /picocom/trunk/picocom.c
4017+
4018+Added r1.2
4019+
4020+
4021+------------------------------------------------------------------------
4022+r8 | npat | 2004-08-11 19:01:25 +0300 (Wed, 11 Aug 2004) | 2 lines
4023+Changed paths:
4024+ M /picocom/trunk/Makefile
4025+ A /picocom/trunk/NEWS
4026+ M /picocom/trunk/README
4027+ A /picocom/trunk/pcasc
4028+ A /picocom/trunk/pcxm
4029+ A /picocom/trunk/pcym
4030+ A /picocom/trunk/pczm
4031+ M /picocom/trunk/picocom.c
4032+
4033+Added r1.1
4034+
4035+------------------------------------------------------------------------
4036+r6 | npat | 2004-08-11 18:59:25 +0300 (Wed, 11 Aug 2004) | 2 lines
4037+Changed paths:
4038+ A /picocom/trunk/LICENSE.txt
4039+ A /picocom/trunk/Makefile
4040+ A /picocom/trunk/README
4041+ A /picocom/trunk/picocom.c
4042+ A /picocom/trunk/term.c
4043+ A /picocom/trunk/term.h
4044+
4045+Imported r1.0 sources
4046+
4047+------------------------------------------------------------------------
4048+r1 | svn | 2004-08-11 08:02:59 +0300 (Wed, 11 Aug 2004) | 2 lines
4049+Changed paths:
4050+ A /mu0
4051+ A /mu0/branches
4052+ A /mu0/tags
4053+ A /mu0/trunk
4054+ A /picocom
4055+ A /picocom/branches
4056+ A /picocom/tags
4057+ A /picocom/trunk
4058+ A /ppgplot
4059+ A /ppgplot/branches
4060+ A /ppgplot/tags
4061+ A /ppgplot/trunk
4062+
4063+Imported initial projects directory structure.
4064+
4065+------------------------------------------------------------------------
4066Index: user/blkfin-apps/picocom/pcym
4067===================================================================
4068--- user/blkfin-apps/picocom/pcym (revision 0)
4069+++ user/blkfin-apps/picocom/pcym (revision 0)
4070@@ -0,0 +1,4 @@
4071+#!/bin/sh
4072+exec picocom \
4073+ --send-cmd="sb -vv" \
4074+ --receive-cmd="rb -vvv" "$@"
4075Index: user/blkfin-apps/picocom/pczm
4076===================================================================
4077--- user/blkfin-apps/picocom/pczm (revision 0)
4078+++ user/blkfin-apps/picocom/pczm (revision 0)
4079@@ -0,0 +1,4 @@
4080+#!/bin/sh
4081+exec picocom \
4082+ --send-cmd="sz -vv -b" \
4083+ --receive-cmd="rz -vvv -b" "$@"
4084Index: user/blkfin-apps/picocom/picocom.c
4085===================================================================
4086--- user/blkfin-apps/picocom/picocom.c (revision 0)
4087+++ user/blkfin-apps/picocom/picocom.c (revision 0)
4088@@ -0,0 +1,1022 @@
4089+/* vi: set sw=4 ts=4:
4090+ *
4091+ * picocom.c
4092+ *
4093+ * simple dumb-terminal program. Helps you manually configure and test
4094+ * stuff like modems, devices w. serial ports etc.
4095+ *
4096+ * by Nick Patavalis (npat@efault.net)
4097+ *
4098+ * This program is free software; you can redistribute it and/or
4099+ * modify it under the terms of the GNU General Public License as
4100+ * published by the Free Software Foundation; either version 2 of the
4101+ * License, or (at your option) any later version.
4102+ *
4103+ * This program is distributed in the hope that it will be useful, but
4104+ * WITHOUT ANY WARRANTY; without even the implied warranty of
4105+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4106+ * General Public License for more details.
4107+ *
4108+ * You should have received a copy of the GNU General Public License
4109+ * along with this program; if not, write to the Free Software
4110+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4111+ * USA
4112+ */
4113+
4114+#include <stdlib.h>
4115+#include <stdio.h>
4116+#include <string.h>
4117+#include <ctype.h>
4118+#include <errno.h>
4119+#include <assert.h>
4120+#include <stdarg.h>
4121+#include <signal.h>
4122+#include <unistd.h>
4123+#include <fcntl.h>
4124+#include <sys/types.h>
4125+#include <sys/stat.h>
4126+#include <sys/wait.h>
4127+#include <limits.h>
4128+
4129+#define _GNU_SOURCE
4130+#include <getopt.h>
4131+
4132+#include "term.h"
4133+
4134+/**********************************************************************/
4135+
4136+#define KEY_EXIT '\x18' /* C-x: exit picocom */
4137+#define KEY_QUIT '\x11' /* C-q: exit picocom without reseting port */
4138+#define KEY_PULSE '\x10' /* C-p: pulse DTR */
4139+#define KEY_TOGGLE '\x14' /* C-t: toggle DTR */
4140+#define KEY_BAUD_UP '\x15' /* C-u: increase baudrate (up) */
4141+#define KEY_BAUD_DN '\x04' /* C-d: decrase baudrate (down) */
4142+#define KEY_FLOW '\x06' /* C-f: change flowcntrl mode */
4143+#define KEY_PARITY '\x19' /* C-y: change parity mode */
4144+#define KEY_BITS '\x02' /* C-b: change number of databits */
4145+#define KEY_STATUS '\x16' /* C-v: show program option */
4146+#define KEY_SEND '\x13' /* C-s: send file */
4147+#define KEY_RECEIVE '\x12' /* C-r: receive file */
4148+#define KEY_BREAK '\x1c' /* C-\: break */
4149+
4150+#define STO STDOUT_FILENO
4151+#define STI STDIN_FILENO
4152+
4153+/**********************************************************************/
4154+
4155+struct {
4156+ char port[128];
4157+ int baud;
4158+ enum flowcntrl_e flow;
4159+ char *flow_str;
4160+ enum parity_e parity;
4161+ char *parity_str;
4162+ int databits;
4163+ int noinit;
4164+ int noreset;
4165+#ifdef UUCP_LOCK_DIR
4166+ int nolock;
4167+#endif
4168+ unsigned char escape;
4169+ char send_cmd[128];
4170+ char receive_cmd[128];
4171+} opts = {
4172+ .port = "",
4173+ .baud = 9600,
4174+ .flow = FC_NONE,
4175+ .flow_str = "none",
4176+ .parity = P_NONE,
4177+ .parity_str = "none",
4178+ .databits = 8,
4179+ .noinit = 0,
4180+ .noreset = 0,
4181+#ifdef UUCP_LOCK_DIR
4182+ .nolock = 0,
4183+#endif
4184+ .escape = '\x01',
4185+ .send_cmd = "ascii_xfr -s -v -l10",
4186+ .receive_cmd = "rz -vv"
4187+};
4188+
4189+int tty_fd;
4190+
4191+/**********************************************************************/
4192+
4193+#ifdef UUCP_LOCK_DIR
4194+
4195+/* use HDB UUCP locks .. see
4196+ * <http://www.faqs.org/faqs/uucp-internals> for details
4197+ */
4198+
4199+char lockname[_POSIX_PATH_MAX] = "";
4200+
4201+int
4202+uucp_lockname(const char *dir, const char *file)
4203+{
4204+ char *p, *cp;
4205+ struct stat sb;
4206+
4207+ if ( ! dir || *dir == '\0' || stat(dir, &sb) != 0 )
4208+ return -1;
4209+
4210+ /* cut-off initial "/dev/" from file-name */
4211+ p = strchr(file + 1, '/');
4212+ p = p ? p + 1 : (char *)file;
4213+ /* replace '/'s with '_'s in what remains (after making a copy) */
4214+ p = cp = strdup(p);
4215+ do { if ( *p == '/' ) *p = '_'; } while(*p++);
4216+ /* build lockname */
4217+ snprintf(lockname, sizeof(lockname), "%s/LCK..%s", dir, cp);
4218+ /* destroy the copy */
4219+ free(cp);
4220+
4221+ return 0;
4222+}
4223+
4224+int
4225+uucp_lock(void)
4226+{
4227+ int r, fd, pid;
4228+ char buf[16];
4229+ mode_t m;
4230+
4231+ if ( lockname[0] == '\0' ) return 0;
4232+
4233+ fd = open(lockname, O_RDONLY);
4234+ if ( fd >= 0 ) {
4235+ r = read(fd, buf, sizeof(buf));
4236+ close(fd);
4237+ /* if r == 4, lock file is binary (old-style) */
4238+ pid = (r == 4) ? *(int *)buf : strtol(buf, NULL, 10);
4239+ if ( pid > 0
4240+ && kill((pid_t)pid, 0) < 0
4241+ && errno == ESRCH ) {
4242+ /* stale lock file */
4243+ printf("Removing stale lock: %s\n", lockname);
4244+ sleep(1);
4245+ unlink(lockname);
4246+ } else {
4247+ lockname[0] = '\0';
4248+ errno = EEXIST;
4249+ return -1;
4250+ }
4251+ }
4252+ /* lock it */
4253+ m = umask(022);
4254+ fd = open(lockname, O_WRONLY|O_CREAT|O_EXCL, 0666);
4255+ if ( fd < 0 ) { lockname[0] = '\0'; return -1; }
4256+ umask(m);
4257+ snprintf(buf, sizeof(buf), "%04d\n", getpid());
4258+ write(fd, buf, strlen(buf));
4259+ close(fd);
4260+
4261+ return 0;
4262+}
4263+
4264+int
4265+uucp_unlock(void)
4266+{
4267+ if ( lockname[0] ) unlink(lockname);
4268+ return 0;
4269+}
4270+
4271+#endif /* of UUCP_LOCK_DIR */
4272+
4273+/**********************************************************************/
4274+
4275+ssize_t
4276+writen_ni(int fd, const void *buff, size_t n)
4277+{
4278+ size_t nl;
4279+ ssize_t nw;
4280+ const char *p;
4281+
4282+ p = buff;
4283+ nl = n;
4284+ while (nl > 0) {
4285+ do {
4286+ nw = write(fd, p, nl);
4287+ } while ( nw < 0 && errno == EINTR );
4288+ if ( nw <= 0 ) break;
4289+ nl -= nw;
4290+ p += nw;
4291+ }
4292+
4293+ return n - nl;
4294+}
4295+
4296+int
4297+fd_printf (int fd, const char *format, ...)
4298+{
4299+ char buf[256];
4300+ va_list args;
4301+ int len;
4302+
4303+ va_start(args, format);
4304+ len = vsnprintf(buf, sizeof(buf), format, args);
4305+ buf[sizeof(buf) - 1] = '\0';
4306+ va_end(args);
4307+
4308+ return writen_ni(fd, buf, len);
4309+}
4310+
4311+void
4312+fatal (const char *format, ...)
4313+{
4314+ char *s, buf[256];
4315+ va_list args;
4316+ int len;
4317+
4318+ term_reset(STO);
4319+ term_reset(STI);
4320+
4321+ va_start(args, format);
4322+ len = vsnprintf(buf, sizeof(buf), format, args);
4323+ buf[sizeof(buf) - 1] = '\0';
4324+ va_end(args);
4325+
4326+ s = "\r\nFATAL: ";
4327+ writen_ni(STO, s, strlen(s));
4328+ writen_ni(STO, buf, len);
4329+ s = "\r\n";
4330+ writen_ni(STO, s, strlen(s));
4331+
4332+ /* wait a bit for output to drain */
4333+ sleep(1);
4334+
4335+#ifdef UUCP_LOCK_DIR
4336+ uucp_unlock();
4337+#endif
4338+
4339+ exit(EXIT_FAILURE);
4340+}
4341+
4342+#define cput(fd, c) do { int cl = c; write((fd), &(cl), 1); } while(0)
4343+
4344+int
4345+fd_readline (int fdi, int fdo, char *b, int bsz)
4346+{
4347+ int r;
4348+ unsigned char c;
4349+ unsigned char *bp, *bpe;
4350+
4351+ bp = b;
4352+ bpe = b + bsz - 1;
4353+
4354+ while (1) {
4355+ r = read(fdi, &c, 1);
4356+ if ( r <= 0 ) { r--; goto out; }
4357+
4358+ switch (c) {
4359+ case '\b':
4360+ if ( bp > (unsigned char *)b ) {
4361+ bp--;
4362+ cput(fdo, c); cput(fdo, ' '); cput(fdo, c);
4363+ } else {
4364+ cput(fdo, '\x07');
4365+ }
4366+ break;
4367+ case '\r':
4368+ *bp = '\0';
4369+ r = bp - (unsigned char *)b;
4370+ goto out;
4371+ default:
4372+ if ( bp < bpe ) { *bp++ = c; cput(fdo, c); }
4373+ else { cput(fdo, '\x07'); }
4374+ break;
4375+ }
4376+ }
4377+
4378+out:
4379+ return r;
4380+}
4381+
4382+#undef cput
4383+
4384+/**********************************************************************/
4385+
4386+int
4387+baud_up (int baud)
4388+{
4389+ if ( baud < 300 )
4390+ baud = 300;
4391+ else if ( baud == 38400 )
4392+ baud = 57600;
4393+ else
4394+ baud = baud * 2;
4395+ if ( baud > 115200 )
4396+ baud = 115200;
4397+
4398+ return baud;
4399+}
4400+
4401+int
4402+baud_down (int baud)
4403+{
4404+ if ( baud > 115200 )
4405+ baud = 115200;
4406+ else if ( baud == 57600 )
4407+ baud = 38400;
4408+ else
4409+ baud = baud / 2;
4410+
4411+ if ( baud < 300)
4412+ baud = 300;
4413+
4414+ return baud;
4415+}
4416+
4417+int
4418+flow_next (int flow, char **flow_str)
4419+{
4420+ switch(flow) {
4421+ case FC_NONE:
4422+ flow = FC_RTSCTS;
4423+ *flow_str = "RTS/CTS";
4424+ break;
4425+ case FC_RTSCTS:
4426+ flow = FC_XONXOFF;
4427+ *flow_str = "xon/xoff";
4428+ break;
4429+ case FC_XONXOFF:
4430+ flow = FC_NONE;
4431+ *flow_str = "none";
4432+ break;
4433+ default:
4434+ flow = FC_NONE;
4435+ *flow_str = "none";
4436+ break;
4437+ }
4438+
4439+ return flow;
4440+}
4441+
4442+int
4443+parity_next (int parity, char **parity_str)
4444+{
4445+ switch(parity) {
4446+ case P_NONE:
4447+ parity = P_EVEN;
4448+ *parity_str = "even";
4449+ break;
4450+ case P_EVEN:
4451+ parity = P_ODD;
4452+ *parity_str = "odd";
4453+ break;
4454+ case P_ODD:
4455+ parity = P_NONE;
4456+ *parity_str = "none";
4457+ break;
4458+ default:
4459+ parity = P_NONE;
4460+ *parity_str = "none";
4461+ break;
4462+ }
4463+
4464+ return parity;
4465+}
4466+
4467+int
4468+bits_next (int bits)
4469+{
4470+ bits++;
4471+ if (bits > 8) bits = 5;
4472+
4473+ return bits;
4474+}
4475+
4476+/**********************************************************************/
4477+
4478+void
4479+child_empty_handler (int signum)
4480+{
4481+}
4482+
4483+void
4484+establish_child_signal_handlers (void)
4485+{
4486+ struct sigaction empty_action;
4487+
4488+ /* Set up the structure to specify the "empty" action. */
4489+ empty_action.sa_handler = child_empty_handler;
4490+ sigemptyset (&empty_action.sa_mask);
4491+ empty_action.sa_flags = 0;
4492+
4493+ sigaction (SIGINT, &empty_action, NULL);
4494+ sigaction (SIGTERM, &empty_action, NULL);
4495+}
4496+
4497+int
4498+run_cmd(int fd, ...)
4499+{
4500+ pid_t pid;
4501+ sigset_t sigm, sigm_old;
4502+
4503+ /* block signals, let child establish its own handlers */
4504+ sigemptyset(&sigm);
4505+ sigaddset(&sigm, SIGTERM);
4506+ sigprocmask(SIG_BLOCK, &sigm, &sigm_old);
4507+
4508+ pid = fork();
4509+ if ( pid < 0 ) {
4510+ sigprocmask(SIG_SETMASK, &sigm_old, NULL);
4511+ fd_printf(STO, "*** cannot fork: %s\n", strerror(errno));
4512+ return -1;
4513+ } else if ( pid ) {
4514+ /* father: picocom */
4515+ int r;
4516+
4517+ /* reset the mask */
4518+ sigprocmask(SIG_SETMASK, &sigm_old, NULL);
4519+ /* wait for child to finish */
4520+ waitpid(pid, &r, 0);
4521+ /* reset terminal (back to raw mode) */
4522+ term_apply(STI);
4523+ /* check and report child return status */
4524+ if ( WIFEXITED(r) ) {
4525+ fd_printf(STO, "\r\n*** exit status: %d\r\n",
4526+ WEXITSTATUS(r));
4527+ return WEXITSTATUS(r);
4528+ } else {
4529+ fd_printf(STO, "\r\n*** abnormal termination: 0x%x\r\n", r);
4530+ return -1;
4531+ }
4532+ } else {
4533+ /* child: external program */
4534+ int r;
4535+ long fl;
4536+ char cmd[512];
4537+
4538+ establish_child_signal_handlers();
4539+ sigprocmask(SIG_SETMASK, &sigm_old, NULL);
4540+ /* unmanage terminal, and reset it to canonical mode */
4541+ term_remove(STI);
4542+ /* unmanage serial port fd, without reset */
4543+ term_erase(fd);
4544+ /* set serial port fd to blocking mode */
4545+ fl = fcntl(fd, F_GETFL);
4546+ fl &= ~O_NONBLOCK;
4547+ fcntl(fd, F_SETFL, fl);
4548+ /* connect stdin and stdout to serial port */
4549+ close(STI);
4550+ close(STO);
4551+ dup2(fd, STI);
4552+ dup2(fd, STO);
4553+ {
4554+ /* build command-line */
4555+ char *c, *ce;
4556+ const char *s;
4557+ int n;
4558+ va_list vls;
4559+
4560+ c = cmd;
4561+ ce = cmd + sizeof(cmd) - 1;
4562+ va_start(vls, fd);
4563+ while ( (s = va_arg(vls, const char *)) ) {
4564+ n = strlen(s);
4565+ if ( c + n + 1 >= ce ) break;
4566+ memcpy(c, s, n); c += n;
4567+ *c++ = ' ';
4568+ }
4569+ va_end(vls);
4570+ *c = '\0';
4571+ }
4572+ /* run extenral command */
4573+ fd_printf(STDERR_FILENO, "%s\n", cmd);
4574+ r = system(cmd);
4575+ if ( WIFEXITED(r) ) exit(WEXITSTATUS(r));
4576+ else exit(128);
4577+ }
4578+}
4579+
4580+/**********************************************************************/
4581+
4582+#define TTY_Q_SZ 256
4583+
4584+struct tty_q {
4585+ int len;
4586+ unsigned char buff[TTY_Q_SZ];
4587+} tty_q;
4588+
4589+/**********************************************************************/
4590+
4591+void
4592+loop(void)
4593+{
4594+ enum {
4595+ ST_COMMAND,
4596+ ST_TRANSPARENT
4597+ } state;
4598+ int dtr_up;
4599+ fd_set rdset, wrset;
4600+ int newbaud, newflow, newparity, newbits;
4601+ char *newflow_str, *newparity_str;
4602+ char fname[128];
4603+ int r, n;
4604+ unsigned char c;
4605+
4606+
4607+ tty_q.len = 0;
4608+ state = ST_TRANSPARENT;
4609+ dtr_up = 0;
4610+
4611+ for (;;) {
4612+ FD_ZERO(&rdset);
4613+ FD_ZERO(&wrset);
4614+ FD_SET(STI, &rdset);
4615+ FD_SET(tty_fd, &rdset);
4616+ if ( tty_q.len ) FD_SET(tty_fd, &wrset);
4617+
4618+ if (select(FD_SETSIZE, &rdset, &wrset, NULL, NULL) < 0)
4619+ fatal("select failed: %d : %s", errno, strerror(errno));
4620+
4621+ if ( FD_ISSET(STI, &rdset) ) {
4622+
4623+ /* read from terminal */
4624+
4625+ do {
4626+ n = read(STI, &c, 1);
4627+ } while (n < 0 && errno == EINTR);
4628+ if (n == 0)
4629+ fatal("stdin closed");
4630+ else if (n < 0)
4631+ fatal("read from stdin failed: %s", strerror(errno));
4632+
4633+ switch (state) {
4634+
4635+ case ST_COMMAND:
4636+ if ( c == opts.escape ) {
4637+ state = ST_TRANSPARENT;
4638+ /* pass the escape character down */
4639+ if (tty_q.len <= TTY_Q_SZ)
4640+ tty_q.buff[tty_q.len++] = c;
4641+ else
4642+ fd_printf(STO, "\x07");
4643+ break;
4644+ }
4645+ state = ST_TRANSPARENT;
4646+ switch (c) {
4647+ case KEY_EXIT:
4648+ return;
4649+ case KEY_QUIT:
4650+ term_set_hupcl(tty_fd, 0);
4651+ term_flush(tty_fd);
4652+ term_apply(tty_fd);
4653+ term_erase(tty_fd);
4654+ return;
4655+ case KEY_STATUS:
4656+ fd_printf(STO, "\r\n");
4657+ fd_printf(STO, "*** baud: %d\r\n", opts.baud);
4658+ fd_printf(STO, "*** flow: %s\r\n", opts.flow_str);
4659+ fd_printf(STO, "*** parity: %s\r\n", opts.parity_str);
4660+ fd_printf(STO, "*** databits: %d\r\n", opts.databits);
4661+ fd_printf(STO, "*** dtr: %s\r\n", dtr_up ? "up" : "down");
4662+ break;
4663+ case KEY_PULSE:
4664+ fd_printf(STO, "\r\n*** pulse DTR ***\r\n");
4665+ if ( term_pulse_dtr(tty_fd) < 0 )
4666+ fd_printf(STO, "*** FAILED\r\n");
4667+ break;
4668+ case KEY_TOGGLE:
4669+ if ( dtr_up )
4670+ r = term_lower_dtr(tty_fd);
4671+ else
4672+ r = term_raise_dtr(tty_fd);
4673+ if ( r >= 0 ) dtr_up = ! dtr_up;
4674+ fd_printf(STO, "\r\n*** DTR: %s ***\r\n",
4675+ dtr_up ? "up" : "down");
4676+ break;
4677+ case KEY_BAUD_UP:
4678+ newbaud = baud_up(opts.baud);
4679+ term_set_baudrate(tty_fd, newbaud);
4680+ tty_q.len = 0; term_flush(tty_fd);
4681+ if ( term_apply(tty_fd) >= 0 ) opts.baud = newbaud;
4682+ fd_printf(STO, "\r\n*** baud: %d ***\r\n", opts.baud);
4683+ break;
4684+ case KEY_BAUD_DN:
4685+ newbaud = baud_down(opts.baud);
4686+ term_set_baudrate(tty_fd, newbaud);
4687+ tty_q.len = 0; term_flush(tty_fd);
4688+ if ( term_apply(tty_fd) >= 0 ) opts.baud = newbaud;
4689+ fd_printf(STO, "\r\n*** baud: %d ***\r\n", opts.baud);
4690+ break;
4691+ case KEY_FLOW:
4692+ newflow = flow_next(opts.flow, &newflow_str);
4693+ term_set_flowcntrl(tty_fd, newflow);
4694+ tty_q.len = 0; term_flush(tty_fd);
4695+ if ( term_apply(tty_fd) >= 0 ) {
4696+ opts.flow = newflow;
4697+ opts.flow_str = newflow_str;
4698+ }
4699+ fd_printf(STO, "\r\n*** flow: %s ***\r\n", opts.flow_str);
4700+ break;
4701+ case KEY_PARITY:
4702+ newparity = parity_next(opts.parity, &newparity_str);
4703+ term_set_parity(tty_fd, newparity);
4704+ tty_q.len = 0; term_flush(tty_fd);
4705+ if ( term_apply(tty_fd) >= 0 ) {
4706+ opts.parity = newparity;
4707+ opts.parity_str = newparity_str;
4708+ }
4709+ fd_printf(STO, "\r\n*** parity: %s ***\r\n",
4710+ opts.parity_str);
4711+ break;
4712+ case KEY_BITS:
4713+ newbits = bits_next(opts.databits);
4714+ term_set_databits(tty_fd, newbits);
4715+ tty_q.len = 0; term_flush(tty_fd);
4716+ if ( term_apply(tty_fd) >= 0 ) opts.databits = newbits;
4717+ fd_printf(STO, "\r\n*** databits: %d ***\r\n",
4718+ opts.databits);
4719+ break;
4720+ case KEY_SEND:
4721+ fd_printf(STO, "\r\n*** file: ");
4722+ r = fd_readline(STI, STO, fname, sizeof(fname));
4723+ fd_printf(STO, "\r\n");
4724+ if ( r < -1 && errno == EINTR ) break;
4725+ if ( r <= -1 )
4726+ fatal("cannot read filename: %s", strerror(errno));
4727+ run_cmd(tty_fd, opts.send_cmd, fname, NULL);
4728+ break;
4729+ case KEY_RECEIVE:
4730+ fd_printf(STO, "*** file: ");
4731+ r = fd_readline(STI, STO, fname, sizeof(fname));
4732+ fd_printf(STO, "\r\n");
4733+ if ( r < -1 && errno == EINTR ) break;
4734+ if ( r <= -1 )
4735+ fatal("cannot read filename: %s", strerror(errno));
4736+ if ( fname[0] )
4737+ run_cmd(tty_fd, opts.send_cmd, fname, NULL);
4738+ else
4739+ run_cmd(tty_fd, opts.receive_cmd, NULL);
4740+ break;
4741+ case KEY_BREAK:
4742+ term_break(tty_fd);
4743+ fd_printf(STO, "\r\n*** break sent ***\r\n");
4744+ break;
4745+ default:
4746+ break;
4747+ }
4748+ break;
4749+
4750+ case ST_TRANSPARENT:
4751+ if ( c == opts.escape ) {
4752+ state = ST_COMMAND;
4753+ } else {
4754+ if (tty_q.len <= TTY_Q_SZ)
4755+ tty_q.buff[tty_q.len++] = c;
4756+ else
4757+ fd_printf(STO, "\x07");
4758+ }
4759+ break;
4760+
4761+ default:
4762+ assert(0);
4763+ break;
4764+ }
4765+ }
4766+
4767+ if ( FD_ISSET(tty_fd, &rdset) ) {
4768+
4769+ /* read from port */
4770+
4771+ do {
4772+ n = read(tty_fd, &c, 1);
4773+ } while (n < 0 && errno == EINTR);
4774+ if (n == 0)
4775+ fatal("term closed");
4776+ else if ( n < 0 )
4777+ fatal("read from term failed: %s", strerror(errno));
4778+
4779+ do {
4780+ n = write(STO, &c, 1);
4781+ } while ( errno == EAGAIN
4782+ || errno == EWOULDBLOCK
4783+ || errno == EINTR );
4784+ if ( n <= 0 )
4785+ fatal("write to stdout failed: %s", strerror(errno));
4786+ }
4787+
4788+ if ( FD_ISSET(tty_fd, &wrset) ) {
4789+
4790+ /* write to port */
4791+
4792+ do {
4793+ n = write(tty_fd, tty_q.buff, tty_q.len);
4794+ } while ( n < 0 && errno == EINTR );
4795+ if ( n <= 0 )
4796+ fatal("write to term failed: %s", strerror(errno));
4797+ memcpy(tty_q.buff, tty_q.buff + n, tty_q.len - n);
4798+ tty_q.len -= n;
4799+ }
4800+ }
4801+}
4802+
4803+/**********************************************************************/
4804+
4805+void
4806+deadly_handler(int signum)
4807+{
4808+ kill(0, SIGTERM);
4809+ sleep(1);
4810+#ifdef UUCP_LOCK_DIR
4811+ uucp_unlock();
4812+#endif
4813+ exit(EXIT_FAILURE);
4814+}
4815+
4816+void
4817+establish_signal_handlers (void)
4818+{
4819+ struct sigaction exit_action, ign_action;
4820+
4821+ /* Set up the structure to specify the exit action. */
4822+ exit_action.sa_handler = deadly_handler;
4823+ sigemptyset (&exit_action.sa_mask);
4824+ exit_action.sa_flags = 0;
4825+
4826+ /* Set up the structure to specify the ignore action. */
4827+ ign_action.sa_handler = SIG_IGN;
4828+ sigemptyset (&ign_action.sa_mask);
4829+ ign_action.sa_flags = 0;
4830+
4831+ sigaction (SIGTERM, &exit_action, NULL);
4832+
4833+ sigaction (SIGINT, &ign_action, NULL);
4834+ sigaction (SIGHUP, &ign_action, NULL);
4835+ sigaction (SIGALRM, &ign_action, NULL);
4836+ sigaction (SIGUSR1, &ign_action, NULL);
4837+ sigaction (SIGUSR2, &ign_action, NULL);
4838+ sigaction (SIGPIPE, &ign_action, NULL);
4839+}
4840+
4841+/**********************************************************************/
4842+
4843+void
4844+show_usage(char *name)
4845+{
4846+ char *s;
4847+
4848+ s = strrchr(name, '/');
4849+ s = s ? s+1 : name;
4850+
4851+ printf("picocom v%s\n", VERSION_STR);
4852+ printf("Usage is: %s [options] <tty device>\n", s);
4853+ printf("Options are:\n");
4854+ printf(" --<b>aud <baudrate>\n");
4855+ printf(" --<f>low s (=soft) | h (=hard) | n (=none)\n");
4856+ printf(" --<p>arity o (=odd) | e (=even) | n (=none)\n");
4857+ printf(" --<d>atabits 5 | 6 | 7 | 8\n");
4858+ printf(" --<e>scape <char>\n");
4859+ printf(" --no<i>nit\n");
4860+ printf(" --no<r>eset\n");
4861+ printf(" --no<l>ock\n");
4862+ printf(" --<s>end-cmd <command>\n");
4863+ printf(" --recei<v>e-cmd <command>\n");
4864+ printf(" --<h>elp\n");
4865+ printf("<?> indicates the equivalent short option.\n");
4866+ printf("Short options are prefixed by \"-\" instead of by \"--\".\n");
4867+}
4868+
4869+/**********************************************************************/
4870+
4871+void
4872+parse_args(int argc, char *argv[])
4873+{
4874+ static struct option longOptions[] =
4875+ {
4876+ {"receive-cmd", required_argument, 0, 'v'},
4877+ {"send-cmd", required_argument, 0, 's'},
4878+ {"escape", required_argument, 0, 'e'},
4879+ {"noinit", no_argument, 0, 'i'},
4880+ {"noreset", no_argument, 0, 'r'},
4881+ {"nolock", no_argument, 0, 'l'},
4882+ {"flow", required_argument, 0, 'f'},
4883+ {"baud", required_argument, 0, 'b'},
4884+ {"parity", required_argument, 0, 'p'},
4885+ {"databits", required_argument, 0, 'd'},
4886+ {"help", no_argument, 0, 'h'},
4887+ {0, 0, 0, 0}
4888+ };
4889+
4890+ while (1) {
4891+ int optionIndex = 0;
4892+ int c;
4893+
4894+ /* no default error messages printed. */
4895+ opterr = 0;
4896+
4897+ c = getopt_long(argc, argv, "hirls:r:e:f:b:p:d:",
4898+ longOptions, &optionIndex);
4899+
4900+ if (c < 0)
4901+ break;
4902+
4903+ switch (c) {
4904+ case 's':
4905+ strncpy(opts.send_cmd, optarg, sizeof(opts.send_cmd));
4906+ opts.send_cmd[sizeof(opts.send_cmd) - 1] = '\0';
4907+ break;
4908+ case 'v':
4909+ strncpy(opts.receive_cmd, optarg, sizeof(opts.receive_cmd));
4910+ opts.receive_cmd[sizeof(opts.receive_cmd) - 1] = '\0';
4911+ break;
4912+ case 'i':
4913+ opts.noinit = 1;
4914+ break;
4915+ case 'r':
4916+ opts.noreset = 1;
4917+ break;
4918+ case 'l':
4919+ opts.nolock = 1;
4920+ break;
4921+ case 'e':
4922+ if ( isupper(optarg[0]) )
4923+ opts.escape = optarg[0] - 'A' + 1;
4924+ else
4925+ opts.escape = optarg[0] - 'a' + 1;
4926+ break;
4927+ case 'f':
4928+ switch (optarg[0]) {
4929+ case 'X':
4930+ case 'x':
4931+ opts.flow_str = "xon/xoff";
4932+ opts.flow = FC_XONXOFF;
4933+ break;
4934+ case 'H':
4935+ case 'h':
4936+ opts.flow_str = "RTS/CTS";
4937+ opts.flow = FC_RTSCTS;
4938+ break;
4939+ case 'N':
4940+ case 'n':
4941+ opts.flow_str = "none";
4942+ opts.flow = FC_NONE;
4943+ break;
4944+ default:
4945+ fprintf(stderr, "--flow '%c' ignored.\n", optarg[0]);
4946+ fprintf(stderr, "--flow can be one off: 'x', 'h', or 'n'\n");
4947+ break;
4948+ }
4949+ break;
4950+ case 'b':
4951+ opts.baud = atoi(optarg);
4952+ break;
4953+ case 'p':
4954+ switch (optarg[0]) {
4955+ case 'e':
4956+ opts.parity_str = "even";
4957+ opts.parity = P_EVEN;
4958+ break;
4959+ case 'o':
4960+ opts.parity_str = "odd";
4961+ opts.parity = P_ODD;
4962+ break;
4963+ case 'n':
4964+ opts.parity_str = "none";
4965+ opts.parity = P_NONE;
4966+ break;
4967+ default:
4968+ fprintf(stderr, "--parity '%c' ignored.\n", optarg[0]);
4969+ fprintf(stderr, "--parity can be one off: 'o', 'e', or 'n'\n");
4970+ break;
4971+ }
4972+ break;
4973+ case 'd':
4974+ switch (optarg[0]) {
4975+ case '5':
4976+ opts.databits = 5;
4977+ break;
4978+ case '6':
4979+ opts.databits = 6;
4980+ break;
4981+ case '7':
4982+ opts.databits = 7;
4983+ break;
4984+ case '8':
4985+ opts.databits = 8;
4986+ break;
4987+ default:
4988+ fprintf(stderr, "--databits '%c' ignored.\n", optarg[0]);
4989+ fprintf(stderr, "--databits can be one off: 5, 6, 7 or 8\n");
4990+ break;
4991+ }
4992+ break;
4993+ case 'h':
4994+ show_usage(argv[0]);
4995+ exit(EXIT_SUCCESS);
4996+ case '?':
4997+ default:
4998+ fprintf(stderr, "Unrecognized option.\n");
4999+ fprintf(stderr, "Run with '--help'.\n");
5000+ exit(EXIT_FAILURE);
5001+ }
5002+ } /* while */
5003+
5004+ if ( (argc - optind) < 1) {
5005+ fprintf(stderr, "No port given\n");
5006+ exit(EXIT_FAILURE);
5007+ }
5008+ strncpy(opts.port, argv[optind], sizeof(opts.port) - 1);
5009+ opts.port[sizeof(opts.port) - 1] = '\0';
5010+
5011+ printf("picocom v%s\n", VERSION_STR);
5012+ printf("\n");
5013+ printf("port is : %s\n", opts.port);
5014+ printf("flowcontrol : %s\n", opts.flow_str);
5015+ printf("baudrate is : %d\n", opts.baud);
5016+ printf("parity is : %s\n", opts.parity_str);
5017+ printf("databits are : %d\n", opts.databits);
5018+ printf("escape is : C-%c\n", 'a' + opts.escape - 1);
5019+ printf("noinit is : %s\n", opts.noinit ? "yes" : "no");
5020+ printf("noreset is : %s\n", opts.noreset ? "yes" : "no");
5021+ printf("nolock is : %s\n", opts.nolock ? "yes" : "no");
5022+ printf("send_cmd is : %s\n", opts.send_cmd);
5023+ printf("receive_cmd is : %s\n", opts.receive_cmd);
5024+ printf("\n");
5025+}
5026+
5027+/**********************************************************************/
5028+
5029+int
5030+main(int argc, char *argv[])
5031+{
5032+ int r;
5033+
5034+ parse_args(argc, argv);
5035+
5036+ establish_signal_handlers();
5037+
5038+ r = term_lib_init();
5039+ if ( r < 0 )
5040+ fatal("term_init failed: %s", term_strerror(term_errno, errno));
5041+
5042+#ifdef UUCP_LOCK_DIR
5043+ if ( ! opts.nolock ) uucp_lockname(UUCP_LOCK_DIR, opts.port);
5044+ if ( uucp_lock() < 0 )
5045+ fatal("cannot lock %s: %s", opts.port, strerror(errno));
5046+#endif
5047+
5048+ tty_fd = open(opts.port, O_RDWR | O_NONBLOCK);
5049+ if (tty_fd < 0)
5050+ fatal("cannot open %s: %s", opts.port, strerror(errno));
5051+
5052+ if ( opts.noinit ) {
5053+ r = term_add(tty_fd);
5054+ } else {
5055+ r = term_set(tty_fd,
5056+ 1, /* raw mode. */
5057+ opts.baud, /* baud rate. */
5058+ opts.parity, /* parity. */
5059+ opts.databits, /* data bits. */
5060+ opts.flow, /* flow control. */
5061+ 1, /* local or modem */
5062+ !opts.noreset); /* hup-on-close. */
5063+ }
5064+ if ( r < 0 )
5065+ fatal("failed to add device %s: %s",
5066+ opts.port, term_strerror(term_errno, errno));
5067+ r = term_apply(tty_fd);
5068+ if ( r < 0 )
5069+ fatal("failed to config device %s: %s",
5070+ opts.port, term_strerror(term_errno, errno));
5071+
5072+ r = term_add(STI);
5073+ if ( r < 0 )
5074+ fatal("failed to add I/O device: %s",
5075+ term_strerror(term_errno, errno));
5076+ term_set_raw(STI);
5077+ r = term_apply(STI);
5078+ if ( r < 0 )
5079+ fatal("failed to set I/O device to raw mode: %s",
5080+ term_strerror(term_errno, errno));
5081+
5082+ fd_printf(STO, "Terminal ready\r\n");
5083+ loop();
5084+
5085+ fd_printf(STO, "\r\n");
5086+ if ( opts.noreset ) {
5087+ fd_printf(STO, "Skipping tty reset...\r\n");
5088+ term_erase(tty_fd);
5089+ }
5090+
5091+ fd_printf(STO, "Thanks for using picocom\r\n");
5092+ /* wait a bit for output to drain */
5093+ sleep(1);
5094+
5095+#ifdef UUCP_LOCK_DIR
5096+ uucp_unlock();
5097+#endif
5098+
5099+ return EXIT_SUCCESS;
5100+}
5101+
5102+/**********************************************************************/
5103+
5104+/*
5105+ * Local Variables:
5106+ * mode:c
5107+ * tab-width: 4
5108+ * c-basic-offset: 4
5109+ * End:
5110+ */
5111Index: user/blkfin-apps/picocom/NEWS
5112===================================================================
5113--- user/blkfin-apps/picocom/NEWS (revision 0)
5114+++ user/blkfin-apps/picocom/NEWS (revision 0)
5115@@ -0,0 +1,24 @@
5116+
5117+version 1.1
5118+
5119+ - Added example shell-scripts that start picocom preconfigured for
5120+ ASCII, Z-MODEM, Y-MODEM, and X-MODEM file transfers.
5121+
5122+ - Better signal handling.
5123+
5124+ - Added the "send" and "receive" commands. They can be used to
5125+ transmit and receive files via external programs that implement
5126+ the respective protocols (like the programs "sz", "rz", etc).
5127+
5128+ - Added the "status" command, which shows the currently active
5129+ program options, like the current baud rate, the current
5130+ flow-control settings, etc. Only options that can be controlled
5131+ online are shown.
5132+
5133+ - Slight code restructuring.
5134+
5135+ - Minor bug fixes.
5136+
5137+version 1.0
5138+
5139+ - Initial release.
5140Index: user/blkfin-apps/picocom/Makefile
5141===================================================================
5142--- user/blkfin-apps/picocom/Makefile (revision 0)
5143+++ user/blkfin-apps/picocom/Makefile (revision 0)
5144@@ -0,0 +1,46 @@
5145+
5146+VERSION=1.4
5147+
5148+# CC = gcc
5149+CPPFLAGS+=-DVERSION_STR=\"$(VERSION)\" -DUUCP_LOCK_DIR=\"/var/lock\"
5150+CFLAGS += -Wall
5151+
5152+# LD = gcc
5153+
5154+all: picocom
5155+
5156+picocom : picocom.o term.o
5157+# $(LD) $(LDFLAGS) -o $@ $+ $(LDLIBS)
5158+
5159+picocom.o : picocom.c term.h
5160+term.o : term.c term.h
5161+
5162+doc : picocom.8 picocom.8.html picocom.8.ps
5163+
5164+changes :
5165+ svn log -v . > CHANGES
5166+
5167+picocom.8 : picocom.8.xml
5168+ xmlmp2man < $< > $@
5169+
5170+picocom.8.html : picocom.8.xml
5171+ xmlmp2html < $< > $@
5172+
5173+picocom.8.ps : picocom.8
5174+ groff -mandoc -Tps $< > $@
5175+
5176+clean:
5177+ rm -f picocom.o term.o
5178+ rm -f *~
5179+ rm -f \#*\#
5180+ rm -f *.gdb
5181+ rm -f picocom
5182+
5183+realclean: distclean
5184+ rm -f picocom.8
5185+ rm -f picocom.8.html
5186+ rm -f picocom.8.ps
5187+ rm -f CHANGES
5188+
5189+romfs:
5190+ $(ROMFSINST) picocom /bin
5191Index: user/blkfin-apps/Makefile
5192===================================================================
5193--- user/blkfin-apps/Makefile (revision 5006)
5194+++ user/blkfin-apps/Makefile (working copy)
5195@@ -26,6 +26,7 @@ dir_$(CONFIG_USER_THREADSTACK)
5196 dir_$(CONFIG_USER_BLACKFIN_ASTERISK) += asterisk
5197 dir_$(CONFIG_USER_USBUTILS) += usbutils
5198 dir_$(CONFIG_USER_BLUEZ) += bluez-utils
5199+dir_$(CONFIG_USER_PICOCOM) += picocom
5200
5201 all %::
5202 for i in $(dir_y) ; do make -C $$i $@ || exit $$? ; done