From e23808dface47b7a73f68a0ac7b02370d79dbfb1 Mon Sep 17 00:00:00 2001 From: xu Date: Fri, 16 May 2025 19:52:38 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=B1=BB=E5=9E=8B]=20=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=B3=A8=E9=87=8A=EF=BC=8C=E9=A3=9E=E6=8E=A7=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E8=AF=B7=E6=B1=82=E6=94=B9=E4=B8=BA=E9=83=A8=E5=88=86?= =?UTF-8?q?,=E9=A3=9E=E6=8E=A7=E9=80=9A=E8=AE=AF=E7=9A=84=E4=B8=B2?= =?UTF-8?q?=E5=8F=A32=E7=BC=93=E5=86=B2=E5=8C=BA=E5=8A=A0=E5=A4=A7?= =?UTF-8?q?=E5=88=B02048,=E6=80=80=E7=96=91=E7=BC=93=E5=86=B2=E5=8C=BA?= =?UTF-8?q?=E5=B0=8F=E5=AF=BC=E8=87=B4=E6=94=BE=E5=8B=BE=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=20=E8=AF=A6=E7=BB=86=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/FoodDeliveryBase.cpp | 19 +++++++++++++++---- src/Serialcommand.cpp | 5 +++++ src/can_control.cpp | 3 +++ src/commser.cpp | 3 +++ src/main.cpp | 2 ++ src/moto.cpp | 2 ++ src/motocontrol.cpp | 3 +++ 7 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/FoodDeliveryBase.cpp b/src/FoodDeliveryBase.cpp index 37b4961..ac23ff8 100644 --- a/src/FoodDeliveryBase.cpp +++ b/src/FoodDeliveryBase.cpp @@ -1,4 +1,6 @@ #include "FoodDeliveryBase.h" +///MQTT和Mavlink业务逻辑控制 +/// @file FoodDeliveryBase.cpp /** * @description: 初始化 */ @@ -35,7 +37,7 @@ FoodCube::FoodCube(char *userSsid, char *userPassword, char *userMqttServer, int case 2: Serial2.begin(57600, SERIAL_8N1); // 设置接收缓冲区大小为1024字节 - Serial2.setRxBufferSize(1024); + Serial2.setRxBufferSize(2048); //飞控用 break; } // 初始化声音模块串口 波特率 @@ -498,9 +500,18 @@ void FoodCube::mav_request_data() * MAV_DATA_STREAM_ENUM_END=13, */ // 根据从Pixhawk请求的所需信息进行设置 - const int maxStreams = 1; // 遍历次数 (下面组合的长度) - const uint8_t MAVStreams[maxStreams] = {MAV_DATA_STREAM_ALL}; // 请求的数据流组合 放到一个对象 后面进行遍历 - const uint16_t MAVRates[maxStreams] = {0x01}; // 设定发送频率 分别对应上面数据流 ps:0X01 1赫兹 既每秒发送一次 + //const int maxStreams = 1; // 遍历次数 (下面组合的长度) + //const uint8_t MAVStreams[maxStreams] = {MAV_DATA_STREAM_ALL}; // 请求的数据流组合 放到一个对象 后面进行遍历 + //const uint16_t MAVRates[maxStreams] = {0x01}; // 设定发送频率 分别对应上面数据流 ps:0X01 1赫兹 既每秒发送一次 + const int maxStreams = 3; + const uint8_t MAVStreams[maxStreams] = { + MAV_DATA_STREAM_EXTENDED_STATUS, + MAV_DATA_STREAM_POSITION, + MAV_DATA_STREAM_EXTRA1 + }; + const uint16_t MAVRates[maxStreams] = {1,1,1}; + + for (int i = 0; i < maxStreams; i++) { // 向飞控发送请求 diff --git a/src/Serialcommand.cpp b/src/Serialcommand.cpp index 2fabe88..2c9e92b 100644 --- a/src/Serialcommand.cpp +++ b/src/Serialcommand.cpp @@ -1,3 +1,8 @@ + +///加入和上层控制器协议解析,可收命令和发送命令返回 ---以前用于和飞控通讯目前已废弃改用mavlink +///使用commser.cpp里面封装的mavlink协议通讯, +///这个库用Serial2,目前Serial2用来播放语音 +/// @file Serialcommand.cpp #include "Serialcommand.h" #include "Arduino.h" #include "CRC.h" diff --git a/src/can_control.cpp b/src/can_control.cpp index f25c63e..10c8354 100644 --- a/src/can_control.cpp +++ b/src/can_control.cpp @@ -1,3 +1,6 @@ +///Can通讯硬件抽象层,给电机控制提供底层can通讯库的封装,可兼容不同can通讯库 +/// @file can_control.cpp + #include "can_control.h" #include "Arduino.h" #include "config.h" diff --git a/src/commser.cpp b/src/commser.cpp index 0703a3f..f0832d1 100644 --- a/src/commser.cpp +++ b/src/commser.cpp @@ -1,3 +1,6 @@ +///MQTT以及Mavlink通讯控制 + + #include "commser.h" #include "motocontrol.h" diff --git a/src/main.cpp b/src/main.cpp index 71c776e..1718ff5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,5 @@ +///主程序,硬件及线程控制 +/// @file main.cpp #include #include "HX711.h" #include "OneButton.h" diff --git a/src/moto.cpp b/src/moto.cpp index 08ee4fe..cc6ae9e 100644 --- a/src/moto.cpp +++ b/src/moto.cpp @@ -1,3 +1,5 @@ +///DJI电机控制协议及基础控制层,通过Can总线控制电机,依赖于CAN硬件抽象层 +// /// @file moto.cpp #include "moto.h" #include "Arduino.h" #include "config.h" diff --git a/src/motocontrol.cpp b/src/motocontrol.cpp index 693940a..30e2443 100644 --- a/src/motocontrol.cpp +++ b/src/motocontrol.cpp @@ -1,3 +1,6 @@ +/// 电机控制业务逻辑封装-依赖moto类 +/// @file motocontrol.cpp + #include "Arduino.h" #include "motocontrol.h"