windows MAC linux XMODEM YMODEM使用方法
来源:互联网 发布:arpu值算法 编辑:程序博客网 时间:2024/06/06 11:48
PuTTy on Windows does not support zmodem, xmodem,
etc. so I often used HyperTerminal, but the GUI of Hyperterminal annoys me.
So instead of switching between PuTTy and HyperTerminal all the time, I tried to use a different terminal emulator ‘TeraTerm Pro’. This seems fine, but for some reason it dumps a few random characters on the serial line after the file is transferred, falsely answering the multiple choice menu to decide between runtime, diag, multiple image or loader.
I am now using GNU Screen with lrzsz. It was a little struggle to figure out the correct syntax for this, because Screen has a google-incompatible name. Hopefully I’ve sprinkled enough relevant terms in this post to help somebody else with this issue.
I start screen with ‘screen /dev/ttyUSB0 115200’. Then when I start the Xmodem download on the bootrom side I execute CTRL-A “:exec !! sx -kbfirmware.bix” in screen.
This works mostly fine. It eats the multiple choice menu after the transfer, but you can press <ENTER> to view it again. And FYI, the bootrom support Xmodem-1K giving a nice transferboost over regular Xmodem.
原文地址
https://yakking.branchable.com/posts/screen-advanced/
https://linux.die.net/man/1/sz
screen是linux下非常实用的小工具之一
配合brew install lrzsz
可以通过串口 XMODEM YMODEM收发信息和文件功能
linux下另一个工具qodem minicom
http://qodem.sourceforge.net/qodem.1.html
http://derrekito.github.io/Minicom-tutorial/
如果要接收则使用rz工具
https://www.systutorials.com/docs/linux/man/1-rz/
screen is sometimes denounced for its bloat, usually bytmuxproponents, but these features come in useful, and screen's wideavailability makes it useful to learn these features.
Copying and pasting text
^A[
opens selection mode. This lets you scroll through your output andselect sections by pressing enter then moving your cursor to the end ofyour selection and pressing enter again.
You can paste the selection by pressing ^A]
, which will input thepreviously selected text, so you can save useful snippets of a commandby copying with^A[
, opening a text editor, and pressing^A]
topaste it.
Customising your caption line
If you opened multiple screens in the same session, you will see a barat the bottom listing which screens are open. This is called thecaption bar.
If you want to always see it, you need to run thecaption always
command.
You can either add it to your ~/.screenrc
file, for it to alwayshappen when you open a terminal, or invoke it directly on the screencommand line by pressing^A:
to open the command line, then entercaption always
and press enter to run the command.
Like your shell's prompt, the caption bar can be customised. This isdone by enteringcaption string $SPEC
.
There are many options possible, and referring to thescreen(1)manpage is more useful than memorising them. The following example liststhe number and title of all screens in the caption, and highlights thecurrent screen in red:
caption string "%?%F%{.R.}%?%3n %t%? [%h]%?"
Screen config for complicated setups
Instead of specifying a command to run when you start your screen session,you can pass a path to a configuration file to run instead.
For example, you could put this in a config file for anirssi
session:
$ cat >irssi-screen-config <<EOFscreen -t irssi irssiEOF
With this config you can then put the following command in an appropriateplace to start services, and have your computer start an irssi sessionin a screen session on start-up.
$ screen -D -m irssi-screen-config
You can also use the hash-bang line of a file to turn your config fileinto a screen script.
$ cat >irssi-screen-config <<EOF#!/usr/bin/screen -Dmscreen -t irssi irssiEOF
Serial console client
It is common for high-end switches and development boards to have aserial port as a back-up control interface, so when everything else isfailing there's still a way to diagnose, and potentially fix a problem.
When appropriate cables have been connected, your machine will typicallyhave added a/dev/ttyUSB0
device node to represent the connection.
Reading and writing to this device will send and recieve data alongthe serial port line. However, in typical embedded linux appliances theother side of the serial connection is agetty, or login console.
To communicate with this, you need a client application.
Given this article is about screen, it should come as no surprise forme to announce that screen can act as such a client.
Rather than doing screen $COMMAND
, to run a command in a local tty,you runscreen /dev/ttyUSB0 115200
.
See the "Window Types" section of screen(1) for details about whatthe 115200 option is, and when you would need to change it.
This is arguably a sign of bloat, that a program about terminalmultiplexing includes a serial console client, however it's convenient,as screen is widely available on Linux distros.
Filter commands
Use ^A:
to open the screen command line. Enterexec COMMAND
to runthat command.
A sequence of !
, .
or :
symbols before the command can be used tospecify whether the input comes from your keyboard (the screen's input)or the output of the command running in your screen.
Exactly which symbols to use is a bit of a mystery, but!!
replacesyour shell with another program talking to the terminal. For anythingelse, see thescreen(1) manpage.
Sending files with xmodem
xmodem is a protocol for file transfer over a serial connection.
It's old and fragile, but it's simple, so development boards sometimeshave it as a fall-back for when everything else fails.
sx(1) is a tool to communicate overxmodem. It can also do theymodem protocol by invoking it as
sx --ymodem
.
After opening the command line with ^A:
, enterexec !! sx $FILE
to send that file over xmodem.
xmodem isn't completely reliable, so it may be necessary to re-runthe command.
- windows MAC linux XMODEM YMODEM使用方法
- Xmodem Ymodem Zmodem
- kermit xmodem ymodem
- xmodem ymodem zmodem协议
- Xmodem、Ymodem、Zmodem
- 【整理】Kermit Xmodem Xmodem-1K Ymodem Ymodem-G Ymodem-1K Zmodem
- Kermit Xmodem Xmodem-1K Ymodem Ymodem-G Ymodem-1K Zmodem
- Kermit Xmodem Xmodem-1K Ymodem Ymodem-G Ymodem-1K Zmodem
- xmodem,ymodem,zmodem,kermit的主要区别
- xmodem,ymodem,zmodem,kermit的主要区别
- xmodem,ymodem,zmodem,kermit的主要区别
- [嵌入式系统]xmodem,ymodem,zmodem的主要区别
- SecureCRT 工具 上传下载数据 与 ASCII、Xmodem、Ymodem 、Zmodem 说明
- SecureCRT 工具 上传下载数据 与 ASCII、Xmodem、Ymodem 、Zmodem 说明
- KERMIT,XMODEM,YMODEM,ZMODEM传输协议小结【转】
- SecureCRT 工具 上传下载数据 与 ASCII、Xmodem、Ymodem 、Zmodem 说明
- Xmodem
- Windows,Linux,Mac OS
- 怎样解决warning LNK4099: 未找到 PDB“vc100.pdb” 造成的链接 时间过长
- 网站防止XSS攻击
- hdu2586 lca+rmq
- MySql用户权限控制 【转】
- 【题解】T6775 拆数乘积
- windows MAC linux XMODEM YMODEM使用方法
- 中间镂空效果:A 视图上叠加 B视图,只显示B视图中间部分,达到好像中间镂空的效果
- 2-用Python搭建一个SSH僵尸网络
- 【excel 函数】常用的Excel函数
- Java数组
- HDU 4109 Instrction Arrangement (拓扑or差分约束求关键路径)
- cenos7安装svn
- Python:练习题(列表推导式、词频统计、异常处理、正则表达式等)
- 循环定时器--用setTimeout代替setInterval
sz(1) - Linux man page
Name
sx, sb, sz - XMODEM, YMODEM, ZMODEM file send
Synopsis
sz [-+8abdefkLlNnopqTtuvyY] file ...
sb [-adfkqtuv] file ...
sx [-akqtuv] file
sz [-oqtv] -c COMMAND
sz [-oqtv] -i COMMAND
sz -TT
Description
Sz uses the ZMODEM, YMODEM or XMODEM error correcting protocol to send one or more files over a dial-in serial port to a variety of programs runningunder PC-DOS, CP/M, Unix, VMS, and other operating systems.
While rz is smart enough to be called from cu(1), very few versions ofcu(1) are smart enough to allowsz to work properly. Unixflavors of Professional-YAM are available for such dial-out application.
Sz sends one or more files with ZMODEM protocol.
ZMODEM greatly simplifies file transfers compared to XMODEM. In addition to a friendly user interface, ZMODEM provides Personal Computer and other users anefficient, accurate, and robust file transfer method.
ZMODEM provides complete END-TO-END data integrity between application programs. ZMODEM's 32 bit CRC catches errors that sneak into even the mostadvanced networks.
Advanced file management features include AutoDownload (Automatic file Download initiated without user intervention), Display of individual and total filelengths and transmission time estimates, Crash Recovery, selective file transfers, and preservation of exact file date and length.
Output from another program may be piped to sz for transmission by denoting standard input with "-":
ls -l | sz -
The program output is transmitted with the filename sPID.sz where PID is the process ID of thesz program. If the environment variableONAMEis set, that is used instead. In this case, the Unix command:
ls -l | ONAME=con sz -ay -
will send a "file" to the PC-DOS console display. The -y option instructs the receiver to open the file for writing unconditionally. The-aoption causes the receiver to convert Unix newlines to PC-DOS carriage returns and linefeeds.
Sb batch sends one or more files with YMODEM or ZMODEM protocol. The initial ZMODEM initialization is not sent. When requested by the receiver,sb supportsYMODEM-g with "cbreak" tty mode, XON/XOFF flow control, and interrupt character set to CAN (^X).YMODEM-g (Professional-YAMg option) increases throughput over error free channels (direct connection, X.PC, etc.) by not acknowledging each transmitted sector.
On Unix systems, additional information about the file is transmitted. If the receiving program uses this information, the transmitted filelength controls the exact number of bytes written to the output dataset, and the modify time and file mode are set accordingly.
Sx sends a single file with XMODEM orXMODEM-1k protocol (sometimes incorrectly called "ymodem"). The user must supply the filename to both sending and receiving programs.
If sz is invoked with $SHELL set and iff that variable contains the stringrsh ,rbash orrksh (restricted shell), szoperates in restricted mode. Restricted mode restricts pathnames to the current directory and PUBDIR (usually /usr/spool/uucppublic) and/or subdirectoriesthereof.
The fourth form sends a single COMMAND to a ZMODEM receiver for execution. Sz exits with the COMMAND return value. If COMMAND includes spaces orcharacters special to the shell, it must be quoted.
The fifth form sends a single COMMAND to a ZMODEM receiver for execution. Sz exits as soon as the receiver has correctly received the command, beforeit is executed.
The sixth form (sz -TT) attempts to output all 256 code combinations to the terminal. In you are having difficulty sending files, this command lets you seewhich character codes are being eaten by the operating system.
If sz is invoked with stdout and stderr to different datasets, Verbose is set to 2, causing frame by frame progress reports to stderr. This may bedisabled with theq option.
The meanings of the available options are:
Using this option turns of memory mapping of the input file. This increases memory and cpu usage.
This option enables the --full-path option.
This is also turned on with to --dot-to-slash option.
Use this option with care.
This option is incompatible with standard zmodem. Use it with care.
Try to initiate a TCP/IP connection. lsz will ask the receiving zmodem to open a TCP/IP connection. All handshaking (which address / port to use) will bedone by the zmodem programs.
Use of this option imposes a security risk, somebody else could connect to the port in between. SeeSECURITY for details.
See --tcp-server for more information.
You will normally not want to use this option as lrzsz is the only zmodem which understands what to do (private extension). You might want to use this ifyou have to use zmodem (for which reason whatever), and cannot use the--tcp option oflsz (perhaps because your telnet doesn't allow to spawn alocal program with stdin/stdout connected to the remote side).
If you use this option you have to start lsz with the --tcp-client ADDRESS:PORT option.lrz will print the address and port on startup.
Use of this option imposes a security risk, somebody else could connect to the port in between. SeeSECURITY for details.
Unlink the file after successful transmission.
Security
Restricted mode restricts pathnames to the current directory and PUBDIR (usually /var/spool/uucppublic) and/or subdirectories thereof, and disables remotecommand execution.
Restricted mode is entered if the R option is given or if lsz detects that it runs under a restricted shell or if the environment variableZMODEM_RESTRICTED is found.
Restricted mode can be turned of with the U option if not running under a restricted shell.
Environment
may be used to specify the number of nulls to send before a ZDATA frame.
SHELL
lsz recognizes a restricted shell if this variable includes rsh or rksh
If this environment variable is set its content is used as the directory to place in the answer file to atimesync request.TMP Used insteadof TMPDIR if TMPDIR is not set. If neither TMPDIR nor TMP is set /tmp will be used.
Examples
ZMODEM File Transfer (Unix to DSZ/ZCOMM/Professional-YAM)
% sz -a *.c
This single command transfers all .c files in the current Unix directory with conversion (-a) to end of line conventions appropriate to the receivingenvironment. With ZMODEM AutoDownload enabled, Professional-YAM and ZCOMM will automatically recieve the files after performing a security check.
% sz -Yan *.c *.h
Send only the .c and .h files that exist on both systems, and are newer on the sending system than the corresponding version on the receiving system,converting Unix to DOS text format.
$ sz -\Yan file1.c file2.c file3.c foo.h baz.h 庐(for VMS)
ZMODEM Command Download (Unix to Professional-YAM)
cpszall:all sz -c "c:;cd /yam/dist" sz -ya $(YD)/*.me sz -yqb y*.exe sz -c "cd /yam" sz -i "!insms"
This Makefile fragment uses sz to issue commands to Professional-YAM to change current disk and directory. Next,sz transfers the.mefiles from the $YD directory, commanding the receiver to overwrite the old files and to convert from Unix end of line conventions to PC-DOS conventions. Thethird line transfers some.exe files. The fourth and fifth lines command Pro-YAM to change directory and execute a PC-DOS batch fileinsms .Since the batch file takes considerable time, the-i form is used to allowsz to exit immediately.
XMODEM File Transfer (Unix to Crosstalk)
% sx -a foo.c
ESC
rx foo.c
The above three commands transfer a single file from Unix to a PC and Crosstalk withsz translating Unix newlines to DOS CR/LF. This combination is muchslower and far less reliable than ZMODEM.
Error Messages
"Caught signal 99" indicates the program was not properly compiled, refer to "bibi(99)" in rbsb.c for details.
See Also
rz(omen), ZMODEM.DOC, YMODEM.DOC, Professional-YAM, crc(omen), sq(omen), todos(omen), tocpm(omen), tomac(omen), yam(omen)
Compile time options required for various operating systems are described in the source file.
Vms Version
The VMS version does not support wild cards. Because of VMS DCL, upper case option letters muse be represented by \ proceding the letter.
The current VMS version does not support XMODEM, XMODEM-1k, or YMODEM.
VMS C Standard I/O and RMS may interact to modify the file contents.
Files
32 bit CRC code courtesy Gary S. Brown.
sz.c, crctab.c, rbsb.c, zm.c, zmodem.h Unix source files
sz.c, crctab.c, vrzsz.c, zm.c, zmodem.h, vmodem.h, vvmodem.c, VMS source files.
/tmp/szlog stores debugging output (sz -vv) (szlog on VMS).
Testing Feature
The command "sz -T file" exercises the Attn sequence error recovery by commanding errors with unterminated packets. The receiving program shouldcomplain five times about binary data packets being too long. Each timesz is interrupted, it should send a ZDATA header followed by another defectivepacket. If the receiver does not detect five long data packets, theAttn sequence is not interrupting the sender, and theMyattn string insz.c must be modified.
After 5 packets, sz stops the "transfer" and prints the total number of characters "sent" (Tcount). The difference between Tcount and 5120 representsthe number of characters stored in various buffers when the Attn sequence is generated.
Bugs
Calling sz from most versions of cu(1) doesn't work because cu's receive process fightssz for characters from the modem.
On at least one BSD system, sz would hang or exit when it got within a few kilobytes of the end of file. Using the "-w 8192" flag fixed the problem. Thereal cause is unknown, perhaps a bug in the kernel TTY output routines.
Programs that do not properly implement the specified file transfer protocol may causesz to "hang" the port for a minute or two. This problem iscorrected by using ZCOMM, Pro-YAM, or other program with a correct implementation of the specified protocol.
Many programs claiming to support YMODEM only support XMODEM with 1k blocks, and they often don't get that quite right.
XMODEM transfers add up to 127 garbage bytes per file. XMODEM-1k and YMODEM-1k transfers use 128 byte blocks to avoid extra padding.
YMODEM programs use the file length transmitted at the beginning of the transfer to prune the file to the correct length; this may cause problems withsource files that grow during the course of the transfer. This problem does not pertain to ZMODEM transfers, which preserve the exact file lengthunconditionally.
Most ZMODEM options are merely passed to the receiving program; some do not implement all these options.
Circular buffering and a ZMODEM sliding window should be used when input is from pipes instead of acknowledging frames each 1024 bytes. If no files can beopened,sz sends a ZMODEM command to echo a suitable complaint; perhaps it should check for the presence of at least one accessible file before gettinghot and bothered. The test mode leaves a zero length file on the receiving system.
A few high speed modems have a firmware bug that drops characters when the direction of high speed transmissson is reversed. The environment variable ZNULLSmay be used to specify the number of nulls to send before a ZDATA frame. Values of 101 for a 4.77 mHz PC and 124 for an AT are typical.
Referenced By
picocom(8),ztelnet(1)