【工具类】minicom 简单使用

本文详细介绍了如何在Ubuntu20.4系统中使用minicom,包括挂载USB设备、设置通信参数如baudrate,以及如何通过saveas功能保存和加载配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 来登录保存的参数

1.4. 参考资料

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值