blob: 5364c44b4af717ca2de45acf0c1acbce7fe02bae [file] [log] [blame]
Jack Jansen3b0a5cd1995-03-07 16:40:18 +00001#
2# Simple test program for ctb module: emulate a terminal.
3#
4import ctb
5import macconsole
6import sys
7
8def cb(err):
9 print 'Done, err=', err
10
11def main():
12 if not ctb.available():
13 print 'Communications Toolbox not available'
14 sys.exit(1)
15# c = macconsole.copen('Terminal window')
16 print 'Minimal terminal emulator V1.0'
17 print '(type @ to exit)'
18 print
19 c = macconsole.fopen(sys.stdin)
20 f = sys.stdin
21 c.setmode(macconsole.C_RAW)
22
23 l = ctb.CMNew('Serial Tool', None)
24 l.Open(0)
25
26 while 1:
27 l.Idle()
28 d = f.read(1)
29 if d == '@':
30 break
31 if d:
32 l.Write(d, ctb.cmData, -1, 0)
33 l.Idle()
34 d, dummy = l.Read(1000, ctb.cmData, 0)
35 if d:
36 f.write(d)
37 f.flush()
38 l.Close(-1, 1)
39 del l
40
Jack Jansenb696b251995-12-21 15:38:14 +000041main()