1. minicom 使用
无特别说明,下边操作均在 ubuntu20.4 上操作
1.1. Ubuntu挂载设备目录
➜ ls /dev/ | grep USB
ttyUSB0
ttyUSB1
1.2. minicom常用命令
连接串口后,命令行界面输入 Ctrl+A; Z; 进入设置界面; 按 ESC 退出设置界面
+-------------------------------------------------------------------+
| Minicom Command Summary |
| |
| Commands can be called by CTRL-A <key> |
| |
| Main Functions Other Functions |
| |
| Dialing directory..D run script (Go)....G | Clear Screen.......C |
| Send files.........S Receive files......R | cOnfigure Minicom..O |
| comm Parameters....P Add linefeed.......A | Suspend minicom....J |
| Capture on/off.....L Hangup.............H | eXit and reset.....X |
| send break.........F initialize Modem...M | Quit with no reset.Q |
| Terminal settings..T run Kermit.........K | Cursor key mode....I |
| lineWrap on/off....W local Echo on/off..E | Help screen........Z |
| Paste file.........Y Timestamp toggle...N | scroll Back........B |
| Add Carriage Ret...U |
| |
| Select function or press Enter for none. |
+-------------------------------------------------------------------+
- W:开启换行,防止截断;再次执行,关闭换行
- L: 开启文件保存;再次执行,关闭文件保存
- N: 开启时间戳(秒级);再次执行,切换为毫秒级别;再次执行,关闭时间显示
- X: 退出minicom
- C: 清空屏幕
- B: 进入滚屏控制,可以通过 (U=Up D=Down F=PgDn B=PgUp s=Srch S=CaseLess N=Next C=Cite ESC=Exit) 等键控制,没有鼠标时键盘操作很有用
➜ minicom --version
minicom version 2.7.1 (compiled Dec 23 2019)
➜ minicom --help
Usage: minicom [OPTION]... [configuration]
A terminal program for Linux and other unix-like systems.
-b, --baudrate : set baudrate (ignore the value from config)
-D, --device : set device name (ignore the value from config)
-s, --setup : enter setup mode
-o, --noinit : do not initialize modem & lockfiles at startup
-m, --metakey : use meta or alt key for commands
-M, --metakey8 : use 8bit meta key for commands
-l, --ansi : literal; assume screen uses non IBM-PC character set
-L, --iso : don't assume screen uses ISO8859
-w, --wrap : Linewrap on
-H, --displayhex : display output in hex
-z, --statline : try to use terminal's status line
-7, --7bit : force 7bit mode
-8, --8bit : force 8bit mode
-c, --color=on/off : ANSI style color usage on or off
-a, --attrib=on/off : use reverse or highlight attributes on or off
-t, --term=TERM : override TERM environment variable
-S, --script=SCRIPT : run SCRIPT at startup
-d, --dial=ENTRY : dial ENTRY from the dialing directory
-p, --ptty=TTYP : connect to pseudo terminal
-C, --capturefile=FILE : start capturing to FILE
-F, --statlinefmt : format of status line
-R, --remotecharset : character set of communication partner
-v, --version : output version information and exit
-h, --help : show help
configuration : configuration file to use
These options can also be specified in the MINICOM environment variable.
This variable is currently unset.
The configuration directory for the access file and the configurations
is compiled to /etc/minicom.
Report bugs to <minicom-devel@lists.alioth.debian.org>.
1.3. 快捷打开串口,通过save as保存制定的串口参数
sudo minicom -s
+-----[configuration]------+
| Filenames and paths |
| File transfer protocols |
| Serial port setup |
| Modem and dialing |
| Screen and keyboard |
| Save setup as dfl |
| Save setup as.. |
| Exit |
| Exit from Minicom |
+--------------------------+
# 上下移动选择 Serial port setup
+-----------------------------------------------------------------------+
| A - Serial Device : /dev/modem |
| B - Lockfile Location : /var/lock |
| C - Callin Program : |
| D - Callout Program : |
| E - Bps/Par/Bits : 115200 8N1 |
| F - Hardware Flow Control : Yes |
| G - Software Flow Control : No |
| |
| Change which setting? |
+-----------------------------------------------------------------------+
# 通过字母选择制定选项,比如选择 A 修改挂载为 /dev/ttyUSB0,回车退出
# 输入 E,然后一直输入 A 选择下一个,直到出现 150000 为止,回车退出
+---------[Comm Parameters]----------+----------------+
| | |
| Current: 115200 8N1 | |
| Speed Parity Data | |
| A: <next> L: None S: 5 | |
| B: <prev> M: Even T: 6 | |
| C: 9600 N: Odd U: 7 | |
| D: 38400 O: Mark V: 8 | |
| E: 115200 P: Space | |
| | |
| Stopbits |----------------+
| W: 1 Q: 8-N-1 |
| X: 2 R: 7-E-1 |
| |
| |
| Choice, or <Enter> to exit? |
+------------------------------------+
# 然后选择 save setup as ... 输入文件名回车保存,比如 xxx1 然后退出, 会生成 /etc/minicom/minirc.xxx1 文件
➜ cat /etc/minicom/minirc.xxx1
# Machine-generated file - use "minicom -s" to change parameters.
pu port /dev/ttyUSB0
pu baudrate 1500000
pu bits 8
pu parity N
pu stopbits 1
# 下次直接通过 sudo minicom xxx1 来登录保存的参数