diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2003-11-19 14:34:18 +0000 |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2003-11-19 14:34:18 +0000 |
commit | 28ecf70db57828db2ca279643bf9aeca7662f35c (patch) | |
tree | 09b7767bbc411f85313b58d6fe7e5e67d9392973 /Mac/Lib/mactty.py | |
parent | 6045b9c93511c767f6cfa2d2fa299c76181acd9b (diff) | |
download | cpython-git-28ecf70db57828db2ca279643bf9aeca7662f35c.tar.gz |
Getting rid of support for MacOS9 and earlier. This is the first step,
and the biggest in size, but probably the easiest. Hunting through the
source code comes next.
Diffstat (limited to 'Mac/Lib/mactty.py')
-rw-r--r-- | Mac/Lib/mactty.py | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/Mac/Lib/mactty.py b/Mac/Lib/mactty.py deleted file mode 100644 index e09a50c8f6..0000000000 --- a/Mac/Lib/mactty.py +++ /dev/null @@ -1,74 +0,0 @@ -# -# mactty module - Use a terminal line as communications channel. -# -# Note that this module is not very complete or well-designed, but it -# will have to serve until I have time to write something better. A unix -# module with the same API is available too, contact me (jack@cwi.nl) -# if you need it. -# -# Usage: -# t = Tty(toolname) -# t.raw() Set in raw/no-echo mode -# t.baudrate(rate) Set baud rate -# t.reset() Back to normal -# t.read(len) Read up to 'len' bytes (but often reads less) -# t.readall(len) Read 'len' bytes -# t.timedread(len,tout) Read upto 'len' bytes, or until 'tout' seconds idle -# t.getmode() Get parameters as a string -# t.setmode(args) Set parameters -# -# Jack Jansen, CWI, January 1997 -# -import ctb -DEBUG=1 - -class Tty: - def __init__(self, name=None): - self.connection = ctb.CMNew('Serial Tool', (10000, 10000, 0, 0, 0, 0)) - #self.orig_data = self.connection.GetConfig() - #if name: - # self.connection.SetConfig(self.orig_data + ' Port "%s"'%name) - self.connection.Open(10) - sizes, status = self.connection.Status() - - def getmode(self): - return self.connection.GetConfig() - - def setmode(self, mode): - length = self.connection.SetConfig(mode) - if length != 0 and length != len(mode): - raise 'SetConfig Error', (mode[:length], mode[length:]) - - def raw(self): - pass - - def baudrate(self, rate): - self.setmode(self.getmode()+' baud %d'%rate) - - def reset(self): - self.setmode(self.orig_data) - - def readall(self, length): - data = '' - while len(data) < length: - data = data + self.read(length-len(data)) - return data - - def timedread(self,length, timeout): - self.connection.Idle() - data, eom = self.connection.Read(length, ctb.cmData, timeout*10) - if DEBUG: - print 'Timedread(%d, %d)->%s'%(length, timeout, `data`) - return data - - def read(self, length): - return self.timedread(length, 0x3fffffff) - - def write(self, data): - if DEBUG: - print 'Write(%s)'%`data` - while data: - self.connection.Idle() - done = self.connection.Write(data, ctb.cmData, 0x3fffffff, 0) - self.connection.Idle() - data = data[done:] |