📄 fconfigure.n
字号:
.VS 8.4.SH "SERIAL PORT CONFIGURATION OPTIONS".PPIf \fIchannelId\fR refers to a serial port, then the followingadditional configuration options are available on Windows andUnix systems with a POSIX serial interface:.TP\fB\-mode\fR \fIbaud\fB,\fIparity\fB,\fIdata\fB,\fIstop\fR.This option is a set of 4 comma-separated values: the baud rate, parity,number of data bits, and number of stop bits for this serial port. The\fIbaud\fR rate is a simple integer that specifies the connection speed.\fIParity\fR is one of the following letters: \fBn\fR, \fBo\fR, \fBe\fR,\fBm\fR, \fBs\fR; respectively signifying the parity options of ``none'',``odd'', ``even'', ``mark'', or ``space''. \fIData\fR is the number ofdata bits and should be an integer from 5 to 8, while \fIstop\fR is thenumber of stop bits and should be the integer 1 or 2..TP\fB\-handshake\fR \fItype\fR.(Windows and Unix). This option is used to setup automatic handshakecontrol. Note that not all handshake types maybe supported by your operatingsystem. The \fItype\fR parameter is case-independent.If \fItype\fR is \fBnone\fR then any handshake is switched off.\fBrtscts\fR activates hardware handshake. Hardware handshake signalsare described below.For software handshake \fBxonxoff\fR the handshake characters can be redefinedwith \fB-xchar\fR.An additional hardware handshake \fBdtrdsr\fR is available only under Windows.There is no default handshake configuration, the initial value dependson your operating system settings.The \fB-handshake\fR option cannot be queried..TP\fB\-queue\fR.(Windows and Unix). The \fB-queue\fR option can only be queried.It returns a list of two integers representing the current numberof bytes in the input and output queue respectively..TP\fB\-timeout\fR \fImsec\fR.(Windows and Unix). This option is used to set the timeout for blockingread operations. It specifies the maximum interval between thereception of two bytes in milliseconds.For Unix systems the granularity is 100 milliseconds.The \fB-timeout\fR option does not affect write operations ornonblocking reads.This option cannot be queried..TP\fB\-ttycontrol\fR \fI{signal boolean signal boolean ...}\fR.(Windows and Unix). This option is used to setup the handshakeoutput lines (see below) permanently or to send a BREAK over the serial line.The \fIsignal\fR names are case-independent.\fB{RTS 1 DTR 0}\fR sets the RTS output to high and the DTR output to low.The BREAK condition (see below) is enabled and disabled with \fB{BREAK 1}\fR and\fB{BREAK 0}\fR respectively.It's not a good idea to change the \fBRTS\fR (or \fBDTR\fR) signalwith active hardware handshake \fBrtscts\fR (or \fBdtrdsr\fR).The result is unpredictable.The \fB-ttycontrol\fR option cannot be queried..TP\fB\-ttystatus\fR.(Windows and Unix). The \fB-ttystatus\fR option can only bequeried. It returns the current modem status and handshake input signals(see below).The result is a list of signal,value pairs with a fixed order,e.g. \fB{CTS 1 DSR 0 RING 1 DCD 0}\fR.The \fIsignal\fR names are returned upper case..TP\fB\-xchar\fR \fI{xonChar xoffChar}\fR.(Windows and Unix). This option is used to query or change the softwarehandshake characters. Normally the operating system default should beDC1 (0x11) and DC3 (0x13) representing the ASCII standardXON and XOFF characters..TP\fB\-pollinterval\fR \fImsec\fR.(Windows only). This option is used to set the maximum time betweenpolling for fileevents.This affects the time interval between checking for events throughout the Tclinterpreter (the smallest value always wins). Use this option only ifyou want to poll the serial port more or less often than 10 msec(the default)..TP\fB\-sysbuffer\fR \fIinSize\fR.TP\fB\-sysbuffer\fR \fI{inSize outSize}\fR.(Windows only). This option is used to change the size of Windowssystem buffers for a serial channel. Especially at higher communicationrates the default input buffer size of 4096 bytes can overrunfor latent systems. The first form specifies the input buffer size,in the second form both input and output buffers are defined..TP\fB\-lasterror\fR.(Windows only). This option is query only.In case of a serial communication error, \fBread\fR or \fBputs\fRreturns a general Tcl file I/O error.\fBfconfigure -lasterror\fR can be called to get a list of error details.See below for an explanation of the various error codes..SH "SERIAL PORT SIGNALS".PPRS-232 is the most commonly used standard electrical interface for serialcommunications. A negative voltage (-3V..-12V) define a mark (on=1) bit anda positive voltage (+3..+12V) define a space (off=0) bit (RS-232C). Thefollowing signals are specified for incoming and outgoing data, statuslines and handshaking. Here we are using the terms \fIworkstation\fR foryour computer and \fImodem\fR for the external device, because some signalnames (DCD, RI) come from modems. Of course your external device may usethese signal lines for other purposes..RS.IP \fBTXD(output)\fR\fBTransmitted Data:\fR Outgoing serial data..IP \fBRXD(input)\fR\fBReceived Data:\fRIncoming serial data..IP \fBRTS(output)\fR\fBRequest To Send:\fR This hardware handshake line informs the modem thatyour workstation is ready to receive data. Your workstation mayautomatically reset this signal to indicate that the input buffer is full..IP \fBCTS(input)\fR\fBClear To Send:\fR The complement to RTS. Indicates that the modem isready to receive data..IP \fBDTR(output)\fR\fBData Terminal Ready:\fR This signal tells the modem that the workstationis ready to establish a link. DTR is often enabled automatically whenever aserial port is opened..IP \fBDSR(input)\fR\fBData Set Ready:\fR The complement to DTR. Tells the workstation that themodem is ready to establish a link..IP \fBDCD(input)\fR\fBData Carrier Detect:\fR This line becomes active when a modem detectsa "Carrier" signal..IP \fBRI(input)\fR\fBRing Indicator:\fR Goes active when the modem detects an incoming call..IP \fBBREAK\fRA BREAK condition is not a hardware signal line, but a logical zero on theTXD or RXD lines for a long period of time, usually 250 to 500milliseconds. Normally a receive or transmit data signal stays at the mark(on=1) voltage until the next character is transferred. A BREAK is sometimesused to reset the communications line or change the operating mode ofcommunications hardware..RE.SH "ERROR CODES (Windows only)".PPA lot of different errors may occur during serial read operations or duringevent polling in background. The external device may have been switchedoff, the data lines may be noisy, system buffers may overrun or your modesettings may be wrong. That's why a reliable software should always\fBcatch\fR serial read operations. In cases of an error Tcl returns ageneral file I/O error. Then \fBfconfigure -lasterror\fR may help tolocate the problem. The following error codes may be returned..RS.IP \fBRXOVER:\fRWindows input buffer overrun. The data comes faster than your scripts readsit or your system is overloaded. Use \fBfconfigure -sysbuffer\fR to avoid atemporary bottleneck and/or make your script faster..IP \fBTXFULL\fRWindows output buffer overrun. Complement to RXOVER. This error shouldpractically not happen, because Tcl cares about the output buffer status..IP \fBOVERRUN\fRUART buffer overrun (hardware) with data lost.The data comes faster than the system driver receives it.Check your advanced serial port settings to enable the FIFO (16550) bufferand/or setup a lower(1) interrupt threshold value..IP \fBRXPARITY\fRA parity error has been detected by your UART.Wrong parity settings with \fBfconfigure -mode\fR or a noisy data line (RXD)may cause this error..IP \fBFRAME\fRA stop-bit error has been detected by your UART.Wrong mode settings with \fBfconfigure -mode\fR or a noisy data line (RXD)may cause this error..IP \fBBREAK\fRA BREAK condition has been detected by your UART (see above)..RE.VE.SH "SEE ALSO"close(n), flush(n), gets(n), puts(n), read(n), socket(n),Tcl_StandardChannels(3).SH KEYWORDSblocking, buffering, carriage return, end of line, flushing, linemode,newline, nonblocking, platform, translation, encoding, filter, byte array,binary
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -