blob: 36d1289c5031c814366ce900a78d332db5653062 [file] [log] [blame]
Guido van Rossum470be141995-03-17 16:07:09 +00001\section{Built-in Module \sectcode{ctb}}
Guido van Rossume47da0a1997-07-17 16:34:52 +00002\label{module-ctb}
Jack Jansendcb0a9b1995-03-01 14:05:27 +00003\bimodindex{ctb}
Fred Drake19479911998-02-13 06:58:54 +00004\setindexsubitem{(in module ctb)}
Jack Jansendcb0a9b1995-03-01 14:05:27 +00005
6This module provides a partial interface to the Macintosh
7Communications Toolbox. Currently, only Connection Manager tools are
Guido van Rossum96628a91995-04-10 11:34:00 +00008supported. It may not be available in all Mac Python versions.
Jack Jansendcb0a9b1995-03-01 14:05:27 +00009
10\begin{datadesc}{error}
11The exception raised on errors.
12\end{datadesc}
13
14\begin{datadesc}{cmData}
15\dataline{cmCntl}
16\dataline{cmAttn}
17Flags for the \var{channel} argument of the \var{Read} and \var{Write}
18methods.
19\end{datadesc}
20
21\begin{datadesc}{cmFlagsEOM}
22End-of-message flag for \var{Read} and \var{Write}.
23\end{datadesc}
24
25\begin{datadesc}{choose*}
26Values returned by \var{Choose}.
27\end{datadesc}
28
29\begin{datadesc}{cmStatus*}
30Bits in the status as returned by \var{Status}.
31\end{datadesc}
32
33\begin{funcdesc}{available}{}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000034Return 1 if the communication toolbox is available, zero otherwise.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000035\end{funcdesc}
36
37\begin{funcdesc}{CMNew}{name\, sizes}
38Create a connection object using the connection tool named
39\var{name}. \var{sizes} is a 6-tuple given buffer sizes for data in,
40data out, control in, control out, attention in and attention out.
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000041Alternatively, passing \code{None} will result in default buffer sizes.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000042\end{funcdesc}
43
44\subsection{connection object}
45For all connection methods that take a \var{timeout} argument, a value
46of \code{-1} is indefinite, meaning that the command runs to completion.
47
Fred Drake19479911998-02-13 06:58:54 +000048\setindexsubitem{(connection object attribute)}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000049
50\begin{datadesc}{callback}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000051If this member is set to a value other than \code{None} it should point
Jack Jansendcb0a9b1995-03-01 14:05:27 +000052to a function accepting a single argument (the connection
53object). This will make all connection object methods work
54asynchronously, with the callback routine being called upon
55completion.
56
Fred Drakeaf8a0151998-01-14 14:51:31 +000057\emph{Note:} for reasons beyond my understanding the callback routine
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000058is currently never called. You are advised against using asynchronous
Jack Jansendcb0a9b1995-03-01 14:05:27 +000059calls for the time being.
60\end{datadesc}
61
62
Fred Drake19479911998-02-13 06:58:54 +000063\setindexsubitem{(connection object method)}
Guido van Rossum470be141995-03-17 16:07:09 +000064
Jack Jansendcb0a9b1995-03-01 14:05:27 +000065\begin{funcdesc}{Open}{timeout}
66Open an outgoing connection, waiting at most \var{timeout} seconds for
67the connection to be established.
68\end{funcdesc}
69
70\begin{funcdesc}{Listen}{timeout}
71Wait for an incoming connection. Stop waiting after \var{timeout}
72seconds. This call is only meaningful to some tools.
73\end{funcdesc}
74
75\begin{funcdesc}{accept}{yesno}
76Accept (when \var{yesno} is non-zero) or reject an incoming call after
77\var{Listen} returned.
78\end{funcdesc}
79
80\begin{funcdesc}{Close}{timeout\, now}
81Close a connection. When \var{now} is zero, the close is orderly
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000082(i.e.\ outstanding output is flushed, etc.)\ with a timeout of
Jack Jansendcb0a9b1995-03-01 14:05:27 +000083\var{timeout} seconds. When \var{now} is non-zero the close is
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000084immediate, discarding output.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000085\end{funcdesc}
86
87\begin{funcdesc}{Read}{len\, chan\, timeout}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000088Read \var{len} bytes, or until \var{timeout} seconds have passed, from
Jack Jansendcb0a9b1995-03-01 14:05:27 +000089the channel \var{chan} (which is one of \var{cmData}, \var{cmCntl} or
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000090\var{cmAttn}). Return a 2-tuple:\ the data read and the end-of-message
Jack Jansendcb0a9b1995-03-01 14:05:27 +000091flag.
92\end{funcdesc}
93
94\begin{funcdesc}{Write}{buf\, chan\, timeout\, eom}
95Write \var{buf} to channel \var{chan}, aborting after \var{timeout}
96seconds. When \var{eom} has the value \var{cmFlagsEOM} an
97end-of-message indicator will be written after the data (if this
98concept has a meaning for this communication tool). The method returns
99the number of bytes written.
100\end{funcdesc}
101
102\begin{funcdesc}{Status}{}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000103Return connection status as the 2-tuple \code{(\var{sizes},
104\var{flags})}. \var{sizes} is a 6-tuple giving the actual buffer sizes used
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000105(see \var{CMNew}), \var{flags} is a set of bits describing the state
106of the connection.
107\end{funcdesc}
108
109\begin{funcdesc}{GetConfig}{}
110Return the configuration string of the communication tool. These
111configuration strings are tool-dependent, but usually easily parsed
112and modified.
113\end{funcdesc}
114
115\begin{funcdesc}{SetConfig}{str}
116Set the configuration string for the tool. The strings are parsed
117left-to-right, with later values taking precedence. This means
118individual configuration parameters can be modified by simply appending
119something like \code{'baud 4800'} to the end of the string returned by
120\var{GetConfig} and passing that to this method. The method returns
121the number of characters actually parsed by the tool before it
122encountered an error (or completed successfully).
123\end{funcdesc}
124
125\begin{funcdesc}{Choose}{}
126Present the user with a dialog to choose a communication tool and
127configure it. If there is an outstanding connection some choices (like
128selecting a different tool) may cause the connection to be
129aborted. The return value (one of the \var{choose*} constants) will
130indicate this.
131\end{funcdesc}
132
133\begin{funcdesc}{Idle}{}
134Give the tool a chance to use the processor. You should call this
135method regularly.
136\end{funcdesc}
137
138\begin{funcdesc}{Abort}{}
139Abort an outstanding asynchronous \var{Open} or \var{Listen}.
140\end{funcdesc}
141
142\begin{funcdesc}{Reset}{}
143Reset a connection. Exact meaning depends on the tool.
144\end{funcdesc}
145
146\begin{funcdesc}{Break}{length}
147Send a break. Whether this means anything, what it means and
148interpretation of the \var{length} parameter depend on the tool in
149use.
150\end{funcdesc}