⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xc.nro

📁 支持X/YModem和cis_b+协议的串口通讯程序
💻 NRO
📖 第 1 页 / 共 4 页
字号:
            echo "Received 'string2' instead."        endif    endif.TP.I set\ Syntax: set.RB < xc -set-option><value>This command is the same as the command-mode.B xc\&'set' command, such as "set bps 1200", "set cis on", and so forth, except thata string <value> must be enclosed within double-quotation marks.Examples:    set cis "on"    set cfile "newfilename"    set auto "on"    set bps 2400.TP.I shellSyntax: shell "<shell-command>"The shell command enclosed within the double-quotation marks is executed. Thisis similar to the.B xccommand-mode "!" command. Remember that if the shell command containsdouble-quotation marks, they must be escaped with backslashes..TP.I timeoutSyntax: timeout <number>If <number> is greater than zero, starts a timer which will cause the MOSTDEEPLY NESTED script to exit when <number> of MINUTES expire. If <number> iszero, then any pending timeout is cancelled. If <number> is negative, nothinghappens.Expiration of the specified timeout causes the most deeply nested script toexit, not to terminate.BR xc .To cause the program to quit if a timeout expires, use a subscript.Example:    'script1' contains:        call "script2"        if expired        then            quit        endif        # more commands    'script2' contains:        assign expired eq 1        timeout 5           # limit of 5 minutes        while ! waitfor "login:" 30        do            xmitbrk        done        assign expired eq 0        exitWhen 'script2' exits, the numeric variable 'expired' will be set to 1 if\&'script2' timed out, and will be 0 otherwise. 'script1' can act on thisinformation accordingly..TP.I transmitSyntax: transmit "string"Sends a string to the modem. The string is sent with brief pauses betweencharacters, to accommodate modems that cannot accept rapid command input, andwithin the string, any alphabetic character preceded by a caret (^) istranslated to the corresponding Control-character.Example:    transmit "ATDT 5551212^M"sends the string "ATDT 5551212" to the modem, followed by a carriage-returncharacter..TP.I trueSyntax: trueDoes nothing, but always evaluates as TRUE. Useful in conditionalexpressions. The opposite of 'false'..TP.I tty\ Syntax: tty "on"        tty "off"Ordinarily, during script execution, characters received from the modem portare echoed to the user's terminal screen. This happens only during 'waitfor'and 'type' execution, so it may be a bit choppy. This echoing can be turnedoff with    tty "off"and turned back on with    tty "on"Note that "on" and "off" must be enclosed in quotation marks..TP.I typeSyntax: type "<filename>"Sends the specified ASCII file to the modem port. This is the same as the.B xcterminal-mode "send ASCII file" escape..TP.I unassignSyntax: unassign <variablename>Erases the specified user variable. The variable may be either numeric orstring type. The variable name must not be enclosed in quotation marks, becausevariable names are considered to be.B xcscript keywords, and not literal strings..TP.I waitforSyntax: waitfor "string" <number>Scans input from the modem port for an occurrence of the specified string,which must be enclosed in quotation marks. The scanning continues for thespecified <number> of SECONDS or until the specified string is identified inthe modem input stream, whichever comes first. This command evaluates as TRUEif the specified string is found, and as FALSE if the specified <number> ofSECONDS elapses and the string isn't found within that time. The default time,if no <number> is specified, is roughly 30 seconds.String matching is performed on a case-\fIin\fRsensitive basis.Within the string, any alphabetic character preceded by a caret (^) istranslated to the corresponding Control-character.Examples:    assign counter eq 1    while ! waitfor "login:" 15    do        xmitbrk; incr counter; if counter morethan 5        then            quit        endif    doneIf in a CompuServe Forum the "prompt character" has been set by the user tobe a backspace, this test will log off if the main prompt is not seen in thenext sixty seconds:    if ! waitfor "forum !^H" 60    then        transmit "bye^M"; quit    endifIf the 'cis' option has been set to "on", either in the.I .xcstartup script, or by a direct 'set' command from command mode, or with    set cis "on"within a current script, and if during 'waitfor' processing a CIS B-Plusprotocol file transfer request is received, then the B-Plus protocol transferis performed, the <number> argument is reset to its original value, and\&'waitfor' processing continues. This allows automatic B-Plus protocol filetransfers from within a script..TP.I whileSyntax: while <list1>; do <list2>; doneOperates similarly to the 'if' command, except that <list2> is executedrepeatedly so long as <list1> evaluates as TRUE. All the conditionalcomparators and rules for comparisons that apply for the 'if' command alsoapply to 'while'. (Note that 'while' loops can be nested within 'if' commandsand vice-versa.).TP.I xmitbrkSyntax: xmitbrkSends a BREAK signal to the modem port..SS \fIFile Transfers\fR.B Xc provides several internal file transfer protocols and supportsexternal protocols such as ZMODEM. This Linux version of.B xccan automatically recognize the trigger string for a ZMODEM downloadand invoke rz to handle the transfer. You must use the 'set' commandto have this feature enabled (either use 'set' at the command lineor in your xc.init). By default these are pre-set at compile time.       set zmcmd rz -y       set autozm onThere are several options for the rz command. The above '-y' tellsrz to overwrite existing files. Familiarize yourself with the otheroptions by invoking rz or sz with the '-h' flag. To send files viaZMODEM you must use the .B xccommand line. From terminal mode, ^A xwill bring up the .B xccommand prompt. From there you can enter youZMODEM command:        $ sz foobar.tar.Z                  Note the '$'. This tells .B xcto attach 'sz' to the current modem portin use by .B xc.Some more recent versions of rz/sz have this featurecrippled. The versions of rz/sz provided with this package work properly. The versions of rz/sz which open the port directly shouldbe avoided. By the way, rz can be invoked from the command line insimilar fashion, but DON'T specify the file name because it will bein the header provided by the sender on the other end. Here aresome examples:      $ rz      /* simple invocation */      $ rz -y   /* overwrite existing file */      $ rz -v   /* verbose */      $ rz -yv  /* verbose and overwrite existing file */When transferring files using the XMODEM protocol, the file mode isspecified in the upload/download command. The main modes for theXMODEM transfers are 1K packets or 128 byte packets deternined bythe commands "ro" and "so" for the former, and "rx" and "sx" forthe latter. In actuallity, as implemented here, "rx" and "ro" areidentical as the packet size is automatically determined by thesender. XMODEM will automatically receive the packet size speci-fied by the sender, whereas the receiver always determines whetherCRC or CHECKSUM error detection is used. When available, .B xcwill always negotiate a CRC transfer.Use of the send "so" and "sx" send commands require a bit more attention.The "so" command will try to negotiate an 'old' YMODEM transfer of 1K byte packets. If the receiver is unable to receive 1K packets.B xcattempts to recover by falling back to 128 byte packets. Ifthe negotiation is successful, .B xcwill transfer 1K byte packets.If at the end of the transfer there are less that 896 bytes in the final packet, .B xcwill automatically switch to 128 byte sizeso as avoid padding the file with extraneous bytes. The "sx"command will only send 128 byte packets as specified in the original XMODEM specifiacation. As with the receive commands, CRCor CHECKSUM error detection is determined automatically and willalways revert to CRC if available. Note that for speed of transfer,1-K byte packet size is better.When transferring files using CompuServe B-Plus protocol, the format of thefile is specified by the host. An ASCII mode will force.B xcto perform TEXT mode translation; a BINARY mode will not do any translation.This means that, in either direction, a BINARY mode will send bytes "as is",whereas in ASCII mode, an incoming file will always be stripped of end-of-linecarriage-returns, while an ASCII file being uploaded may or may not havecarriage-returns added after each newline, depending on the "on" or "off"setting of the "cr" option.When using either the "%t" (take) command, an XMODEM receive command, or aCompuServe B-Plus download command,.B xcwill check if the file name you specify already exists on your system, and askfor an OK to overwrite the file, or for an alternative name. In the CompuServecase, there will also be an option to "Resume" a download. If the CRC checksumof the bytes that you already have in the file matches CompuServe's checksum onthe the same initial bytes in its version of the file, file transfer willproceed from that point onwards. This saves connect time when a very largedownload has been interrupted during a prior session.Script-driven file transfers using the CompuServe B-Plus protocol are more orless built into the.B xcscript language, since during 'waitfor' processing, a file transfer requestfrom the modem port will trigger a B-Plus transfer if the "cis" mode is set.The difficulty in performing such transfers isn't in the transfer itself, butrather in the maneuvering required to get into position to transfer the correctfile, and is something that probably only experienced script writers shouldwrestle with. However, if we assume that in the midst of a script, you'vereached a point where you can issue a "download" command to CompuServe, forinstance a "Disposition" prompt during a File Library "BROWSE" command, and youwant to download the present file, which is "XCALL.C" on CompuServe, and"xcall.c" does not exist in your current working directory, you'd use thefollowing sequence of script commands to do it:    set cis on       # can't do auto file B-Plus transfer otherwise    transmit "dow^M"    pause 2          # wait for CIS to display protocol menu    transmit "2^M"   # B-Plus is number 2 on that menu     transmit "xcall.c^M"  # "file name for your computer:"    waitfor "Disposition"During the final "waitfor" processing, the CompuServe ENQ character willbe recognized and the transfer will proceed automatically. Then 'waitfor'will continue waiting for the "Disposition" prompt, after which your scriptcan proceed. The same sort of thing can be done with file uploads, but onceagain, the difficulty isn't with the transfer, but rather with setting thingsup so that the transfer will be requested at the correct place.A shell script,.B cisdownloadprovided with the distribution, can automatically retrieve a single file from aCompuServe library.For XMODEM, YMODEM, and ZMODEM transfers via scripts, there's no mechanismbuilt into the.B xcscript language to use the built-in, 128-byte-packet XMODEM in.BR xc .Instead, we strongly recommend that you obtain Chuck Forsberg's excellent,shareware utility called "RZSZ", which can handle XMODEM, XMODEM-1K,YMODEM, and ZMODEM transfers and which can be used from within.B xcwith the 'pipe' command, or from command mode with the '$' command, or usingthe examples under the .I bind_scriptcommand above..SS \fIDebugging\fRThere are three varieties of debugging in.BR xc .The script command (set debug "on" or set debug "off") will control echoingof each line of a script to the screen.If the program was compiled with DEBUG set to 1 in xc.h, all screen outputwill be captured in a file called.I debug.login the current directory, providing that it exists before entering.BR xc,and providing that output is not being diverted to a current capture file. The.I debug.logfile is overwritten each time.B xcis run. If you forgot to turn on capturing, if the program was compiled withDEBUG set to 1, and if.I debug.logexists, all is not lost: your session is recorded in.IR debug.log .Note that capturing to files is turned off when exiting terminal mode, andthis includes running the built-in B+ or XMODEM protocols.Finally, in the xcb+.c module, there is a CIS_DEBUG definition line whichis normally commented out. If this definition is uncommented, then a B+transfer will record every byte in a file called.IR xc.log .This file is created if needed, in the current directory, and overwrittenon each run of.BR xc ..SH Exit Codes.TStab(@) ;c2B lw(60) .0@Successful, uneventful completion.1@Error in command-line arguments.2@Failure in forking to execute a command or run a shell.3@T{No modem port specified on the command line, or contained in the environmentvariable MODEM.T}4@Inability to create a LCK..file for the specified port.5@Inability to open the specified port.6@No environment variable TERM has been set.7@No entry for the current TERM setting in /etc/termcap.8@Problem caused by the 'ungetty' program..TE.SH Copyright.B Xcand its source files and sample scripts and manual page are Copyright 1993 byJean-Pierre Radley.Permission is granted to the public to use this code in any manner, withoutany warranty, implied or otherwise, of fitness for a particular purpose.By virtue of a restriction previously placed upon all code derivative from.BR xcomm ", the " xccode and associated files may not be sold by anyone to anyone, nor incorporatedinto any product that is not also free. It's OK to transfer them for free..SH AuthorsThis manual page was written by Fred Buck (1989) and Jean\-Pierre Radley(1990, 1991, 1992, 1993)..B Xcitself is the product of many synergistic wise minds. See the README document..SH VersionThis edition of the manual is for XC \*(]V.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -