Added ref to Misc/NEWS file; added hint to run regen script on Linux.
[python/dscho.git] / Mac / Lib / test / ctbtest.py
blob5364c44b4af717ca2de45acf0c1acbce7fe02bae
2 # Simple test program for ctb module: emulate a terminal.
4 import ctb
5 import macconsole
6 import sys
8 def cb(err):
9 print 'Done, err=', err
11 def 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)
23 l = ctb.CMNew('Serial Tool', None)
24 l.Open(0)
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
41 main()