OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [doc/] [open.n] - Blame information for rev 578

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
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.1.1.1 2002-01-16 10:25:24 markom Exp $
9
'\"
10
.so man.macros
11
.TH open n 7.6 Tcl "Tcl Built-In Commands"
12
.BS
13
'\" Note:  do not modify the .SH NAME line immediately below!
14
.SH NAME
15
open \- Open a file-based or command pipeline channel
16
.SH SYNOPSIS
17
.sp
18
\fBopen \fIfileName\fR
19
.br
20
\fBopen \fIfileName access\fR
21
.br
22
\fBopen \fIfileName access permissions\fR
23
.BE
24
 
25
.SH DESCRIPTION
26
.PP
27
.VS
28
This command opens a file, serial port, or command pipeline and returns a
29
.VE
30
channel identifier that may be used in future invocations of commands like
31
\fBread\fR, \fBputs\fR, and \fBclose\fR.
32
If the first character of \fIfileName\fR is not \fB|\fR then
33
the command opens a file:
34
\fIfileName\fR gives the name of the file to open, and it must conform to the
35
conventions described in the \fBfilename\fR manual entry.
36
.PP
37
The \fIaccess\fR argument, if present, indicates the way in which the file
38
(or command pipeline) is to be accessed.
39
In the first form \fIaccess\fR may have any of the following values:
40
.TP 15
41
\fBr\fR
42
Open the file for reading only; the file must already exist. This is the
43
default value if \fIaccess\fR is not specified.
44
.TP 15
45
\fBr+\fR
46
Open the file for both reading and writing; the file must
47
already exist.
48
.TP 15
49
\fBw\fR
50
Open the file for writing only.  Truncate it if it exists.  If it doesn't
51
exist, create a new file.
52
.TP 15
53
\fBw+\fR
54
Open the file for reading and writing.  Truncate it if it exists.
55
If it doesn't exist, create a new file.
56
.TP 15
57
\fBa\fR
58
Open the file for writing only.  The file must already exist, and the file
59
is positioned so that new data is appended to the file.
60
.TP 15
61
\fBa+\fR
62
Open the file for reading and writing.  If the file doesn't exist,
63
create a new empty file.
64
Set the initial access position  to the end of the file.
65
.PP
66
In the second form, \fIaccess\fR consists of a list of any of the
67
following flags, all of which have the standard POSIX meanings.
68
One of the flags must be either \fBRDONLY\fR, \fBWRONLY\fR or \fBRDWR\fR.
69
.TP 15
70
\fBRDONLY\fR
71
Open the file for reading only.
72
.TP 15
73
\fBWRONLY\fR
74
Open the file for writing only.
75
.TP 15
76
\fBRDWR\fR
77
Open the file for both reading and writing.
78
.TP 15
79
\fBAPPEND\fR
80
Set the file pointer to the end of the file prior to each write.
81
.TP 15
82
\fBCREAT\fR
83
Create the file if it doesn't already exist (without this flag it
84
is an error for the file not to exist).
85
.TP 15
86
\fBEXCL\fR
87
If \fBCREAT\fR is also specified, an error is returned if the
88
file already exists.
89
.TP 15
90
\fBNOCTTY\fR
91
If the file is a terminal device, this flag prevents the file from
92
becoming the controlling terminal of the process.
93
.TP 15
94
\fBNONBLOCK\fR
95
Prevents the process from blocking while opening the file, and
96
possibly in subsequent I/O operations.  The exact behavior of
97
this flag is system- and device-dependent;  its use is discouraged
98
(it is better to use the \fBfconfigure\fR command to put a file
99
in nonblocking mode).
100
For details refer to your system documentation on the \fBopen\fR system
101
call's \fBO_NONBLOCK\fR flag.
102
.TP 15
103
\fBTRUNC\fR
104
If the file exists it is truncated to zero length.
105
.PP
106
If a new file is created as part of opening it, \fIpermissions\fR
107
(an integer) is used to set the permissions for the new file in
108
conjunction with the process's file mode creation mask.
109
\fIPermissions\fR defaults to 0666.
110
.SH "COMMAND PIPELINES"
111
.PP
112
If the first character of \fIfileName\fR is ``|'' then the
113
remaining characters of \fIfileName\fR are treated as a list of arguments
114
that describe a command pipeline to invoke, in the same style as the
115
arguments for \fBexec\fR.
116
In this case, the channel identifier returned by \fBopen\fR may be used
117
to write to the command's input pipe or read from its output pipe,
118
depending on the value of \fIaccess\fR.
119
If write-only access is used (e.g. \fIaccess\fR is \fBw\fR), then
120
standard output for the pipeline is directed to the current standard
121
output unless overridden by the command.
122
If read-only access is used (e.g. \fIaccess\fR is \fBr\fR),
123
standard input for the pipeline is taken from the current standard
124
input unless overridden by the command.
125
.SH "SERIAL COMMUNICATIONS"
126
.VS
127
.PP
128
If \fIfileName\fR refers to a serial port, then the specified serial port
129
is opened and initialized in a platform-dependent manner.  Acceptable
130
values for the \fIfileName\fR to use to open a serial port are described in
131
the PORTABILITY ISSUES section.
132
 
