1 \section{Built-in Module
\module{ctb
}}
5 This module provides a partial interface to the Macintosh
6 Communications Toolbox. Currently, only Connection Manager tools are
7 supported. It may not be available in all Mac Python versions.
8 \index{Communications Toolbox, Macintosh
}
9 \index{Macintosh Communications Toolbox
}
10 \index{Connection Manager
}
12 \begin{datadesc
}{error
}
13 The exception raised on errors.
16 \begin{datadesc
}{cmData
}
19 Flags for the
\var{channel
} argument of the
\method{Read()
} and
20 \method{Write()
} methods.
23 \begin{datadesc
}{cmFlagsEOM
}
24 End-of-message flag for
\method{Read()
} and
\method{Write()
}.
27 \begin{datadesc
}{choose*
}
28 Values returned by
\method{Choose()
}.
31 \begin{datadesc
}{cmStatus*
}
32 Bits in the status as returned by
\method{Status()
}.
35 \begin{funcdesc
}{available
}{}
36 Return
\code{1} if the Communication Toolbox is available, zero otherwise.
39 \begin{funcdesc
}{CMNew
}{name, sizes
}
40 Create a connection object using the connection tool named
41 \var{name
}.
\var{sizes
} is a
6-tuple given buffer sizes for data in,
42 data out, control in, control out, attention in and attention out.
43 Alternatively, passing
\code{None
} for
\var{sizes
} will result in
47 \subsection{connection object
}
48 \label{connection-object
}
50 For all connection methods that take a
\var{timeout
} argument, a value
51 of
\code{-
1} is indefinite, meaning that the command runs to completion.
53 \begin{memberdesc
}[connection
]{callback
}
54 If this member is set to a value other than
\code{None
} it should point
55 to a function accepting a single argument (the connection
56 object). This will make all connection object methods work
57 asynchronously, with the callback routine being called upon
60 \emph{Note:
} for reasons beyond my understanding the callback routine
61 is currently never called. You are advised against using asynchronous
62 calls for the time being.
66 \begin{methoddesc
}[connection
]{Open
}{timeout
}
67 Open an outgoing connection, waiting at most
\var{timeout
} seconds for
68 the connection to be established.
71 \begin{methoddesc
}[connection
]{Listen
}{timeout
}
72 Wait for an incoming connection. Stop waiting after
\var{timeout
}
73 seconds. This call is only meaningful to some tools.
76 \begin{methoddesc
}[connection
]{accept
}{yesno
}
77 Accept (when
\var{yesno
} is non-zero) or reject an incoming call after
78 \method{Listen()
} returned.
81 \begin{methoddesc
}[connection
]{Close
}{timeout, now
}
82 Close a connection. When
\var{now
} is zero, the close is orderly
83 (i.e.\ outstanding output is flushed, etc.)\ with a timeout of
84 \var{timeout
} seconds. When
\var{now
} is non-zero the close is
85 immediate, discarding output.
88 \begin{methoddesc
}[connection
]{Read
}{len, chan, timeout
}
89 Read
\var{len
} bytes, or until
\var{timeout
} seconds have passed, from
90 the channel
\var{chan
} (which is one of
\constant{cmData
},
91 \constant{cmCntl
} or
\constant{cmAttn
}). Return a
2-tuple:\ the data
92 read and the end-of-message flag,
\constant{cmFlagsEOM
}.
95 \begin{methoddesc
}[connection
]{Write
}{buf, chan, timeout, eom
}
96 Write
\var{buf
} to channel
\var{chan
}, aborting after
\var{timeout
}
97 seconds. When
\var{eom
} has the value
\constant{cmFlagsEOM
}, an
98 end-of-message indicator will be written after the data (if this
99 concept has a meaning for this communication tool). The method returns
100 the number of bytes written.
103 \begin{methoddesc
}[connection
]{Status
}{}
104 Return connection status as the
2-tuple
\code{(
\var{sizes
},
105 \var{flags
})
}.
\var{sizes
} is a
6-tuple giving the actual buffer sizes used
106 (see
\function{CMNew()
}),
\var{flags
} is a set of bits describing the state
110 \begin{methoddesc
}[connection
]{GetConfig
}{}
111 Return the configuration string of the communication tool. These
112 configuration strings are tool-dependent, but usually easily parsed
116 \begin{methoddesc
}[connection
]{SetConfig
}{str
}
117 Set the configuration string for the tool. The strings are parsed
118 left-to-right, with later values taking precedence. This means
119 individual configuration parameters can be modified by simply appending
120 something like
\code{'baud
4800'
} to the end of the string returned by
121 \method{GetConfig()
} and passing that to this method. The method returns
122 the number of characters actually parsed by the tool before it
123 encountered an error (or completed successfully).
126 \begin{methoddesc
}[connection
]{Choose
}{}
127 Present the user with a dialog to choose a communication tool and
128 configure it. If there is an outstanding connection some choices (like
129 selecting a different tool) may cause the connection to be
130 aborted. The return value (one of the
\constant{choose*
} constants) will
134 \begin{methoddesc
}[connection
]{Idle
}{}
135 Give the tool a chance to use the processor. You should call this
139 \begin{methoddesc
}[connection
]{Abort
}{}
140 Abort an outstanding asynchronous
\method{Open()
} or
\method{Listen()
}.
143 \begin{methoddesc
}[connection
]{Reset
}{}
144 Reset a connection. Exact meaning depends on the tool.
147 \begin{methoddesc
}[connection
]{Break
}{length
}
148 Send a break. Whether this means anything, what it means and
149 interpretation of the
\var{length
} parameter depends on the tool in