# betaflight_serial_reader **Repository Path**: csc105/betaflight_serial_reader ## Basic Information - **Project Name**: betaflight_serial_reader - **Description**: 借鉴betaflight上位机获取飞控IMU数据,具备可视化功能 实机测试无上锁保护,可在获取IMU数据同时控制飞机 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-03-21 - **Last Updated**: 2025-03-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Betaflight Serial Reader ## 简介 | Introduction 这是一个用于从Betaflight飞控读取IMU数据和姿态信息的工具。它通过串口连接飞控,使用MSP协议通信,将飞控的姿态角度和原始传感器数据以可视化方式显示在终端上。 This is a tool for reading IMU data and attitude information from Betaflight flight controllers. It connects to the flight controller via serial port, communicates using the MSP protocol, and displays the attitude angles and raw sensor data in a visual way in the terminal. ## 功能特点 | Features - 连接到Betaflight飞控并通过MSP协议通信 - 读取和解析姿态数据(角度)和原始IMU数据 - 在终端上以可视化方式显示姿态 - 支持Windows和Linux/Unix系统 - 可配置串口和波特率 - Connect to Betaflight flight controllers via MSP protocol - Read and parse attitude data (angles) and raw IMU data - Display attitude in a visual way in the terminal - Support for Windows and Linux/Unix systems - Configurable serial port and baud rate ## 编译 | Building ### 依赖项 | Dependencies - C++17 兼容的编译器 (GCC 7+, Clang 5+, MSVC 2017+) - CMake 3.10+ - 线程库 (通常已包含在C++标准库中) - C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+) - CMake 3.10+ - Threading library (usually included in the C++ standard library) ### 安装操作步骤 | Installation Steps ```bash # 克隆仓库 | Clone the repository git clone <> cd betaflight_serial_reader # 创建构建目录 | Create a build directory mkdir -p build cd build # 配置并编译 | Configure and build cmake .. make # 安装(可选) | Install (optional) sudo make install ``` ## 使用方法 | Usage ```bash ./betaflight_serial_reader [选项] 选项 | Options: -p, --port <串口> 指定串口设备 (默认: /dev/ttyUSB0 或 COM3) Specify serial port device (default: /dev/ttyUSB0 or COM3) -b, --baud <波特率> 指定波特率 (默认: 115200) Specify baud rate (default: 115200) -h, --help 显示帮助信息 | Show help information 示例 | Examples: ./betaflight_serial_reader -p /dev/ttyACM0 -b 115200 ./betaflight_serial_reader --port COM4 --baud 57600 ``` ## 如何连接飞控 | How to Connect to Flight Controller 1. 通过USB线将飞控与电脑连接 | Connect the flight controller to your computer via USB 2. 确定飞控的串口设备名称 | Determine the serial port device name - Linux下可能是 `/dev/ttyACM0` 或 `/dev/ttyUSB0` - Windows下可能是 `COM3` 或其他COM端口 3. 运行程序,指定正确的串口设备名称 | Run the program with the correct serial port name 4. 姿态数据应该开始显示在终端上 | Attitude data should start appearing in the terminal ### WSL 2 下使用 - 安装usbipd-win `winget install usbipd` *# Windows PowerShell (管理员权限)* - 列出可用USB设备 `usbipd list`  *# Windows PowerShell* - 附加到WSL ```powershell # Windows PowerShell usbipd bind --busid usbipd attach --busid --wsl ``` - WSL中查看设备 `lsusb` or `ls /dev` ## 项目结构 | Project Structure ``` betaflight_serial_reader/ ├── CMakeLists.txt # CMake配置文件 ├── include/ # 头文件目录 │ ├── serial_port.h # 串口通信类 │ ├── msp_protocol.h # MSP协议定义 │ ├── msp_parser.h # MSP协议解析器 │ └── attitude_visualizer.h # 姿态可视化工具 ├── src/ # 源文件目录 │ ├── serial_port.cpp # 串口通信实现 │ ├── msp_parser.cpp # MSP协议解析器实现 │ ├── attitude_visualizer.cpp # 姿态可视化工具实现 │ └── main.cpp # 主程序 └── README.md # 本文件 ``` ## 扩展与贡献 | Extensions and Contributions 欢迎提交问题报告、功能请求和代码贡献。如需贡献,请fork本仓库并提交PR。 Issue reports, feature requests, and code contributions are welcome. To contribute, please fork this repository and submit a PR. ## 许可证 | License 本项目使用MIT许可证。详见 [LICENSE](LICENSE) 文件。 This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.