blob: de2e8650c7e9d4c209eb584a5e2a90237d007014 [file] [log] [blame]
Fred Drakec817e271998-08-10 18:40:22 +00001\section{\module{ctb} ---
2 Interface to the Communications Tool Box.}
Fred Drakefe7f3bc1998-07-23 17:55:31 +00003\declaremodule{builtin}{ctb}
4
5\modulesynopsis{Interfaces to the Communications Tool Box. Only the Connection
Fred Drakec817e271998-08-10 18:40:22 +00006Manager is supported.}
Fred Drakefe7f3bc1998-07-23 17:55:31 +00007
Jack Jansendcb0a9b1995-03-01 14:05:27 +00008
9This module provides a partial interface to the Macintosh
10Communications Toolbox. Currently, only Connection Manager tools are
Guido van Rossum96628a91995-04-10 11:34:00 +000011supported. It may not be available in all Mac Python versions.
Fred Drake41788db1998-04-04 06:23:02 +000012\index{Communications Toolbox, Macintosh}
13\index{Macintosh Communications Toolbox}
14\index{Connection Manager}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000015
16\begin{datadesc}{error}
17The exception raised on errors.
18\end{datadesc}
19
20\begin{datadesc}{cmData}
21\dataline{cmCntl}
22\dataline{cmAttn}
Fred Drake41788db1998-04-04 06:23:02 +000023Flags for the \var{channel} argument of the \method{Read()} and
24\method{Write()} methods.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000025\end{datadesc}
26
27\begin{datadesc}{cmFlagsEOM}
Fred Drake41788db1998-04-04 06:23:02 +000028End-of-message flag for \method{Read()} and \method{Write()}.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000029\end{datadesc}
30
31\begin{datadesc}{choose*}
Fred Drake41788db1998-04-04 06:23:02 +000032Values returned by \method{Choose()}.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000033\end{datadesc}
34
35\begin{datadesc}{cmStatus*}
Fred Drake41788db1998-04-04 06:23:02 +000036Bits in the status as returned by \method{Status()}.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000037\end{datadesc}
38
39\begin{funcdesc}{available}{}
Fred Drake41788db1998-04-04 06:23:02 +000040Return \code{1} if the Communication Toolbox is available, zero otherwise.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000041\end{funcdesc}
42
Fred Drakecce10901998-03-17 06:33:25 +000043\begin{funcdesc}{CMNew}{name, sizes}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000044Create a connection object using the connection tool named
45\var{name}. \var{sizes} is a 6-tuple given buffer sizes for data in,
46data out, control in, control out, attention in and attention out.
Fred Drake41788db1998-04-04 06:23:02 +000047Alternatively, passing \code{None} for \var{sizes} will result in
48default buffer sizes.
Jack Jansendcb0a9b1995-03-01 14:05:27 +000049\end{funcdesc}
50
51\subsection{connection object}
Fred Drake41788db1998-04-04 06:23:02 +000052\label{connection-object}
53
Jack Jansendcb0a9b1995-03-01 14:05:27 +000054For all connection methods that take a \var{timeout} argument, a value
55of \code{-1} is indefinite, meaning that the command runs to completion.
56
Fred Drake41788db1998-04-04 06:23:02 +000057\begin{memberdesc}[connection]{callback}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000058If this member is set to a value other than \code{None} it should point
Jack Jansendcb0a9b1995-03-01 14:05:27 +000059to a function accepting a single argument (the connection
60object). This will make all connection object methods work
61asynchronously, with the callback routine being called upon
62completion.
63
Fred Drakeaf8a0151998-01-14 14:51:31 +000064\emph{Note:} for reasons beyond my understanding the callback routine
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000065is currently never called. You are advised against using asynchronous
Jack Jansendcb0a9b1995-03-01 14:05:27 +000066calls for the time being.
Fred Drake41788db1998-04-04 06:23:02 +000067\end{memberdesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000068
69
Fred Drake41788db1998-04-04 06:23:02 +000070\begin{methoddesc}[connection]{Open}{timeout}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000071Open an outgoing connection, waiting at most \var{timeout} seconds for
72the connection to be established.
Fred Drake41788db1998-04-04 06:23:02 +000073\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000074
Fred Drake41788db1998-04-04 06:23:02 +000075\begin{methoddesc}[connection]{Listen}{timeout}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000076Wait for an incoming connection. Stop waiting after \var{timeout}
77seconds. This call is only meaningful to some tools.
Fred Drake41788db1998-04-04 06:23:02 +000078\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000079
Fred Drake41788db1998-04-04 06:23:02 +000080\begin{methoddesc}[connection]{accept}{yesno}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000081Accept (when \var{yesno} is non-zero) or reject an incoming call after
Fred Drake41788db1998-04-04 06:23:02 +000082\method{Listen()} returned.
83\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000084
Fred Drake41788db1998-04-04 06:23:02 +000085\begin{methoddesc}[connection]{Close}{timeout, now}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000086Close a connection. When \var{now} is zero, the close is orderly
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000087(i.e.\ outstanding output is flushed, etc.)\ with a timeout of
Jack Jansendcb0a9b1995-03-01 14:05:27 +000088\var{timeout} seconds. When \var{now} is non-zero the close is
Guido van Rossum6bb1adc1995-03-13 10:03:32 +000089immediate, discarding output.
Fred Drake41788db1998-04-04 06:23:02 +000090\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000091
Fred Drake41788db1998-04-04 06:23:02 +000092\begin{methoddesc}[connection]{Read}{len, chan, timeout}
93Read \var{len} bytes, or until \var{timeout} seconds have passed, from
94the channel \var{chan} (which is one of \constant{cmData},
95\constant{cmCntl} or \constant{cmAttn}). Return a 2-tuple:\ the data
96read and the end-of-message flag, \constant{cmFlagsEOM}.
97\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +000098
Fred Drake41788db1998-04-04 06:23:02 +000099\begin{methoddesc}[connection]{Write}{buf, chan, timeout, eom}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000100Write \var{buf} to channel \var{chan}, aborting after \var{timeout}
Fred Drake41788db1998-04-04 06:23:02 +0000101seconds. When \var{eom} has the value \constant{cmFlagsEOM}, an
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000102end-of-message indicator will be written after the data (if this
103concept has a meaning for this communication tool). The method returns
104the number of bytes written.
Fred Drake41788db1998-04-04 06:23:02 +0000105\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000106
Fred Drake41788db1998-04-04 06:23:02 +0000107\begin{methoddesc}[connection]{Status}{}
Guido van Rossum6bb1adc1995-03-13 10:03:32 +0000108Return connection status as the 2-tuple \code{(\var{sizes},
109\var{flags})}. \var{sizes} is a 6-tuple giving the actual buffer sizes used
Fred Drake41788db1998-04-04 06:23:02 +0000110(see \function{CMNew()}), \var{flags} is a set of bits describing the state
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000111of the connection.
Fred Drake41788db1998-04-04 06:23:02 +0000112\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000113
Fred Drake41788db1998-04-04 06:23:02 +0000114\begin{methoddesc}[connection]{GetConfig}{}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000115Return the configuration string of the communication tool. These
116configuration strings are tool-dependent, but usually easily parsed
117and modified.
Fred Drake41788db1998-04-04 06:23:02 +0000118\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000119
Fred Drake41788db1998-04-04 06:23:02 +0000120\begin{methoddesc}[connection]{SetConfig}{str}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000121Set the configuration string for the tool. The strings are parsed
122left-to-right, with later values taking precedence. This means
123individual configuration parameters can be modified by simply appending
124something like \code{'baud 4800'} to the end of the string returned by
Fred Drake41788db1998-04-04 06:23:02 +0000125\method{GetConfig()} and passing that to this method. The method returns
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000126the number of characters actually parsed by the tool before it
127encountered an error (or completed successfully).
Fred Drake41788db1998-04-04 06:23:02 +0000128\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000129
Fred Drake41788db1998-04-04 06:23:02 +0000130\begin{methoddesc}[connection]{Choose}{}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000131Present the user with a dialog to choose a communication tool and
132configure it. If there is an outstanding connection some choices (like
133selecting a different tool) may cause the connection to be
Fred Drake41788db1998-04-04 06:23:02 +0000134aborted. The return value (one of the \constant{choose*} constants) will
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000135indicate this.
Fred Drake41788db1998-04-04 06:23:02 +0000136\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000137
Fred Drake41788db1998-04-04 06:23:02 +0000138\begin{methoddesc}[connection]{Idle}{}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000139Give the tool a chance to use the processor. You should call this
140method regularly.
Fred Drake41788db1998-04-04 06:23:02 +0000141\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000142
Fred Drake41788db1998-04-04 06:23:02 +0000143\begin{methoddesc}[connection]{Abort}{}
144Abort an outstanding asynchronous \method{Open()} or \method{Listen()}.
145\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000146
Fred Drake41788db1998-04-04 06:23:02 +0000147\begin{methoddesc}[connection]{Reset}{}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000148Reset a connection. Exact meaning depends on the tool.
Fred Drake41788db1998-04-04 06:23:02 +0000149\end{methoddesc}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000150
Fred Drake41788db1998-04-04 06:23:02 +0000151\begin{methoddesc}[connection]{Break}{length}
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000152Send a break. Whether this means anything, what it means and
Fred Drake41788db1998-04-04 06:23:02 +0000153interpretation of the \var{length} parameter depends on the tool in
Jack Jansendcb0a9b1995-03-01 14:05:27 +0000154use.
Fred Drake41788db1998-04-04 06:23:02 +0000155\end{methoddesc}