blob: 9950a410f2680e1d7c575ef1769977af06b873ea [file] [log] [blame]
Fred Drakec817e271998-08-10 18:40:22 +00001\section{\module{ctb} ---
Fred Drakef6863c11999-03-02 16:37:17 +00002 Interface to the Communications Tool Box}
Fred Drakefe7f3bc1998-07-23 17:55:31 +00003
Fred Drakef6863c11999-03-02 16:37:17 +00004\declaremodule{builtin}{ctb}
5 \platform{Mac}
Fred Drakef459a092000-10-14 04:49:36 +00006\modulesynopsis{Interfaces to the Communications Tool Box. Only the
7 Connection Manager is supported.}
Fred Drakefe7f3bc1998-07-23 17:55:31 +00008
Jack Jansendcb0a9b1995-03-01 14:05:27 +00009
10This module provides a partial interface to the Macintosh
11Communications Toolbox. Currently, only Connection Manager tools are
Jack Jansen827713a2001-09-11 20:18:04 +000012supported.
13
14This module is only available under MacOS9 or earlier, in classic PPC
15MacPython.
Fred Drake41788db1998-04-04 06:23:02 +000016\index{Communications Toolbox, Macintosh}
17\index{Macintosh Communications Toolbox}
18\index{Connection Manager}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000019
20\begin{datadesc}{error}
21The exception raised on errors.
22\end{datadesc}
23
24\begin{datadesc}{cmData}
25\dataline{cmCntl}
26\dataline{cmAttn}
Fred Drake41788db1998-04-04 06:23:02 +000027Flags for the \var{channel} argument of the \method{Read()} and
28\method{Write()} methods.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000029\end{datadesc}
30
31\begin{datadesc}{cmFlagsEOM}
Fred Drake41788db1998-04-04 06:23:02 +000032End-of-message flag for \method{Read()} and \method{Write()}.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000033\end{datadesc}
34
35\begin{datadesc}{choose*}
Fred Drake41788db1998-04-04 06:23:02 +000036Values returned by \method{Choose()}.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000037\end{datadesc}
38
39\begin{datadesc}{cmStatus*}
Fred Drake41788db1998-04-04 06:23:02 +000040Bits in the status as returned by \method{Status()}.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000041\end{datadesc}
42
43\begin{funcdesc}{available}{}
Fred Drake41788db1998-04-04 06:23:02 +000044Return \code{1} if the Communication Toolbox is available, zero otherwise.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000045\end{funcdesc}
46
Fred Drakecce10901998-03-17 06:33:25 +000047\begin{funcdesc}{CMNew}{name, sizes}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000048Create a connection object using the connection tool named
49\var{name}. \var{sizes} is a 6-tuple given buffer sizes for data in,
50data out, control in, control out, attention in and attention out.
Fred Drake41788db1998-04-04 06:23:02 +000051Alternatively, passing \code{None} for \var{sizes} will result in
52default buffer sizes.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000053\end{funcdesc}
54
Fred Drakef6863c11999-03-02 16:37:17 +000055
56\subsection{Connection Objects \label{connection-object}}
Fred Drake41788db1998-04-04 06:23:02 +000057
Jack Jansendcb0a9b1995-03-01 14:05:27 +000058For all connection methods that take a \var{timeout} argument, a value
59of \code{-1} is indefinite, meaning that the command runs to completion.
60
Fred Drake41788db1998-04-04 06:23:02 +000061\begin{memberdesc}[connection]{callback}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000062If this member is set to a value other than \code{None} it should point
Jack Jansendcb0a9b1995-03-01 14:05:27 +000063to a function accepting a single argument (the connection
64object). This will make all connection object methods work
65asynchronously, with the callback routine being called upon
66completion.
67
Fred Drakeaf8a0151998-01-14 14:51:31 +000068\emph{Note:} for reasons beyond my understanding the callback routine
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000069is currently never called. You are advised against using asynchronous
Jack Jansendcb0a9b1995-03-01 14:05:27 +000070calls for the time being.
Fred Drake41788db1998-04-04 06:23:02 +000071\end{memberdesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000072
73
Fred Drake41788db1998-04-04 06:23:02 +000074\begin{methoddesc}[connection]{Open}{timeout}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000075Open an outgoing connection, waiting at most \var{timeout} seconds for
76the connection to be established.
Fred Drake41788db1998-04-04 06:23:02 +000077\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000078
Fred Drake41788db1998-04-04 06:23:02 +000079\begin{methoddesc}[connection]{Listen}{timeout}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000080Wait for an incoming connection. Stop waiting after \var{timeout}
81seconds. This call is only meaningful to some tools.
Fred Drake41788db1998-04-04 06:23:02 +000082\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000083
Fred Drake41788db1998-04-04 06:23:02 +000084\begin{methoddesc}[connection]{accept}{yesno}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000085Accept (when \var{yesno} is non-zero) or reject an incoming call after
Fred Drake41788db1998-04-04 06:23:02 +000086\method{Listen()} returned.
87\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000088
Fred Drake41788db1998-04-04 06:23:02 +000089\begin{methoddesc}[connection]{Close}{timeout, now}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000090Close a connection. When \var{now} is zero, the close is orderly
Fred Drake15e33d82001-07-06 06:49:32 +000091(outstanding output is flushed, etc.)\ with a timeout of
Jack Jansendcb0a9b1995-03-01 14:05:27 +000092\var{timeout} seconds. When \var{now} is non-zero the close is
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000093immediate, discarding output.
Fred Drake41788db1998-04-04 06:23:02 +000094\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000095
Fred Drake41788db1998-04-04 06:23:02 +000096\begin{methoddesc}[connection]{Read}{len, chan, timeout}
97Read \var{len} bytes, or until \var{timeout} seconds have passed, from
98the channel \var{chan} (which is one of \constant{cmData},
99\constant{cmCntl} or \constant{cmAttn}). Return a 2-tuple:\ the data
100read and the end-of-message flag, \constant{cmFlagsEOM}.
101\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000102
Fred Drake41788db1998-04-04 06:23:02 +0000103\begin{methoddesc}[connection]{Write}{buf, chan, timeout, eom}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000104Write \var{buf} to channel \var{chan}, aborting after \var{timeout}
Fred Drake41788db1998-04-04 06:23:02 +0000105seconds. When \var{eom} has the value \constant{cmFlagsEOM}, an
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000106end-of-message indicator will be written after the data (if this
107concept has a meaning for this communication tool). The method returns
108the number of bytes written.
Fred Drake41788db1998-04-04 06:23:02 +0000109\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000110
Fred Drake41788db1998-04-04 06:23:02 +0000111\begin{methoddesc}[connection]{Status}{}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000112Return connection status as the 2-tuple \code{(\var{sizes},
113\var{flags})}. \var{sizes} is a 6-tuple giving the actual buffer sizes used
Fred Drake41788db1998-04-04 06:23:02 +0000114(see \function{CMNew()}), \var{flags} is a set of bits describing the state
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000115of the connection.
Fred Drake41788db1998-04-04 06:23:02 +0000116\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000117
Fred Drake41788db1998-04-04 06:23:02 +0000118\begin{methoddesc}[connection]{GetConfig}{}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000119Return the configuration string of the communication tool. These
120configuration strings are tool-dependent, but usually easily parsed
121and modified.
Fred Drake41788db1998-04-04 06:23:02 +0000122\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000123
Fred Drake41788db1998-04-04 06:23:02 +0000124\begin{methoddesc}[connection]{SetConfig}{str}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000125Set the configuration string for the tool. The strings are parsed
126left-to-right, with later values taking precedence. This means
127individual configuration parameters can be modified by simply appending
128something like \code{'baud 4800'} to the end of the string returned by
Fred Drake41788db1998-04-04 06:23:02 +0000129\method{GetConfig()} and passing that to this method. The method returns
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000130the number of characters actually parsed by the tool before it
131encountered an error (or completed successfully).
Fred Drake41788db1998-04-04 06:23:02 +0000132\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000133
Fred Drake41788db1998-04-04 06:23:02 +0000134\begin{methoddesc}[connection]{Choose}{}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000135Present the user with a dialog to choose a communication tool and
136configure it. If there is an outstanding connection some choices (like
137selecting a different tool) may cause the connection to be
Fred Drake41788db1998-04-04 06:23:02 +0000138aborted. The return value (one of the \constant{choose*} constants) will
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000139indicate this.
Fred Drake41788db1998-04-04 06:23:02 +0000140\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000141
Fred Drake41788db1998-04-04 06:23:02 +0000142\begin{methoddesc}[connection]{Idle}{}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000143Give the tool a chance to use the processor. You should call this
144method regularly.
Fred Drake41788db1998-04-04 06:23:02 +0000145\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000146
Fred Drake41788db1998-04-04 06:23:02 +0000147\begin{methoddesc}[connection]{Abort}{}
148Abort an outstanding asynchronous \method{Open()} or \method{Listen()}.
149\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000150
Fred Drake41788db1998-04-04 06:23:02 +0000151\begin{methoddesc}[connection]{Reset}{}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000152Reset a connection. Exact meaning depends on the tool.
Fred Drake41788db1998-04-04 06:23:02 +0000153\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000154
Fred Drake41788db1998-04-04 06:23:02 +0000155\begin{methoddesc}[connection]{Break}{length}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000156Send a break. Whether this means anything, what it means and
Fred Drake41788db1998-04-04 06:23:02 +0000157interpretation of the \var{length} parameter depends on the tool in
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000158use.
Fred Drake41788db1998-04-04 06:23:02 +0000159\end{methoddesc}