| 1 | '\" |
| 2 | '\" Copyright (c) 1993 The Regents of the University of California. |
| 3 | '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. |
| 4 | '\" |
| 5 | '\" See the file "license.terms" for information on usage and redistribution |
| 6 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 7 | '\" |
| 8 | '\" RCS: @(#) $Id: open.n,v 1.16.2.3 2005/04/19 16:30:21 davygrvy Exp $ |
| 9 | '\" |
| 10 | '\" The definitions below are for supplemental macros used in Tcl/Tk |
| 11 | '\" manual entries. |
| 12 | '\" |
| 13 | '\" .AP type name in/out ?indent? |
| 14 | '\" Start paragraph describing an argument to a library procedure. |
| 15 | '\" type is type of argument (int, etc.), in/out is either "in", "out", |
| 16 | '\" or "in/out" to describe whether procedure reads or modifies arg, |
| 17 | '\" and indent is equivalent to second arg of .IP (shouldn't ever be |
| 18 | '\" needed; use .AS below instead) |
| 19 | '\" |
| 20 | '\" .AS ?type? ?name? |
| 21 | '\" Give maximum sizes of arguments for setting tab stops. Type and |
| 22 | '\" name are examples of largest possible arguments that will be passed |
| 23 | '\" to .AP later. If args are omitted, default tab stops are used. |
| 24 | '\" |
| 25 | '\" .BS |
| 26 | '\" Start box enclosure. From here until next .BE, everything will be |
| 27 | '\" enclosed in one large box. |
| 28 | '\" |
| 29 | '\" .BE |
| 30 | '\" End of box enclosure. |
| 31 | '\" |
| 32 | '\" .CS |
| 33 | '\" Begin code excerpt. |
| 34 | '\" |
| 35 | '\" .CE |
| 36 | '\" End code excerpt. |
| 37 | '\" |
| 38 | '\" .VS ?version? ?br? |
| 39 | '\" Begin vertical sidebar, for use in marking newly-changed parts |
| 40 | '\" of man pages. The first argument is ignored and used for recording |
| 41 | '\" the version when the .VS was added, so that the sidebars can be |
| 42 | '\" found and removed when they reach a certain age. If another argument |
| 43 | '\" is present, then a line break is forced before starting the sidebar. |
| 44 | '\" |
| 45 | '\" .VE |
| 46 | '\" End of vertical sidebar. |
| 47 | '\" |
| 48 | '\" .DS |
| 49 | '\" Begin an indented unfilled display. |
| 50 | '\" |
| 51 | '\" .DE |
| 52 | '\" End of indented unfilled display. |
| 53 | '\" |
| 54 | '\" .SO |
| 55 | '\" Start of list of standard options for a Tk widget. The |
| 56 | '\" options follow on successive lines, in four columns separated |
| 57 | '\" by tabs. |
| 58 | '\" |
| 59 | '\" .SE |
| 60 | '\" End of list of standard options for a Tk widget. |
| 61 | '\" |
| 62 | '\" .OP cmdName dbName dbClass |
| 63 | '\" Start of description of a specific option. cmdName gives the |
| 64 | '\" option's name as specified in the class command, dbName gives |
| 65 | '\" the option's name in the option database, and dbClass gives |
| 66 | '\" the option's class in the option database. |
| 67 | '\" |
| 68 | '\" .UL arg1 arg2 |
| 69 | '\" Print arg1 underlined, then print arg2 normally. |
| 70 | '\" |
| 71 | '\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $ |
| 72 | '\" |
| 73 | '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. |
| 74 | .if t .wh -1.3i ^B |
| 75 | .nr ^l \n(.l |
| 76 | .ad b |
| 77 | '\" # Start an argument description |
| 78 | .de AP |
| 79 | .ie !"\\$4"" .TP \\$4 |
| 80 | .el \{\ |
| 81 | . ie !"\\$2"" .TP \\n()Cu |
| 82 | . el .TP 15 |
| 83 | .\} |
| 84 | .ta \\n()Au \\n()Bu |
| 85 | .ie !"\\$3"" \{\ |
| 86 | \&\\$1 \\fI\\$2\\fP (\\$3) |
| 87 | .\".b |
| 88 | .\} |
| 89 | .el \{\ |
| 90 | .br |
| 91 | .ie !"\\$2"" \{\ |
| 92 | \&\\$1 \\fI\\$2\\fP |
| 93 | .\} |
| 94 | .el \{\ |
| 95 | \&\\fI\\$1\\fP |
| 96 | .\} |
| 97 | .\} |
| 98 | .. |
| 99 | '\" # define tabbing values for .AP |
| 100 | .de AS |
| 101 | .nr )A 10n |
| 102 | .if !"\\$1"" .nr )A \\w'\\$1'u+3n |
| 103 | .nr )B \\n()Au+15n |
| 104 | .\" |
| 105 | .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n |
| 106 | .nr )C \\n()Bu+\\w'(in/out)'u+2n |
| 107 | .. |
| 108 | .AS Tcl_Interp Tcl_CreateInterp in/out |
| 109 | '\" # BS - start boxed text |
| 110 | '\" # ^y = starting y location |
| 111 | '\" # ^b = 1 |
| 112 | .de BS |
| 113 | .br |
| 114 | .mk ^y |
| 115 | .nr ^b 1u |
| 116 | .if n .nf |
| 117 | .if n .ti 0 |
| 118 | .if n \l'\\n(.lu\(ul' |
| 119 | .if n .fi |
| 120 | .. |
| 121 | '\" # BE - end boxed text (draw box now) |
| 122 | .de BE |
| 123 | .nf |
| 124 | .ti 0 |
| 125 | .mk ^t |
| 126 | .ie n \l'\\n(^lu\(ul' |
| 127 | .el \{\ |
| 128 | .\" Draw four-sided box normally, but don't draw top of |
| 129 | .\" box if the box started on an earlier page. |
| 130 | .ie !\\n(^b-1 \{\ |
| 131 | \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' |
| 132 | .\} |
| 133 | .el \}\ |
| 134 | \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' |
| 135 | .\} |
| 136 | .\} |
| 137 | .fi |
| 138 | .br |
| 139 | .nr ^b 0 |
| 140 | .. |
| 141 | '\" # VS - start vertical sidebar |
| 142 | '\" # ^Y = starting y location |
| 143 | '\" # ^v = 1 (for troff; for nroff this doesn't matter) |
| 144 | .de VS |
| 145 | .if !"\\$2"" .br |
| 146 | .mk ^Y |
| 147 | .ie n 'mc \s12\(br\s0 |
| 148 | .el .nr ^v 1u |
| 149 | .. |
| 150 | '\" # VE - end of vertical sidebar |
| 151 | .de VE |
| 152 | .ie n 'mc |
| 153 | .el \{\ |
| 154 | .ev 2 |
| 155 | .nf |
| 156 | .ti 0 |
| 157 | .mk ^t |
| 158 | \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' |
| 159 | .sp -1 |
| 160 | .fi |
| 161 | .ev |
| 162 | .\} |
| 163 | .nr ^v 0 |
| 164 | .. |
| 165 | '\" # Special macro to handle page bottom: finish off current |
| 166 | '\" # box/sidebar if in box/sidebar mode, then invoked standard |
| 167 | '\" # page bottom macro. |
| 168 | .de ^B |
| 169 | .ev 2 |
| 170 | 'ti 0 |
| 171 | 'nf |
| 172 | .mk ^t |
| 173 | .if \\n(^b \{\ |
| 174 | .\" Draw three-sided box if this is the box's first page, |
| 175 | .\" draw two sides but no top otherwise. |
| 176 | .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c |
| 177 | .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c |
| 178 | .\} |
| 179 | .if \\n(^v \{\ |
| 180 | .nr ^x \\n(^tu+1v-\\n(^Yu |
| 181 | \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c |
| 182 | .\} |
| 183 | .bp |
| 184 | 'fi |
| 185 | .ev |
| 186 | .if \\n(^b \{\ |
| 187 | .mk ^y |
| 188 | .nr ^b 2 |
| 189 | .\} |
| 190 | .if \\n(^v \{\ |
| 191 | .mk ^Y |
| 192 | .\} |
| 193 | .. |
| 194 | '\" # DS - begin display |
| 195 | .de DS |
| 196 | .RS |
| 197 | .nf |
| 198 | .sp |
| 199 | .. |
| 200 | '\" # DE - end display |
| 201 | .de DE |
| 202 | .fi |
| 203 | .RE |
| 204 | .sp |
| 205 | .. |
| 206 | '\" # SO - start of list of standard options |
| 207 | .de SO |
| 208 | .SH "STANDARD OPTIONS" |
| 209 | .LP |
| 210 | .nf |
| 211 | .ta 5.5c 11c |
| 212 | .ft B |
| 213 | .. |
| 214 | '\" # SE - end of list of standard options |
| 215 | .de SE |
| 216 | .fi |
| 217 | .ft R |
| 218 | .LP |
| 219 | See the \\fBoptions\\fR manual entry for details on the standard options. |
| 220 | .. |
| 221 | '\" # OP - start of full description for a single option |
| 222 | .de OP |
| 223 | .LP |
| 224 | .nf |
| 225 | .ta 4c |
| 226 | Command-Line Name: \\fB\\$1\\fR |
| 227 | Database Name: \\fB\\$2\\fR |
| 228 | Database Class: \\fB\\$3\\fR |
| 229 | .fi |
| 230 | .IP |
| 231 | .. |
| 232 | '\" # CS - begin code excerpt |
| 233 | .de CS |
| 234 | .RS |
| 235 | .nf |
| 236 | .ta .25i .5i .75i 1i |
| 237 | .. |
| 238 | '\" # CE - end code excerpt |
| 239 | .de CE |
| 240 | .fi |
| 241 | .RE |
| 242 | .. |
| 243 | .de UL |
| 244 | \\$1\l'|0\(ul'\\$2 |
| 245 | .. |
| 246 | .TH open n 8.3 Tcl "Tcl Built-In Commands" |
| 247 | .BS |
| 248 | '\" Note: do not modify the .SH NAME line immediately below! |
| 249 | .SH NAME |
| 250 | open \- Open a file-based or command pipeline channel |
| 251 | .SH SYNOPSIS |
| 252 | .sp |
| 253 | \fBopen \fIfileName\fR |
| 254 | .br |
| 255 | \fBopen \fIfileName access\fR |
| 256 | .br |
| 257 | \fBopen \fIfileName access permissions\fR |
| 258 | .BE |
| 259 | |
| 260 | .SH DESCRIPTION |
| 261 | .PP |
| 262 | This command opens a file, serial port, or command pipeline and returns a |
| 263 | channel identifier that may be used in future invocations of commands like |
| 264 | \fBread\fR, \fBputs\fR, and \fBclose\fR. |
| 265 | If the first character of \fIfileName\fR is not \fB|\fR then |
| 266 | the command opens a file: |
| 267 | \fIfileName\fR gives the name of the file to open, and it must conform to the |
| 268 | conventions described in the \fBfilename\fR manual entry. |
| 269 | .PP |
| 270 | The \fIaccess\fR argument, if present, indicates the way in which the file |
| 271 | (or command pipeline) is to be accessed. |
| 272 | In the first form \fIaccess\fR may have any of the following values: |
| 273 | .TP 15 |
| 274 | \fBr\fR |
| 275 | Open the file for reading only; the file must already exist. This is the |
| 276 | default value if \fIaccess\fR is not specified. |
| 277 | .TP 15 |
| 278 | \fBr+\fR |
| 279 | Open the file for both reading and writing; the file must |
| 280 | already exist. |
| 281 | .TP 15 |
| 282 | \fBw\fR |
| 283 | Open the file for writing only. Truncate it if it exists. If it doesn't |
| 284 | exist, create a new file. |
| 285 | .TP 15 |
| 286 | \fBw+\fR |
| 287 | Open the file for reading and writing. Truncate it if it exists. |
| 288 | If it doesn't exist, create a new file. |
| 289 | .TP 15 |
| 290 | \fBa\fR |
| 291 | Open the file for writing only. If the file doesn't exist, |
| 292 | create a new empty file. |
| 293 | Set the initial access position to the end of the file. |
| 294 | .TP 15 |
| 295 | \fBa+\fR |
| 296 | Open the file for reading and writing. If the file doesn't exist, |
| 297 | create a new empty file. |
| 298 | Set the initial access position to the end of the file. |
| 299 | .PP |
| 300 | In the second form, \fIaccess\fR consists of a list of any of the |
| 301 | following flags, all of which have the standard POSIX meanings. |
| 302 | One of the flags must be either \fBRDONLY\fR, \fBWRONLY\fR or \fBRDWR\fR. |
| 303 | .TP 15 |
| 304 | \fBRDONLY\fR |
| 305 | Open the file for reading only. |
| 306 | .TP 15 |
| 307 | \fBWRONLY\fR |
| 308 | Open the file for writing only. |
| 309 | .TP 15 |
| 310 | \fBRDWR\fR |
| 311 | Open the file for both reading and writing. |
| 312 | .TP 15 |
| 313 | \fBAPPEND\fR |
| 314 | Set the file pointer to the end of the file prior to each write. |
| 315 | .TP 15 |
| 316 | \fBCREAT\fR |
| 317 | Create the file if it doesn't already exist (without this flag it |
| 318 | is an error for the file not to exist). |
| 319 | .TP 15 |
| 320 | \fBEXCL\fR |
| 321 | If \fBCREAT\fR is also specified, an error is returned if the |
| 322 | file already exists. |
| 323 | .TP 15 |
| 324 | \fBNOCTTY\fR |
| 325 | If the file is a terminal device, this flag prevents the file from |
| 326 | becoming the controlling terminal of the process. |
| 327 | .TP 15 |
| 328 | \fBNONBLOCK\fR |
| 329 | Prevents the process from blocking while opening the file, and |
| 330 | possibly in subsequent I/O operations. The exact behavior of |
| 331 | this flag is system- and device-dependent; its use is discouraged |
| 332 | (it is better to use the \fBfconfigure\fR command to put a file |
| 333 | in nonblocking mode). |
| 334 | For details refer to your system documentation on the \fBopen\fR system |
| 335 | call's \fBO_NONBLOCK\fR flag. |
| 336 | .TP 15 |
| 337 | \fBTRUNC\fR |
| 338 | If the file exists it is truncated to zero length. |
| 339 | .PP |
| 340 | If a new file is created as part of opening it, \fIpermissions\fR |
| 341 | (an integer) is used to set the permissions for the new file in |
| 342 | conjunction with the process's file mode creation mask. |
| 343 | \fIPermissions\fR defaults to 0666. |
| 344 | .PP |
| 345 | Note that if you are going to be reading or writing binary data from |
| 346 | the channel created by this command, you should use the |
| 347 | \fBfconfigure\fR command to change the \fB-translation\fR option of |
| 348 | the channel to \fBbinary\fR before transferring any binary data. This |
| 349 | is in contrast to the ``b'' character passed as part of the equivalent |
| 350 | of the \fIaccess\fR parameter to some versions of the C library |
| 351 | \fIfopen()\fR function. |
| 352 | |
| 353 | .SH "COMMAND PIPELINES" |
| 354 | .PP |
| 355 | If the first character of \fIfileName\fR is ``|'' then the |
| 356 | remaining characters of \fIfileName\fR are treated as a list of arguments |
| 357 | that describe a command pipeline to invoke, in the same style as the |
| 358 | arguments for \fBexec\fR. |
| 359 | In this case, the channel identifier returned by \fBopen\fR may be used |
| 360 | to write to the command's input pipe or read from its output pipe, |
| 361 | depending on the value of \fIaccess\fR. |
| 362 | If write-only access is used (e.g. \fIaccess\fR is \fBw\fR), then |
| 363 | standard output for the pipeline is directed to the current standard |
| 364 | output unless overridden by the command. |
| 365 | If read-only access is used (e.g. \fIaccess\fR is \fBr\fR), |
| 366 | standard input for the pipeline is taken from the current standard |
| 367 | input unless overridden by the command. |
| 368 | The id of the spawned process is accessible through the \fBpid\fR |
| 369 | command, using the channel id returned by \fBopen\fR as argument. |
| 370 | .PP |
| 371 | If the command (or one of the commands) executed in the command |
| 372 | pipeline returns an error (according to the definition in \fBexec\fR), |
| 373 | a Tcl error is generated when \fBclose\fR is called on the channel |
| 374 | unless the pipeline is in non-blocking mode then no exit status is |
| 375 | returned (a silent \fBclose\fR with -blocking 0). |
| 376 | .PP |
| 377 | It is often useful to use the \fBfileevent\fR command with pipelines |
| 378 | so other processing may happen at the same time as running the command |
| 379 | in the background. |
| 380 | .VS 8.4 |
| 381 | .SH "SERIAL COMMUNICATIONS" |
| 382 | .PP |
| 383 | If \fIfileName\fR refers to a serial port, then the specified serial port |
| 384 | is opened and initialized in a platform-dependent manner. Acceptable |
| 385 | values for the \fIfileName\fR to use to open a serial port are described in |
| 386 | the PORTABILITY ISSUES section. |
| 387 | .PP |
| 388 | The \fBfconfigure\fR command can be used to query and set additional |
| 389 | configuration options specific to serial ports (where supported): |
| 390 | .TP |
| 391 | \fB\-mode\fR \fIbaud\fB,\fIparity\fB,\fIdata\fB,\fIstop\fR |
| 392 | This option is a set of 4 comma-separated values: the baud rate, parity, |
| 393 | number of data bits, and number of stop bits for this serial port. The |
| 394 | \fIbaud\fR rate is a simple integer that specifies the connection speed. |
| 395 | \fIParity\fR is one of the following letters: \fBn\fR, \fBo\fR, \fBe\fR, |
| 396 | \fBm\fR, \fBs\fR; respectively signifying the parity options of ``none'', |
| 397 | ``odd'', ``even'', ``mark'', or ``space''. \fIData\fR is the number of |
| 398 | data bits and should be an integer from 5 to 8, while \fIstop\fR is the |
| 399 | number of stop bits and should be the integer 1 or 2. |
| 400 | .TP |
| 401 | \fB\-handshake\fR \fItype\fR |
| 402 | (Windows and Unix). This option is used to setup automatic handshake |
| 403 | control. Note that not all handshake types maybe supported by your operating |
| 404 | system. The \fItype\fR parameter is case-independent. |
| 405 | .sp |
| 406 | If \fItype\fR is \fBnone\fR then any handshake is switched off. |
| 407 | \fBrtscts\fR activates hardware handshake. Hardware handshake signals |
| 408 | are described below. |
| 409 | For software handshake \fBxonxoff\fR the handshake characters can be redefined |
| 410 | with \fB-xchar\fR. |
| 411 | An additional hardware handshake \fBdtrdsr\fR is available only under Windows. |
| 412 | There is no default handshake configuration, the initial value depends |
| 413 | on your operating system settings. |
| 414 | The \fB-handshake\fR option cannot be queried. |
| 415 | .TP |
| 416 | \fB\-queue\fR |
| 417 | (Windows and Unix). The \fB-queue\fR option can only be queried. |
| 418 | It returns a list of two integers representing the current number |
| 419 | of bytes in the input and output queue respectively. |
| 420 | .TP |
| 421 | \fB\-timeout\fR \fImsec\fR |
| 422 | (Windows and Unix). This option is used to set the timeout for blocking |
| 423 | read operations. It specifies the maximum interval between the |
| 424 | reception of two bytes in milliseconds. |
| 425 | For Unix systems the granularity is 100 milliseconds. |
| 426 | The \fB-timeout\fR option does not affect write operations or |
| 427 | nonblocking reads. |
| 428 | This option cannot be queried. |
| 429 | .TP |
| 430 | \fB\-ttycontrol\fR \fI{signal boolean signal boolean ...}\fR |
| 431 | (Windows and Unix). This option is used to setup the handshake |
| 432 | output lines (see below) permanently or to send a BREAK over the serial line. |
| 433 | The \fIsignal\fR names are case-independent. |
| 434 | \fB{RTS 1 DTR 0}\fR sets the RTS output to high and the DTR output to low. |
| 435 | The BREAK condition (see below) is enabled and disabled with \fB{BREAK 1}\fR and |
| 436 | \fB{BREAK 0}\fR respectively. |
| 437 | It's not a good idea to change the \fBRTS\fR (or \fBDTR\fR) signal |
| 438 | with active hardware handshake \fBrtscts\fR (or \fBdtrdsr\fR). |
| 439 | The result is unpredictable. |
| 440 | The \fB-ttycontrol\fR option cannot be queried. |
| 441 | .TP |
| 442 | \fB\-ttystatus\fR |
| 443 | (Windows and Unix). The \fB-ttystatus\fR option can only be |
| 444 | queried. It returns the current modem status and handshake input signals |
| 445 | (see below). |
| 446 | The result is a list of signal,value pairs with a fixed order, |
| 447 | e.g. \fB{CTS 1 DSR 0 RING 1 DCD 0}\fR. |
| 448 | The \fIsignal\fR names are returned upper case. |
| 449 | .TP |
| 450 | \fB\-xchar\fR \fI{xonChar xoffChar}\fR |
| 451 | (Windows and Unix). This option is used to query or change the software |
| 452 | handshake characters. Normally the operating system default should be |
| 453 | DC1 (0x11) and DC3 (0x13) representing the ASCII standard |
| 454 | XON and XOFF characters. |
| 455 | .TP |
| 456 | \fB\-pollinterval\fR \fImsec\fR |
| 457 | (Windows only). This option is used to set the maximum time between |
| 458 | polling for fileevents. |
| 459 | This affects the time interval between checking for events throughout the Tcl |
| 460 | interpreter (the smallest value always wins). Use this option only if |
| 461 | you want to poll the serial port more or less often than 10 msec |
| 462 | (the default). |
| 463 | .TP |
| 464 | \fB\-sysbuffer\fR \fIinSize\fR |
| 465 | .TP |
| 466 | \fB\-sysbuffer\fR \fI{inSize outSize}\fR |
| 467 | (Windows only). This option is used to change the size of Windows |
| 468 | system buffers for a serial channel. Especially at higher communication |
| 469 | rates the default input buffer size of 4096 bytes can overrun |
| 470 | for latent systems. The first form specifies the input buffer size, |
| 471 | in the second form both input and output buffers are defined. |
| 472 | .TP |
| 473 | \fB\-lasterror\fR |
| 474 | (Windows only). This option is query only. |
| 475 | In case of a serial communication error, \fBread\fR or \fBputs\fR |
| 476 | returns a general Tcl file I/O error. |
| 477 | \fBfconfigure -lasterror\fR can be called to get a list of error details. |
| 478 | See below for an explanation of the various error codes. |
| 479 | |
| 480 | .SH "SERIAL PORT SIGNALS" |
| 481 | .PP |
| 482 | RS-232 is the most commonly used standard electrical interface for serial |
| 483 | communications. A negative voltage (-3V..-12V) define a mark (on=1) bit and |
| 484 | a positive voltage (+3..+12V) define a space (off=0) bit (RS-232C). The |
| 485 | following signals are specified for incoming and outgoing data, status |
| 486 | lines and handshaking. Here we are using the terms \fIworkstation\fR for |
| 487 | your computer and \fImodem\fR for the external device, because some signal |
| 488 | names (DCD, RI) come from modems. Of course your external device may use |
| 489 | these signal lines for other purposes. |
| 490 | |
| 491 | .IP \fBTXD(output)\fR |
| 492 | \fBTransmitted Data:\fR Outgoing serial data. |
| 493 | .IP \fBRXD(input)\fR |
| 494 | \fBReceived Data:\fRIncoming serial data. |
| 495 | .IP \fBRTS(output)\fR |
| 496 | \fBRequest To Send:\fR This hardware handshake line informs the modem that |
| 497 | your workstation is ready to receive data. Your workstation may |
| 498 | automatically reset this signal to indicate that the input buffer is full. |
| 499 | .IP \fBCTS(input)\fR |
| 500 | \fBClear To Send:\fR The complement to RTS. Indicates that the modem is |
| 501 | ready to receive data. |
| 502 | .IP \fBDTR(output)\fR |
| 503 | \fBData Terminal Ready:\fR This signal tells the modem that the workstation |
| 504 | is ready to establish a link. DTR is often enabled automatically whenever a |
| 505 | serial port is opened. |
| 506 | .IP \fBDSR(input)\fR |
| 507 | \fBData Set Ready:\fR The complement to DTR. Tells the workstation that the |
| 508 | modem is ready to establish a link. |
| 509 | .IP \fBDCD(input)\fR |
| 510 | \fBData Carrier Detect:\fR This line becomes active when a modem detects |
| 511 | a "Carrier" signal. |
| 512 | .IP \fBRI(input)\fR |
| 513 | \fBRing Indicator:\fR Goes active when the modem detects an incoming call. |
| 514 | .IP \fBBREAK\fR |
| 515 | A BREAK condition is not a hardware signal line, but a logical zero on the |
| 516 | TXD or RXD lines for a long period of time, usually 250 to 500 |
| 517 | milliseconds. Normally a receive or transmit data signal stays at the mark |
| 518 | (on=1) voltage until the next character is transferred. A BREAK is sometimes |
| 519 | used to reset the communications line or change the operating mode of |
| 520 | communications hardware. |
| 521 | |
| 522 | .SH "ERROR CODES (Windows only)" |
| 523 | .PP |
| 524 | A lot of different errors may occur during serial read operations or during |
| 525 | event polling in background. The external device may have been switched |
| 526 | off, the data lines may be noisy, system buffers may overrun or your mode |
| 527 | settings may be wrong. That's why a reliable software should always |
| 528 | \fBcatch\fR serial read operations. In cases of an error Tcl returns a |
| 529 | general file I/O error. Then \fBfconfigure -lasterror\fR may help to |
| 530 | locate the problem. The following error codes may be returned. |
| 531 | |
| 532 | .TP 10 |
| 533 | \fBRXOVER\fR |
| 534 | Windows input buffer overrun. The data comes faster than your scripts reads |
| 535 | it or your system is overloaded. Use \fBfconfigure -sysbuffer\fR to avoid a |
| 536 | temporary bottleneck and/or make your script faster. |
| 537 | .TP 10 |
| 538 | \fBTXFULL\fR |
| 539 | Windows output buffer overrun. Complement to RXOVER. This error should |
| 540 | practically not happen, because Tcl cares about the output buffer status. |
| 541 | .TP 10 |
| 542 | \fBOVERRUN\fR |
| 543 | UART buffer overrun (hardware) with data lost. |
| 544 | The data comes faster than the system driver receives it. |
| 545 | Check your advanced serial port settings to enable the FIFO (16550) buffer |
| 546 | and/or setup a lower(1) interrupt threshold value. |
| 547 | .TP 10 |
| 548 | \fBRXPARITY\fR |
| 549 | A parity error has been detected by your UART. |
| 550 | Wrong parity settings with \fBfconfigure -mode\fR or a noisy data line (RXD) |
| 551 | may cause this error. |
| 552 | .TP 10 |
| 553 | \fBFRAME\fR |
| 554 | A stop-bit error has been detected by your UART. |
| 555 | Wrong mode settings with \fBfconfigure -mode\fR or a noisy data line (RXD) |
| 556 | may cause this error. |
| 557 | .TP 10 |
| 558 | \fBBREAK\fR |
| 559 | A BREAK condition has been detected by your UART (see above). |
| 560 | .VE |
| 561 | |
| 562 | .SH "PORTABILITY ISSUES" |
| 563 | .TP |
| 564 | \fBWindows \fR(all versions) |
| 565 | Valid values for \fIfileName\fR to open a serial port are of the form |
| 566 | \fBcom\fIX\fB:\fR, where \fIX\fR is a number, generally from 1 to 4. |
| 567 | This notation only works for serial ports from 1 to 9, if the system |
| 568 | happens to have more than four. An attempt to open a serial port that |
| 569 | does not exist or has a number greater than 9 will fail. An alternate |
| 570 | form of opening serial ports is to use the filename \fB\e\e.\ecomX\fR, |
| 571 | where X is any number that corresponds to a serial port; please note |
| 572 | that this method is considerably slower on Windows 95 and Windows 98. |
| 573 | .TP |
| 574 | \fBWindows NT\fR |
| 575 | When running Tcl interactively, there may be some strange interactions |
| 576 | between the real console, if one is present, and a command pipeline that uses |
| 577 | standard input or output. If a command pipeline is opened for reading, some |
| 578 | of the lines entered at the console will be sent to the command pipeline and |
| 579 | some will be sent to the Tcl evaluator. If a command pipeline is opened for |
| 580 | writing, keystrokes entered into the console are not visible until the |
| 581 | pipe is closed. This behavior occurs whether the command pipeline is |
| 582 | executing 16-bit or 32-bit applications. These problems only occur because |
| 583 | both Tcl and the child application are competing for the console at |
| 584 | the same time. If the command pipeline is started from a script, so that Tcl |
| 585 | is not accessing the console, or if the command pipeline does not use |
| 586 | standard input or output, but is redirected from or to a file, then the |
| 587 | above problems do not occur. |
| 588 | .TP |
| 589 | \fBWindows 95\fR |
| 590 | A command pipeline that executes a 16-bit DOS application cannot be opened |
| 591 | for both reading and writing, since 16-bit DOS applications that receive |
| 592 | standard input from a pipe and send standard output to a pipe run |
| 593 | synchronously. Command pipelines that do not execute 16-bit DOS |
| 594 | applications run asynchronously and can be opened for both reading and |
| 595 | writing. |
| 596 | .sp |
| 597 | When running Tcl interactively, there may be some strange interactions |
| 598 | between the real console, if one is present, and a command pipeline that uses |
| 599 | standard input or output. If a command pipeline is opened for reading from |
| 600 | a 32-bit application, some of the keystrokes entered at the console will be |
| 601 | sent to the command pipeline and some will be sent to the Tcl evaluator. If |
| 602 | a command pipeline is opened for writing to a 32-bit application, no output |
| 603 | is visible on the console until the pipe is closed. These problems only |
| 604 | occur because both Tcl and the child application are competing for the |
| 605 | console at the same time. If the command pipeline is started from a script, |
| 606 | so that Tcl is not accessing the console, or if the command pipeline does |
| 607 | not use standard input or output, but is redirected from or to a file, then |
| 608 | the above problems do not occur. |
| 609 | .sp |
| 610 | Whether or not Tcl is running interactively, if a command pipeline is opened |
| 611 | for reading from a 16-bit DOS application, the call to \fBopen\fR will not |
| 612 | return until end-of-file has been received from the command pipeline's |
| 613 | standard output. If a command pipeline is opened for writing to a 16-bit DOS |
| 614 | application, no data will be sent to the command pipeline's standard output |
| 615 | until the pipe is actually closed. This problem occurs because 16-bit DOS |
| 616 | applications are run synchronously, as described above. |
| 617 | .TP |
| 618 | \fBMacintosh\fR |
| 619 | Opening a serial port is not currently implemented under Macintosh. |
| 620 | .sp |
| 621 | Opening a command pipeline is not supported under Macintosh, since |
| 622 | applications do not support the concept of standard input or output. |
| 623 | .TP |
| 624 | \fBUnix\fR\0\0\0\0\0\0\0 |
| 625 | Valid values for \fIfileName\fR to open a serial port are generally of the |
| 626 | form \fB/dev/tty\fIX\fR, where \fIX\fR is \fBa\fR or \fBb\fR, but the name |
| 627 | of any pseudo-file that maps to a serial port may be used. |
| 628 | .VS 8.4 |
| 629 | Advanced configuration options are only supported for serial ports |
| 630 | when Tcl is built to use the POSIX serial interface. |
| 631 | .VE 8.4 |
| 632 | .sp |
| 633 | When running Tcl interactively, there may be some strange interactions |
| 634 | between the console, if one is present, and a command pipeline that uses |
| 635 | standard input. If a command pipeline is opened for reading, some |
| 636 | of the lines entered at the console will be sent to the command pipeline and |
| 637 | some will be sent to the Tcl evaluator. This problem only occurs because |
| 638 | both Tcl and the child application are competing for the console at the |
| 639 | same time. If the command pipeline is started from a script, so that Tcl is |
| 640 | not accessing the console, or if the command pipeline does not use standard |
| 641 | input, but is redirected from a file, then the above problem does not occur. |
| 642 | .LP |
| 643 | See the PORTABILITY ISSUES section of the \fBexec\fR command for additional |
| 644 | information not specific to command pipelines about executing |
| 645 | applications on the various platforms |
| 646 | .SH "EXAMPLE" |
| 647 | Open a command pipeline and catch any errors: |
| 648 | .CS |
| 649 | set fl [\fBopen\fR "| ls this_file_does_not_exist"] |
| 650 | set data [read $fl] |
| 651 | if {[catch {close $fl} err]} { |
| 652 | puts "ls command failed: $err" |
| 653 | } |
| 654 | .CE |
| 655 | |
| 656 | .SH "SEE ALSO" |
| 657 | file(n), close(n), filename(n), fconfigure(n), gets(n), read(n), |
| 658 | puts(n), exec(n), pid(n), fopen(3) |
| 659 | |
| 660 | .SH KEYWORDS |
| 661 | access mode, append, create, file, non-blocking, open, permissions, |
| 662 | pipeline, process, serial |