当前位置:首页>python>MicroPython 远程终端 & 文件管理器

MicroPython 远程终端 & 文件管理器

  • 2026-09-09 18:41:40
MicroPython 远程终端 & 文件管理器

🎯 一句话卖点

「插上板子 → rshell → 拖拽复制文件 + 实时 REPL」 比 ampy 更快,比 mpremote 更轻,Linux/Mac/Windows 全平台开箱即用!

⚡ 极速安装

# 系统级安装(推荐)
sudo pip3 install rshell          # Debian/Ubuntu 先 `sudo apt install python3-pip`

# 虚拟环境
python3 -m venv venv && source venv/bin/activate
pip install rshell

🔌 首次运行(串口权限一键解决)

# 添加当前用户到 dialout 组(Ubuntu 示例)
sudo usermod -a -G dialout $USER
# 重新登录或执行 newgrp dialout 生效

# 连接开发板(自动识别 /dev/ttyACM* / ttyUSB*)
rshell

📸 30 秒上手会话

Welcome rshell. Control-D to exit.
> ls -l /flash                    # 查看板内文件
> cp hello.py /flash              # 拖进来即可运行
> cat /flash/hello.py             # 确认内容
> repl                            # 秒进 REPL
>>> import hello
Hello World
>>> Control-X                      # 返回 shell
> boards                          # 多板并发管理

🛠️ 常用命令速查(会 Linux 就会用)

命令
说明
示例
ls /flash
列目录
ls -l /flash/*.py
cp file /flash
上传文件
cp -r project /flash
cat /flash/main.py
查看内容
cat /flash/boot.py
repl
进入 REPL
repl ~ pyb.bootloader()
 ~
boards
多板列表
boards
edit /flash/app.py
自动下载→编辑→回传
edit /flash/config.json
rm -r /flash/temp
删除目录
rm *.pyc
rsync src /flash
增量同步
rsync -m src /flash(仅更新)

🔗 多板并发 & 命名

# 给板子起别名(下次插自动识别)
echo'name="door_sensor"' > /pyboard/board.py
# 重新插拔后
> boards
pyboard-1  door_sensor
> ls /door_sensor/flash

📡 串口 / Telnet / 环境变量

# 指定端口 & 波特率
rshell -p /dev/ttyUSB0 -b 921600

# Telnet 连接 WiPy
rshell -p telnet 192.168.1.100 -u micro -w python

# 环境变量默认值
export RSHELL_PORT=/dev/ttyACM1
export RSHELL_BAUD=115200
export RSHELL_EDITOR=code           # VS Code 编辑文件

⚙️ 二进制 & 特殊平台

# 二进制传输(Raw REPL 不稳定平台)
rshell --ascii -p /dev/ttyS0  # 数据→ASCII Hex 编码

# 等待端口出现(热插拔)
rshell -p /dev/ttyACM0 --wait 10

🧪 模式匹配(类 Unix 子集)

模式
匹配
不支持
*.py
当前目录 .py 文件
t*/*.bmp
(中间通配)
temp/x[0-9]a.*
temp/x1a.bmp 等
{*.doc,*.pdf}
(花括号)

📄 命令行全参数

rshell -h                    # 查看完整帮助
rshell -p PORT -b BAUD       # 串口连接
rshell -p telnet IP -u USER -w PASS  # Telnet 连接
rshell --timing              # 打印每条命令耗时
rshell --quiet               # 静默模式(脚本专用)
rshell -f script.txt         # 批量执行命令文件

🎨 拖拽图流程(ASCII 漫画)

┌─── 主机 ─────────────────────────┐
│  $ rshell                        │
│  > cp main.py /flash             │
│  > repl                          │
└──────┬───────────────────────────┘
       │ USB/Serial/Telnet
───────┼───────  MicroPython  ─────────
       ▼
┌─── 开发板 ───────────────────────┐
│ /flash/main.py   ← 已上传        │
│ >>> import main   # 实时运行     │
└──────────────────────────────────┘

关注回复rshell获取

低价出售安全证书不限于cisp、pte等请Vme~建了一个项目群,想进群的请回复进群即可

最新文章

随机文章