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