133
.SH "CONFIGURATION OPTIONS"
134
The \fBfconfigure\fR command can be used to query and set the following
135
configuration option for open serial ports:
136
.TP
137
\fB\-mode \fIbaud\fB,\fIparity\fB,\fIdata\fB,\fIstop\fR
138
.
139
This option is a set of 4 comma-separated values: the baud rate, parity,
140
number of data bits, and number of stop bits for this serial port.  The
141
\fIbaud\fR rate is a simple integer that specifies the connection speed.
142
\fIParity\fR is one of the following letters: \fBn\fR, \fBo\fR, \fBe\fR,
143
\fBm\fR, \fBs\fR; respectively signifying the parity options of ``none'',
144
``odd'', ``even'', ``mark'', or ``space''.  \fIData\fR is the number of
145
data bits and should be an integer from 5 to 8, while \fIstop\fR is the
146
number of stop bits and should be the integer 1 or 2.
147
.VE
148
 
149
.VS
150
.SH "PORTABILITY ISSUES"
151
.sp
152
.TP
153
\fBWindows \fR(all versions)
154
.
155
Valid values for \fIfileName\fR to open a serial port are of the form
156
\fBcom\fIX\fB:\fR, where \fIX\fR is a number, generally from 1 to 4.  An
157
attempt to open a serial port that does not exist will fail.
158
.TP
159
\fBWindows NT\fR
160
.
161
When running Tcl interactively, there may be some strange interactions
162
between the real console, if one is present, and a command pipeline that uses
163
standard input or output.  If a command pipeline is opened for reading, some
164
of the lines entered at the console will be sent to the command pipeline and
165
some will be sent to the Tcl evaluator.  If a command pipeline is opened for
166
writing, keystrokes entered into the console are not visible until the the
167
pipe is closed.  This behavior occurs whether the command pipeline is
168
executing 16-bit or 32-bit applications.  These problems only occur because
169
both Tcl and the child application are competing for the console at
170
the same time.  If the command pipeline is started from a script, so that Tcl
171
is not accessing the console, or if the command pipeline does not use
172
standard input or output, but is redirected from or to a file, then the
173
above problems do not occur.
174
.TP
175
\fBWindows 95\fR
176
.
177
A command pipeline that executes a 16-bit DOS application cannot be opened
178
for both reading and writing, since 16-bit DOS applications that receive
179
standard input from a pipe and send standard output to a pipe run
180
synchronously.  Command pipelines that do not execute 16-bit DOS
181
applications run asynchronously and can be opened for both reading and
182
writing.
183
.sp
184
When running Tcl interactively, there may be some strange interactions
185
between the real console, if one is present, and a command pipeline that uses
186
standard input or output.  If a command pipeline is opened for reading from
187
a 32-bit application, some of the keystrokes entered at the console will be
188
sent to the command pipeline and some will be sent to the Tcl evaluator.  If
189
a command pipeline is opened for writing to a 32-bit application, no output
190
is visible on the console until the the pipe is closed.  These problems only
191
occur because both Tcl and the child application are competing for the
192
console at the same time.  If the command pipeline is started from a script,
193
so that Tcl is not accessing the console, or if the command pipeline does
194
not use standard input or output, but is redirected from or to a file, then
195
the above problems do not occur.
196
.sp
197
Whether or not Tcl is running interactively, if a command pipeline is opened
198
for reading from a 16-bit DOS application, the call to \fBopen\fR will not
199
return until end-of-file has been received from the command pipeline's
200
standard output.  If a command pipeline is opened for writing to a 16-bit DOS
201
application, no data will be sent to the command pipeline's standard output
202
until the pipe is actually closed.  This problem occurs because 16-bit DOS
203
applications are run synchronously, as described above.
204
.TP
205
\fBWindows 3.X\fR
206
.
207
A command pipeline can execute 16-bit or 32-bit DOS or Windows
208
applications, but the call to \fBopen\fR will not return until the last
209
program in the pipeline has finished executing; command pipelines run
210
synchronously.  If the pipeline is opened with write access (either just
211
writing or both reading and writing) the first application in the
212
pipeline will instead see an immediate end-of-file; any data the caller
213
writes to the open pipe will instead be discarded.
214
.sp
215
Since Tcl cannot be run with a real console under Windows 3.X, there are
216
no interactions between command pipelines and the console.
217
.TP
218
\fBMacintosh\fR
219
.
220
Opening a serial port is not currently implemented under Macintosh.
221
.sp
222
Opening a command pipeline is not supported under Macintosh, since
223
applications do not support the concept of standard input or output.
224
.TP
225
\fBUnix\fR\0\0\0\0\0\0\0
226
.
227
Valid values for \fIfileName\fR to open a serial port are generally of the
228
form \fB/dev/tty\fIX\fR, where \fIX\fR is \fBa\fR or \fBb\fR, but the name
229
of any pseudo-file that maps to a serial port may be used.
230
.sp
231
When running Tcl interactively, there may be some strange interactions
232
between the console, if one is present, and a command pipeline that uses
233
standard input.  If a command pipeline is opened for reading, some
234
of the lines entered at the console will be sent to the command pipeline and
235
some will be sent to the Tcl evaluator.  This problem only occurs because
236
both Tcl and the child application are competing for the console at the
237
same time.  If the command pipeline is started from a script, so that Tcl is
238
not accessing the console, or if the command pipeline does not use standard
239
input, but is redirected from a file, then the above problem does not occur.
240
.LP
241
See the PORTABILITY ISSUES section of the \fBexec\fR command for additional
242
information not specific to command pipelines about executing
243
applications on the various platforms
244
.SH "SEE ALSO"
245
close(n), filename(n), gets(n), read(n), puts(n), exec(n)
246
.VE
247
.SH KEYWORDS
248
access mode, append, create, file, non-blocking, open, permissions,
249
pipeline, process, serial

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.