本指南将帮助你快速搭建 OGScope 开发环境。
中文 | English
- ✅ 在 Raspberry Pi Zero 2W 上运行 OGScope
- ✅ 配置 PyCharm Professional 远程开发
- ✅ 通过 Web 界面访问系统
- Raspberry Pi Zero 2W
- IMX327 相机模块
- MicroSD 卡 (32GB+)
- 5V 3A 电源适配器
- (可选)2.4寸 SPI LCD 屏幕
- macOS
- PyCharm Professional 2021.1.3 或更高版本
- Git
- Raspberry Pi OS(官方镜像)
- Python 3.9+
- 网络连接(WiFi 或有线)
# 1. 下载 Raspberry Pi Imager 工具
# 访问: https://www.raspberrypi.org/downloads/
# 2. 使用 Raspberry Pi Imager 烧录 Raspberry Pi OS Lite
# 或使用 dd 命令烧录到 SD 卡
# macOS/Linux:
sudo dd if=2024-01-15-raspios-bookworm-armhf-lite.img of=/dev/diskX bs=4m status=progress# 1. 插入 SD 卡并启动 Raspberry Pi
# 2. 默认用户名: pi
# 3. 默认密码: raspberry
# 首次登录后,建议修改密码
passwd# 方法 1: WiFi 连接
sudo nmcli dev wifi connect "WiFi名称" password "密码"
# 方法 2: 配置静态 IP(可选)
sudo nano /etc/network/interfaces
# 查看 IP 地址
ip addr show wlan0 # WiFi
ip addr show eth0 # 有线# 在 Mac 上测试 SSH 连接
ssh pi@raspberrypi.local
# 或使用 IP 地址
ssh pi@192.168.1.xxx# 在 Raspberry Pi 上执行
cd ~
git clone https://github.com/your-username/OGScope.git
cd OGScope
chmod +x scripts/install.sh
./scripts/install.sh安装脚本会自动:
- 安装系统依赖
- 安装 Poetry
- 创建 Python 虚拟环境
- 安装项目依赖
- 配置 systemd 服务
如果自动安装失败,可以手动执行:
# 1. 更新系统
sudo apt update && sudo apt upgrade -y
# 2. 安装系统依赖
sudo apt install -y python3.9 python3-pip python3-venv git \
build-essential libopencv-dev libjpeg-dev libpng-dev \
libspidev-dev v4l-utils
# 3. 安装 Poetry
curl -sSL https://install.python-poetry.org | python3 -
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# 4. 克隆项目(如果还没有)
cd ~
git clone https://github.com/your-username/OGScope.git
cd OGScope
# 5. 安装 Python 依赖
poetry install
# 6. 运行测试
poetry run python -m ogscope.main在 Mac 上执行:
# 生成 SSH 密钥(如果还没有)
ssh-keygen -t ed25519 -C "ogscope-dev"
# 复制公钥到 Raspberry Pi
ssh-copy-id orangepi@orangepi.local
# 配置 SSH config
cat >> ~/.ssh/config << 'EOF'
Host orangepi
HostName orangepi.local
User orangepi
Port 22
ForwardAgent yes
ServerAliveInterval 60
EOF
# 测试连接
ssh orangepi建议以 开发指南 中的“远程开发(手动部署 + systemd)”流程为准。
快速版本:
-
添加远程解释器
File→Settings→Project→Python Interpreter- 点击 ⚙️ →
Add...→SSH Interpreter - Host:
orangepi.local, User:orangepi - Interpreter:
/home/orangepi/.local/bin/poetry
-
配置自动部署
Tools→Deployment→Configuration- 添加 SFTP 服务器
- 设置路径映射
-
启用自动上传
Tools→Deployment→Automatic Upload✅
# 方法 1: 手动启动(开发模式)
cd ~/OGScope
poetry run python -m ogscope.main
# 方法 2: 使用 systemd(生产模式)
sudo systemctl start ogscope
sudo systemctl status ogscope在浏览器中打开:
http://orangepi.local:8000
# 或使用 IP 地址
http://192.168.1.xxx:8000
FastAPI 自动生成的文档:
http://orangepi.local:8000/docs # Swagger UI
http://orangepi.local:8000/redoc # ReDoc
- Raspberry Pi 可以正常启动
- SSH 可以连接
- Poetry 已安装
- OGScope 依赖已安装
- Web 服务可以启动
- 浏览器可以访问界面
- PyCharm 可以远程连接
# 在 Raspberry Pi 上
cd ~/OGScope
poetry run pytest tests/unit/# 方法 1: 使用 IP 地址
ip addr show wlan0
# 方法 2: 路由器管理界面查看
# 方法 3: 使用 nmap 扫描
nmap -sn 192.168.1.0/24# 使用 pip 安装(备选)
pip3 install poetry# 查看日志
journalctl -u ogscope -f
# 检查端口占用
sudo netstat -tunlp | grep 8000
# 手动启动查看错误
cd ~/OGScope
poetry run python -m ogscope.main# 检查 SSH 服务
sudo systemctl status ssh
# 检查防火墙
sudo ufw status
# 测试 SSH 连接
ssh -v orangepi@orangepi.local祝你使用愉快!🎉