Browse Source

youxian+7S0

master
L1ng 1 week ago
parent
commit
a5fd2f6f15
  1. 4
      .cproject
  2. 2
      .project
  3. 4
      .settings/language.settings.xml
  4. 18
      Core/BASE/Inc/BSP/B03_Para_01_100.h
  5. 2
      Core/BASE/Inc/BSP/BHBF_ROBOT.h
  6. 22
      Core/BASE/Inc/MSP/msp_485_android.h
  7. 15
      Core/BASE/Inc/MSP/msp_WH_LTE_7S0.h
  8. 11
      Core/BASE/Protobuf/PSource/bsp_CV.pb.h
  9. 9
      Core/BASE/Protobuf/PSource/bsp_Error.pb.h
  10. 11
      Core/BASE/Protobuf/PSource/bsp_GV.pb.h
  11. 12
      Core/BASE/Protobuf/PSource/bsp_IV.pb.h
  12. 89
      Core/BASE/Protobuf/PSource/bsp_PV.pb.h
  13. 1
      Core/BASE/Protobuf/Proto/bsp_CV.proto
  14. 10
      Core/BASE/Protobuf/Proto/bsp_Error.proto
  15. 1
      Core/BASE/Protobuf/Proto/bsp_GV.proto
  16. 3
      Core/BASE/Protobuf/Proto/bsp_IV.proto
  17. 89
      Core/BASE/Protobuf/Proto/bsp_PV.proto
  18. 54
      Core/BASE/Src/BSP/B03_Para_01_100.c
  19. 1
      Core/BASE/Src/BSP/BHBF_ROBOT.c
  20. 8
      Core/BASE/Src/BSP/bsp_MB_host.c
  21. 4
      Core/BASE/Src/BSP/bsp_client_setting.c
  22. 187
      Core/BASE/Src/MSP/msp_485_android.c
  23. 3
      Core/BASE/Src/MSP/msp_MK32_1.c
  24. 1
      Core/BASE/Src/MSP/msp_TL720D.c
  25. 426
      Core/BASE/Src/MSP/msp_WH_LTE_7S0.c
  26. 24
      Core/FSM/Src/Handset_Status_Setting.c
  27. 39
      Core/FSM/Src/fsm_state_control.c
  28. 10
      Core/FSM/Src/motor.c
  29. 4
      Core/FSM/Src/paint_gun_action.c
  30. 53
      Core/FSM/Src/robot_move_actions.c
  31. 8
      Core/FSM/Src/swing_action.c
  32. 38
      Core/Src/main.c
  33. 8
      Core/Src/usart.c
  34. 80
      Swing_Rust_UDP_cabled Debug.launch
  35. 14
      Swing_Rust_UDP_cabled.ioc

4
.cproject

@ -83,6 +83,10 @@
</tool> </tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.1879730817" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker"> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.1879730817" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.779857613" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" useByScannerDiscovery="false" value="${workspace_loc:/${ProjName}/STM32H743VGTX_FLASH.ld}" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.779857613" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" useByScannerDiscovery="false" value="${workspace_loc:/${ProjName}/STM32H743VGTX_FLASH.ld}" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.otherflags.842195703" name="Other flags" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.otherflags" useByScannerDiscovery="false" valueType="stringList">
<listOptionValue builtIn="false" value="-u _printf_float"/>
<listOptionValue builtIn="false" value="-lm"/>
</option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.1058332669" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input"> <inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.1058332669" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/>

2
.project

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>Swing_Rust_UDPV2</name> <name>Swing_Rust_UDP_cabled</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>

4
.settings/language.settings.xml

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1453070425915770112" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="454426226195276816" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/> <language-scope id="org.eclipse.cdt.core.g++"/>
</provider> </provider>
@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1453070425915770112" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="454426226195276816" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/> <language-scope id="org.eclipse.cdt.core.g++"/>
</provider> </provider>

18
Core/BASE/Inc/BSP/B03_Para_01_100.h

@ -13,6 +13,7 @@
#include "bsp_PID.pb.h" #include "bsp_PID.pb.h"
//int32_t 定义头文件 //int32_t 定义头文件
#include <stdint.h> #include <stdint.h>
#define ROBOT_NUMBER 3
// //
//typedef struct { //typedef struct {
// int32_t Speed_m_per_min_1 ; // MPMin = 1m/min 1米每分钟 m/min // int32_t Speed_m_per_min_1 ; // MPMin = 1m/min 1米每分钟 m/min
@ -44,22 +45,11 @@
typedef struct { typedef struct {
// 基础参数(和CV_struct_define一一对应) // 基础参数(和CV_struct_define一一对应)
float TT_Motor_1m_per_min; //天钛电机1m/min对应要发的参考数值
float TT_Motor_one_degree; //天钛电机1°对应要发的参考数值
float strain_gauge_k; //压力传感器的k值 float strain_gauge_k; //压力传感器的k值
float strain_gauge_b; //压力传感器的b值 float strain_gauge_b; //压力传感器的b值
float pressure_Max; //最大压力值 float pressure_Max; //最大压力值
int32_t pulse_Per_Circle; //每转多少脉冲 float angle_offset; //陀螺仪角度偏置
int32_t wheel_Reduction_Ratio; //减速比 float operating_times; //机器人总运行时间
double wheel_Diameter_m; //车轮直径 m
// 补齐CV中缺失的PID可选字段(和CV_struct_define完全匹配)
bool has_PID_high;
PID_Parameters PID_high;
bool has_PID_mid;
PID_Parameters PID_mid;
bool has_PID_low;
PID_Parameters PID_low;
} B03_Para_t; } B03_Para_t;
@ -74,5 +64,5 @@ typedef struct {
// 声明100组DH参数数组(extern关键) // 声明100组DH参数数组(extern关键)
extern const B03_Para_t g_B03_param_table[100]; extern B03_Para_t g_B03_param_table[100];
#endif /* BASE_INC_B03_PARA_01_100_H_ */ #endif /* BASE_INC_B03_PARA_01_100_H_ */

2
Core/BASE/Inc/BSP/BHBF_ROBOT.h

@ -46,6 +46,7 @@
#include "MSP/msp_MK32_1.h" #include "MSP/msp_MK32_1.h"
#include "MSP/msp_Force_Sensor.h" #include "MSP/msp_Force_Sensor.h"
#include "MSP/msp_WH_LTE_7S0.h" #include "MSP/msp_WH_LTE_7S0.h"
#include "MSP/msp_485_android.h"
#include "paint_gun_action.h" #include "paint_gun_action.h"
@ -71,6 +72,7 @@ extern IV_struct_define IV;
extern CV_struct_define CV; extern CV_struct_define CV;
extern PV_struct_define decoded_PV; extern PV_struct_define decoded_PV;
extern PV_struct_define decoded_PV_variable; extern PV_struct_define decoded_PV_variable;
extern PV_struct_define _decoded_PV_temp;
typedef struct sys_timer_handler typedef struct sys_timer_handler
{ {

22
Core/BASE/Inc/MSP/msp_485_android.h

@ -0,0 +1,22 @@
/*
* msp_485_android.h
*
* Created on: 2025121
* Author: akeguo
*/
#ifndef BASE_INC_MSP_MSP_485_ANDROID_H_
#define BASE_INC_MSP_MSP_485_ANDROID_H_
#include "bsp_Error_Detect.h"
#include "bsp_MB_host.h"
extern int isOnLineCount;
extern int16_t read_android_holidng_register_count;
extern void android_485_intialize_with_slaveID(struct UARTHandler *Handler,
int slave_id);
extern void android_485_intialize(struct UARTHandler *Handler);
#endif /* BASE_INC_MSP_MSP_485_ANDROID_H_ */

15
Core/BASE/Inc/MSP/msp_WH_LTE_7S0.h

@ -16,6 +16,21 @@ void WH_LTE_7S0_intialize(struct UARTHandler *Handler);
void decode_received_data_from_computer(uint8_t *buffer, uint16_t length); void decode_received_data_from_computer(uint8_t *buffer, uint16_t length);
void decode_command_from_wh_LTE_7S0(uint8_t *buffer, uint16_t length); void decode_command_from_wh_LTE_7S0(uint8_t *buffer, uint16_t length);
void UpdateGV(); void UpdateGV();
void LTE7S0_Init_MQTT(void);
void LTE7S0_Init_MQTT2(void);
void LTE_StepIntoConfigMode(void);
void LTE_StepOutOfConfigMode(void);
void LTE_CheckModuleAlive(void);
void LTE7S0_Init_HuaWei_MQTT(void);
void LTE7S0_Init_HuaWei_MQTT2(void);
void LTE_StepIntoConfigMode_HuaWei(void);
void LTE_StepOutOfConfigMode_HuaWei(void);
void LTE_Connect_HuaWei(void);
void LTE_CheckModuleAlive_HuaWei(void);
void Upload_Data_To_HuaWeiCloud(void);
extern char NeedToFeedBackToComputer; extern char NeedToFeedBackToComputer;
#endif /* INC_BSP_BSP_WH_LTE_7S0_H_ */ #endif /* INC_BSP_BSP_WH_LTE_7S0_H_ */

11
Core/BASE/Protobuf/PSource/bsp_CV.pb.h

@ -18,6 +18,7 @@ typedef struct _CV_struct_define {
float strain_gauge_b; /* 压力传感器的b值 */ float strain_gauge_b; /* 压力传感器的b值 */
float pressure_Max; /* 最大压力值 */ float pressure_Max; /* 最大压力值 */
float angle_offset; /* 陀螺仪角度偏置 */ float angle_offset; /* 陀螺仪角度偏置 */
float operating_times; /* 机器人总运行时间 */
} CV_struct_define; } CV_struct_define;
@ -26,21 +27,23 @@ extern "C" {
#endif #endif
/* Initializer values for message structs */ /* Initializer values for message structs */
#define CV_struct_define_init_default {0, 0, 0, 0} #define CV_struct_define_init_default {0, 0, 0, 0, 0}
#define CV_struct_define_init_zero {0, 0, 0, 0} #define CV_struct_define_init_zero {0, 0, 0, 0, 0}
/* Field tags (for use in manual encoding/decoding) */ /* Field tags (for use in manual encoding/decoding) */
#define CV_struct_define_strain_gauge_k_tag 1 #define CV_struct_define_strain_gauge_k_tag 1
#define CV_struct_define_strain_gauge_b_tag 2 #define CV_struct_define_strain_gauge_b_tag 2
#define CV_struct_define_pressure_Max_tag 3 #define CV_struct_define_pressure_Max_tag 3
#define CV_struct_define_angle_offset_tag 4 #define CV_struct_define_angle_offset_tag 4
#define CV_struct_define_operating_times_tag 5
/* Struct field encoding specification for nanopb */ /* Struct field encoding specification for nanopb */
#define CV_struct_define_FIELDLIST(X, a) \ #define CV_struct_define_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, FLOAT, strain_gauge_k, 1) \ X(a, STATIC, SINGULAR, FLOAT, strain_gauge_k, 1) \
X(a, STATIC, SINGULAR, FLOAT, strain_gauge_b, 2) \ X(a, STATIC, SINGULAR, FLOAT, strain_gauge_b, 2) \
X(a, STATIC, SINGULAR, FLOAT, pressure_Max, 3) \ X(a, STATIC, SINGULAR, FLOAT, pressure_Max, 3) \
X(a, STATIC, SINGULAR, FLOAT, angle_offset, 4) X(a, STATIC, SINGULAR, FLOAT, angle_offset, 4) \
X(a, STATIC, SINGULAR, FLOAT, operating_times, 5)
#define CV_struct_define_CALLBACK NULL #define CV_struct_define_CALLBACK NULL
#define CV_struct_define_DEFAULT NULL #define CV_struct_define_DEFAULT NULL
@ -51,7 +54,7 @@ extern const pb_msgdesc_t CV_struct_define_msg;
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define BSP_CV_PB_H_MAX_SIZE CV_struct_define_size #define BSP_CV_PB_H_MAX_SIZE CV_struct_define_size
#define CV_struct_define_size 20 #define CV_struct_define_size 25
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

9
Core/BASE/Protobuf/PSource/bsp_Error.pb.h

@ -19,11 +19,10 @@ typedef enum _ComError {
ComError_ZQ_CAN_ID2_RightMotor = 5, ComError_ZQ_CAN_ID2_RightMotor = 5,
ComError_ZQ_CAN_ID3_SwingMotor = 6, ComError_ZQ_CAN_ID3_SwingMotor = 6,
ComError_Force_Sensor = 7, ComError_Force_Sensor = 7,
ComError_Mfog40 = 8, ComError_Ultrasonic_Sensor = 8,
ComError_Ultrasonic_Sensor = 9, ComError_Android_485 = 9, /* UWB_20_Error=10; */
ComError_UWB_20_Error = 10, ComError_Strain_Gauge = 10,
ComError_Strain_Gauge = 11, ComError_Ground_Management = 11
ComError_Ground_Management = 12
} ComError; } ComError;
/* Struct definitions */ /* Struct definitions */

11
Core/BASE/Protobuf/PSource/bsp_GV.pb.h

@ -64,6 +64,7 @@ typedef struct _GV_struct_define {
int32_t auto_working; /* 记录是否正在自动行进 */ int32_t auto_working; /* 记录是否正在自动行进 */
int32_t client_close; int32_t client_close;
int32_t robot_real_speed; int32_t robot_real_speed;
int32_t wire_status;
} GV_struct_define; } GV_struct_define;
@ -72,8 +73,8 @@ extern "C" {
#endif #endif
/* Initializer values for message structs */ /* Initializer values for message structs */
#define GV_struct_define_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, SP_MSP_MK32_Button_init_default, false, TT_MotorParameters_init_default, false, TT_MotorParameters_init_default, false, TT_MotorParameters_init_default, false, MSP_TL720DParameters_init_default, false, IO_Data_init_default, false, ErrorData_init_default, false, PV_struct_define_init_default, 0, 0, 0, 0, 0, false, Strain_Gauge_Struct_init_default, 0, 0, 0, 0, false, ground_management_struct_init_default, 0, 0, 0, 0} #define GV_struct_define_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, SP_MSP_MK32_Button_init_default, false, TT_MotorParameters_init_default, false, TT_MotorParameters_init_default, false, TT_MotorParameters_init_default, false, MSP_TL720DParameters_init_default, false, IO_Data_init_default, false, ErrorData_init_default, false, PV_struct_define_init_default, 0, 0, 0, 0, 0, false, Strain_Gauge_Struct_init_default, 0, 0, 0, 0, false, ground_management_struct_init_default, 0, 0, 0, 0, 0}
#define GV_struct_define_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, SP_MSP_MK32_Button_init_zero, false, TT_MotorParameters_init_zero, false, TT_MotorParameters_init_zero, false, TT_MotorParameters_init_zero, false, MSP_TL720DParameters_init_zero, false, IO_Data_init_zero, false, ErrorData_init_zero, false, PV_struct_define_init_zero, 0, 0, 0, 0, 0, false, Strain_Gauge_Struct_init_zero, 0, 0, 0, 0, false, ground_management_struct_init_zero, 0, 0, 0, 0} #define GV_struct_define_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, SP_MSP_MK32_Button_init_zero, false, TT_MotorParameters_init_zero, false, TT_MotorParameters_init_zero, false, TT_MotorParameters_init_zero, false, MSP_TL720DParameters_init_zero, false, IO_Data_init_zero, false, ErrorData_init_zero, false, PV_struct_define_init_zero, 0, 0, 0, 0, 0, false, Strain_Gauge_Struct_init_zero, 0, 0, 0, 0, false, ground_management_struct_init_zero, 0, 0, 0, 0, 0}
/* Field tags (for use in manual encoding/decoding) */ /* Field tags (for use in manual encoding/decoding) */
#define GV_struct_define_TempatureE_2C_tag 1 #define GV_struct_define_TempatureE_2C_tag 1
@ -110,6 +111,7 @@ extern "C" {
#define GV_struct_define_auto_working_tag 32 #define GV_struct_define_auto_working_tag 32
#define GV_struct_define_client_close_tag 33 #define GV_struct_define_client_close_tag 33
#define GV_struct_define_robot_real_speed_tag 34 #define GV_struct_define_robot_real_speed_tag 34
#define GV_struct_define_wire_status_tag 35
/* Struct field encoding specification for nanopb */ /* Struct field encoding specification for nanopb */
#define GV_struct_define_FIELDLIST(X, a) \ #define GV_struct_define_FIELDLIST(X, a) \
@ -146,7 +148,8 @@ X(a, STATIC, OPTIONAL, MESSAGE, GroundManagementValue, 30) \
X(a, STATIC, SINGULAR, INT32, robot_back_distance, 31) \ X(a, STATIC, SINGULAR, INT32, robot_back_distance, 31) \
X(a, STATIC, SINGULAR, INT32, auto_working, 32) \ X(a, STATIC, SINGULAR, INT32, auto_working, 32) \
X(a, STATIC, SINGULAR, INT32, client_close, 33) \ X(a, STATIC, SINGULAR, INT32, client_close, 33) \
X(a, STATIC, SINGULAR, INT32, robot_real_speed, 34) X(a, STATIC, SINGULAR, INT32, robot_real_speed, 34) \
X(a, STATIC, SINGULAR, INT32, wire_status, 35)
#define GV_struct_define_CALLBACK NULL #define GV_struct_define_CALLBACK NULL
#define GV_struct_define_DEFAULT NULL #define GV_struct_define_DEFAULT NULL
#define GV_struct_define_P_MK32_MSGTYPE SP_MSP_MK32_Button #define GV_struct_define_P_MK32_MSGTYPE SP_MSP_MK32_Button
@ -167,7 +170,7 @@ extern const pb_msgdesc_t GV_struct_define_msg;
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define BSP_GV_PB_H_MAX_SIZE GV_struct_define_size #define BSP_GV_PB_H_MAX_SIZE GV_struct_define_size
#define GV_struct_define_size 2051 #define GV_struct_define_size 2086
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

12
Core/BASE/Protobuf/PSource/bsp_IV.pb.h

@ -79,6 +79,8 @@ typedef struct _IV_struct_define {
int32_t auto_mode_status; int32_t auto_mode_status;
/* 确诊机器人出错的原因 */ /* 确诊机器人出错的原因 */
int32_t reason_of_robot_error; int32_t reason_of_robot_error;
/* 获取有线连接还是无线连接 */
int32_t wire_or_wireless;
} IV_struct_define; } IV_struct_define;
@ -87,8 +89,8 @@ extern "C" {
#endif #endif
/* Initializer values for message structs */ /* Initializer values for message structs */
#define IV_struct_define_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define IV_struct_define_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define IV_struct_define_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define IV_struct_define_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
/* Field tags (for use in manual encoding/decoding) */ /* Field tags (for use in manual encoding/decoding) */
#define IV_struct_define_LeftCompensation_tag 1 #define IV_struct_define_LeftCompensation_tag 1
@ -114,6 +116,7 @@ extern "C" {
#define IV_struct_define_robot_set_speed_tag 21 #define IV_struct_define_robot_set_speed_tag 21
#define IV_struct_define_auto_mode_status_tag 22 #define IV_struct_define_auto_mode_status_tag 22
#define IV_struct_define_reason_of_robot_error_tag 23 #define IV_struct_define_reason_of_robot_error_tag 23
#define IV_struct_define_wire_or_wireless_tag 24
/* Struct field encoding specification for nanopb */ /* Struct field encoding specification for nanopb */
#define IV_struct_define_FIELDLIST(X, a) \ #define IV_struct_define_FIELDLIST(X, a) \
@ -139,7 +142,8 @@ X(a, STATIC, SINGULAR, INT32, right_angle, 19) \
X(a, STATIC, SINGULAR, INT32, robot_start, 20) \ X(a, STATIC, SINGULAR, INT32, robot_start, 20) \
X(a, STATIC, SINGULAR, INT32, robot_set_speed, 21) \ X(a, STATIC, SINGULAR, INT32, robot_set_speed, 21) \
X(a, STATIC, SINGULAR, INT32, auto_mode_status, 22) \ X(a, STATIC, SINGULAR, INT32, auto_mode_status, 22) \
X(a, STATIC, SINGULAR, INT32, reason_of_robot_error, 23) X(a, STATIC, SINGULAR, INT32, reason_of_robot_error, 23) \
X(a, STATIC, SINGULAR, INT32, wire_or_wireless, 24)
#define IV_struct_define_CALLBACK NULL #define IV_struct_define_CALLBACK NULL
#define IV_struct_define_DEFAULT NULL #define IV_struct_define_DEFAULT NULL
@ -150,7 +154,7 @@ extern const pb_msgdesc_t IV_struct_define_msg;
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define BSP_IV_PB_H_MAX_SIZE IV_struct_define_size #define BSP_IV_PB_H_MAX_SIZE IV_struct_define_size
#define IV_struct_define_size 261 #define IV_struct_define_size 273
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

89
Core/BASE/Protobuf/PSource/bsp_PV.pb.h

@ -13,67 +13,22 @@
/* 抛丸机器人作业参数结构体定义 /* 抛丸机器人作业参数结构体定义
APP/ */ APP/ */
typedef struct _PV_struct_define { typedef struct _PV_struct_define {
/* 操作模式(枚举值) int32_t Robot_Operation_Mode; /* 操作模式 手动模式1 2 3 4 自动模式5 6 7 */
1 - / int32_t Robot_Move_Speed; /* 机器人移动速度 */
2 - / int32_t Robot_Change_Lane_Distance; /* 换道距离 */
3 - "平民""平面" int32_t Robot_Swing_Speed; /* 摆臂速度 */
4 - int32_t Robot_symmetricalOrNot; /* 摆臂角度界面中的对称or非对称 1 对称 2 非对称 */
5 - int32_t Robot_Swing_Range_Angle; /* 对称下的摆臂角度 */
6 - int32_t Robot_asymmetricalAngleSetValue; /* 非对称条件下下 1左侧 2 右侧 */
7 - */ int32_t Robot_backMode; /* 后退设置模式 1 打退交替 2 边打边退 */
int32_t Robot_Operation_Mode; int32_t Robot_Back_Distance; /* 打退交替条件下的后退距离 */
/* 机器人移动速度(基础行走速度) int32_t Robot_Back_Speed; /* 边打边退条件下的后退速度 */
0.1m/min×0.1=101m/min int32_t Robot_Press_Set; /* 压力设置 */
0~1800~18m/min18m/min的要求 */ int32_t Robot_Vertical_Adjust; /* 竖直微调 */
int32_t Robot_Move_Speed; int32_t Robot_Length_Homework; /* 自动模式下的作业长度 */
/* 换道距离(自动换道功能的核心参数) int32_t Robot_Width_Homework; /* 自动模式下的作业宽度 */
mm int32_t Robot_SandBalst_Encode_One; /* 喷砂机编码1 输入为空发1 */
*/ int32_t Robot_SandBalst_Encode_Two; /* 喷砂机编码2 输入为空发2 */
int32_t Robot_Change_Lane_Distance;
/* 摆臂速度(抛丸/喷砂摆臂装置的摆动速度)
°/s/
2525°/S的要求 */
int32_t Robot_Swing_Speed;
/* 摆臂角度设置模式(对称/非对称)
1 -
2 - / */
int32_t Robot_symmetricalOrNot;
/* 对称模式下摆臂总摆动角度
°
90-45°~+45° */
int32_t Robot_Swing_Range_Angle;
/* 非对称模式下的摆动侧选择
1 -
2 - */
int32_t Robot_asymmetricalAngleSetValue;
/* 后退作业模式(抛丸/喷砂作业时的后退逻辑)
1 - 退退
2 - 退退 */
int32_t Robot_backMode;
/* 打退交替模式下的后退距离
mm
退退 */
int32_t Robot_Back_Distance;
/* 边打边退模式下的后退速度
0.1m/minRobot_Move_Speed
0~1800~18m/min */
int32_t Robot_Back_Speed;
/* 压力设置(抛丸/喷砂作业的介质压力)
0.01MPa500.5MPa
/Sa2.5 */
int32_t Robot_Press_Set;
/* 竖直微调(竖直作业模式下的位置微调量)
mm
/ */
int32_t Robot_Vertical_Adjust;
/* 自动模式下的作业长度
mm
*/
int32_t Robot_Length_Homework;
/* 自动模式下的作业宽度
mm
110mm标准作业宽度 */
int32_t Robot_Width_Homework;
} PV_struct_define; } PV_struct_define;
@ -82,8 +37,8 @@ extern "C" {
#endif #endif
/* Initializer values for message structs */ /* Initializer values for message structs */
#define PV_struct_define_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define PV_struct_define_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
#define PV_struct_define_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define PV_struct_define_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
/* Field tags (for use in manual encoding/decoding) */ /* Field tags (for use in manual encoding/decoding) */
#define PV_struct_define_Robot_Operation_Mode_tag 1 #define PV_struct_define_Robot_Operation_Mode_tag 1
@ -100,6 +55,8 @@ extern "C" {
#define PV_struct_define_Robot_Vertical_Adjust_tag 12 #define PV_struct_define_Robot_Vertical_Adjust_tag 12
#define PV_struct_define_Robot_Length_Homework_tag 13 #define PV_struct_define_Robot_Length_Homework_tag 13
#define PV_struct_define_Robot_Width_Homework_tag 14 #define PV_struct_define_Robot_Width_Homework_tag 14
#define PV_struct_define_Robot_SandBalst_Encode_One_tag 15
#define PV_struct_define_Robot_SandBalst_Encode_Two_tag 16
/* Struct field encoding specification for nanopb */ /* Struct field encoding specification for nanopb */
#define PV_struct_define_FIELDLIST(X, a) \ #define PV_struct_define_FIELDLIST(X, a) \
@ -116,7 +73,9 @@ X(a, STATIC, SINGULAR, INT32, Robot_Back_Speed, 10) \
X(a, STATIC, SINGULAR, INT32, Robot_Press_Set, 11) \ X(a, STATIC, SINGULAR, INT32, Robot_Press_Set, 11) \
X(a, STATIC, SINGULAR, INT32, Robot_Vertical_Adjust, 12) \ X(a, STATIC, SINGULAR, INT32, Robot_Vertical_Adjust, 12) \
X(a, STATIC, SINGULAR, INT32, Robot_Length_Homework, 13) \ X(a, STATIC, SINGULAR, INT32, Robot_Length_Homework, 13) \
X(a, STATIC, SINGULAR, INT32, Robot_Width_Homework, 14) X(a, STATIC, SINGULAR, INT32, Robot_Width_Homework, 14) \
X(a, STATIC, SINGULAR, INT32, Robot_SandBalst_Encode_One, 15) \
X(a, STATIC, SINGULAR, INT32, Robot_SandBalst_Encode_Two, 16)
#define PV_struct_define_CALLBACK NULL #define PV_struct_define_CALLBACK NULL
#define PV_struct_define_DEFAULT NULL #define PV_struct_define_DEFAULT NULL
@ -127,7 +86,7 @@ extern const pb_msgdesc_t PV_struct_define_msg;
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define BSP_PV_PB_H_MAX_SIZE PV_struct_define_size #define BSP_PV_PB_H_MAX_SIZE PV_struct_define_size
#define PV_struct_define_size 154 #define PV_struct_define_size 177
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

1
Core/BASE/Protobuf/Proto/bsp_CV.proto

@ -10,6 +10,7 @@ message CV_struct_define{
float strain_gauge_b=2; //b值 float strain_gauge_b=2; //b值
float pressure_Max=3; // float pressure_Max=3; //
float angle_offset=4; // float angle_offset=4; //
float operating_times=5; //
} }

10
Core/BASE/Protobuf/Proto/bsp_Error.proto

@ -23,12 +23,10 @@ enum ComError //枚举消息类型 Error Bit Define
ZQ_CAN_ID3_SwingMotor =6; ZQ_CAN_ID3_SwingMotor =6;
Force_Sensor =7; Force_Sensor =7;
Mfog40 =8; Ultrasonic_Sensor =8;
Ultrasonic_Sensor =9; Android_485 =9; //UWB_20_Error=10;
UWB_20_Error=10; Strain_Gauge =10;
Ground_Management =11;
Strain_Gauge=11;
Ground_Management = 12;
} }
//protoc --nanopb_out=. *.proto //protoc --nanopb_out=. *.proto

1
Core/BASE/Protobuf/Proto/bsp_GV.proto

@ -47,6 +47,7 @@ message GV_struct_define
int32 auto_working =32; // int32 auto_working =32; //
int32 client_close=33; int32 client_close=33;
int32 robot_real_speed=34; int32 robot_real_speed=34;
int32 wire_status=35;
}; };

3
Core/BASE/Protobuf/Proto/bsp_IV.proto

@ -96,4 +96,7 @@ message IV_struct_define
// //
int32 reason_of_robot_error=23; int32 reason_of_robot_error=23;
//线线
int32 wire_or_wireless=24;
}; };

89
Core/BASE/Protobuf/Proto/bsp_PV.proto

@ -6,78 +6,21 @@ option java_package = "com.example.swingarmapp.models";
// //
// APP/ // APP/
message PV_struct_define{ message PV_struct_define{
//
// 1 - /
// 2 - /
// 3 - "平民""平面"
// 4 -
// 5 -
// 6 -
// 7 -
int32 Robot_Operation_Mode = 1;
// int32 Robot_Operation_Mode= 1; // 1 2 3 4 5 6 7
// 0.1m/min×0.1=101m/min int32 Robot_Move_Speed=2; //
// 0~1800~18m/min18m/min的要求 int32 Robot_Change_Lane_Distance= 3; //
int32 Robot_Move_Speed = 2; int32 Robot_Swing_Speed= 4; //
int32 Robot_symmetricalOrNot=5; //or非对称 1 2
// int32 Robot_Swing_Range_Angle=6; //
// mm int32 Robot_asymmetricalAngleSetValue=7; // 1 2
// int32 Robot_backMode=8; //退 1 退 2 退
int32 Robot_Change_Lane_Distance = 3; int32 Robot_Back_Distance= 9; //退退
int32 Robot_Back_Speed=10; //退退
// / int32 Robot_Press_Set= 11; //
// °/s/ int32 Robot_Vertical_Adjust= 12; //
// 2525°/S的要求 int32 Robot_Length_Homework=13; //
int32 Robot_Swing_Speed = 4; int32 Robot_Width_Homework=14; //
int32 Robot_SandBalst_Encode_One=15; //1 1
// / int32 Robot_SandBalst_Encode_Two=16; //2 2
// 1 -
// 2 - /
int32 Robot_symmetricalOrNot = 5;
//
// °
// 90-45°~+45°
int32 Robot_Swing_Range_Angle = 6;
//
// 1 -
// 2 -
int32 Robot_asymmetricalAngleSetValue = 7;
// 退/退
// 1 - 退退
// 2 - 退退
int32 Robot_backMode = 8;
// 退退
// mm
// 退退
int32 Robot_Back_Distance = 9;
// 退退
// 0.1m/minRobot_Move_Speed
// 0~1800~18m/min
int32 Robot_Back_Speed = 10;
// /
// 0.01MPa500.5MPa
// /Sa2.5
int32 Robot_Press_Set = 11;
//
// mm
// /
int32 Robot_Vertical_Adjust = 12;
//
// mm
//
int32 Robot_Length_Homework = 13;
//
// mm
// 110mm标准作业宽度
int32 Robot_Width_Homework = 14;
}; };

54
Core/BASE/Src/BSP/B03_Para_01_100.c

@ -7,47 +7,29 @@
#include "B03_Para_01_100.h" #include "B03_Para_01_100.h"
// 100台机械臂DH参数表(指定初始化器写法)
//const P02_Para_t g_P02_param_table[100] = {
// // 第0台 SN001
// { B03_Para_t g_B03_param_table[100] = {
// .Speed_m_per_min_1=10, // 第1台 B03-17
// .LeftTurnSpeed_2=12,
// .RightTurnSpeed_3 =12,
// .RobotLeftAngleValue_4=90,
// .RobotRightAngleValue_5=-90,
// .RobotUpAngleValue_6=0,
// .RobotDownAngleValue_7=0,
// //....
// .wheel_Diameter_m_20=45
// },
// // 第1台 SN002
// {
// .Speed_m_per_min_1=11,
// .LeftTurnSpeed_2=13,
// .RightTurnSpeed_3 =12,
// .RobotLeftAngleValue_4=90,
// .RobotRightAngleValue_5=-90,
// .RobotUpAngleValue_6=0,
// .RobotDownAngleValue_7=0,
// // ... 其余参数
// .wheel_Diameter_m_20=45
// },
// // 剩下98台...
//};
const B03_Para_t g_B03_param_table[100] = {
// 第1台 B03-13
{ {
.TT_Motor_1m_per_min=1540.988, .angle_offset=0.0f,
.TT_Motor_one_degree=11014,
}, },
// 第2台 B03-14 // 第2台 B03-19
{ {
.angle_offset=192.0f,
}, },
// 剩下98台... // 第3台 B03-18
{
.angle_offset=0.0f,
},
// 第4台 B03-16
{
.angle_offset=0.0f,
.operating_times=0.0f,
},
// 剩下97台...
}; };

1
Core/BASE/Src/BSP/BHBF_ROBOT.c

@ -39,6 +39,7 @@ GV_struct_define GV =
PV_struct_define decoded_PV_variable = { 0 }; PV_struct_define decoded_PV_variable = { 0 };
PV_struct_define decoded_PV = { 0 }; PV_struct_define decoded_PV = { 0 };
PV_struct_define _decoded_PV_temp = { 0 };
IV_struct_define IV ={ 0 }; IV_struct_define IV ={ 0 };

8
Core/BASE/Src/BSP/bsp_MB_host.c

@ -221,12 +221,12 @@ void MB_ReadHoldingReg(uint8_t *Tx_Buf, uint8_t *TxCount_t, uint8_t _addr,
uint16_t TxCount = 0; uint16_t TxCount = 0;
uint16_t crc = 0; uint16_t crc = 0;
Tx_Buf[TxCount++] = _addr; /* 从站地址 */ Tx_Buf[TxCount++] = _addr; /* 从站地址 */ //40
Tx_Buf[TxCount++] = 0x03; /* 功能码 */ Tx_Buf[TxCount++] = 0x03; /* 功能码 */
Tx_Buf[TxCount++] = _reg >> 8; /* 寄存器地址 高字节 */ Tx_Buf[TxCount++] = _reg >> 8; /* 寄存器地址 高字节 */ //0
Tx_Buf[TxCount++] = _reg; /* 寄存器地址 低字节 */ Tx_Buf[TxCount++] = _reg; /* 寄存器地址 低字节 */ //0
Tx_Buf[TxCount++] = _num >> 8; /* 寄存器(16bits)个数 高字节 */ Tx_Buf[TxCount++] = _num >> 8; /* 寄存器(16bits)个数 高字节 */
Tx_Buf[TxCount++] = _num; /* 低字节 */ Tx_Buf[TxCount++] = _num; /* 低字节 */ //20
crc = MB_CRC16(Tx_Buf, TxCount); crc = MB_CRC16(Tx_Buf, TxCount);
Tx_Buf[TxCount++] = crc; /* crc 低字节 */ Tx_Buf[TxCount++] = crc; /* crc 低字节 */

4
Core/BASE/Src/BSP/bsp_client_setting.c

@ -86,9 +86,11 @@ void decode_received_data_from_client(uint8_t *buffer, uint16_t length)
i_pv_stream = pb_istream_from_buffer(&buffer[4], length - 4); i_pv_stream = pb_istream_from_buffer(&buffer[4], length - 4);
pb_decode(&i_pv_stream, PV_struct_define_fields, &decoded_PV_variable); pb_decode(&i_pv_stream, PV_struct_define_fields, &decoded_PV_variable);
HardWareErrorController->Set_PCOMHardWare(HardWareErrorController,"ZQ_Serial",1); HardWareErrorController->Set_PCOMHardWare(HardWareErrorController,"ZQ_Serial",1);
HardWareErrorController->Set_PCOMHardWare(HardWareErrorController, "Android_485", 1);
//pb_decode(&i_pv_stream, PV_struct_define_fields, &decoded_PV); //pb_decode(&i_pv_stream, PV_struct_define_fields, &decoded_PV);
GV.PV = decoded_PV_variable;
GV.wire_status=1; //1代表无线
// if(decoded_PV_variable.TimeStamp>decoded_PV.TimeStamp) // if(decoded_PV_variable.TimeStamp>decoded_PV.TimeStamp)
// { // {
// decoded_PV=decoded_PV_variable; // decoded_PV=decoded_PV_variable;

187
Core/BASE/Src/MSP/msp_485_android.c

@ -0,0 +1,187 @@
/*
* msp_485_android.c
*
* Created on: 2025121
* Author: akeguo
*/
#include "msp_485_android.h"
#include "msp_MK32_1.h"
#include "bsp_Error_Detect.h"
void decode_android_Sbus(uint8_t *buffer, uint16_t length);
void decode_android_PV(uint8_t *buffer, uint16_t length);
void android_485_loop(); //inqure data from the, in fact this is a modbus 03 function;
struct UARTHandler *android_handler;
DispacherController *androidr_dispacherController;
int android_slave_id = 0x40;
int8_t android_slave_iv_start_holiding_register = 100;
int16_t android_slave_iv_holiding_register_num = 0; //这个数据要随时改变
//最多读取多少个字节
int16_t read_android_holidng_register_count = 18 + 1 + PV_struct_define_size / 2; //16个subs通道 1个PV数据长度,
uint16_t Decoded_Android_HoldingReg_Value[100]; //用来对Android的Sbus /PV /IV 的操作
uint16_t send_pv_android_holdingReg_Value[100]; // /PV /IV 的操作
void android_485_intialize(struct UARTHandler *Handler)
{
android_handler = Handler;
androidr_dispacherController = Handler->dispacherController;
androidr_dispacherController->Dispacher_Enable = 1;
//不周期性发送
androidr_dispacherController->Add_Dispatcher_List(androidr_dispacherController, android_485_loop);
HardWareErrorController->Add_PCOMHardWare(HardWareErrorController, "Android_485", 0, ComError_Android_485);
LOG("msp_485_android_intialize");
}
void android_485_intialize_with_slaveID(struct UARTHandler *Handler, int slave_id)
{
android_485_intialize(Handler);
android_slave_id = slave_id;
}
int time_to_adapt = 150;
void android_485_loop()
{
//读取安卓数据 03
MB_ReadHoldingReg(&android_handler->Tx_Buf, &android_handler->TxCount, android_slave_id, 0, 20);
android_handler->AddSendList(android_handler, android_handler->Tx_Buf, android_handler->TxCount, time_to_adapt,
decode_android_Sbus);
}
int PMK32Index = 0;
int32_t *p_mk32_pointer;
int received_android_counter = 0;
int received_counter_max = 10/2;// 每次读取多少次遥控器然后读取PV/写IV
int count=0;
//读取 的寄存器
void decode_android_Sbus(uint8_t *buffer, uint16_t length)
{
// uint8_t data1[length];
// memcpy(data1, buffer, length);
if (length <= 5)
{
return;
}
int decoded_result = MB_Decode_HoldingRegs(buffer, length, read_android_holidng_register_count,
&Decoded_Android_HoldingReg_Value[0]);
if (decoded_result == 1)
{
p_mk32_pointer = (int32_t*) P_MK32;
//Sbus 设定
for (int PMK32Index = 0; PMK32Index < 18; PMK32Index++)
{
//此处必须加类型转换
*p_mk32_pointer = (int16_t) Decoded_Android_HoldingReg_Value[PMK32Index];
p_mk32_pointer++;
}
//检查按钮是否复位
if (Is_All_Button_Reset == 0)
{
if (P_MK32->CH4_SA == 0 && P_MK32->CH5_SB == 0 && P_MK32->CH6_SC == 0 && P_MK32->CH7_SD == 0)
{
Is_All_Button_Reset = 1;
HardWareErrorController->Set_PCOMHardWare(HardWareErrorController, "Need_To_Reset", 1);
}
}
else if (Is_All_Button_Reset == 1)
{
HardWareErrorController->Set_PCOMHardWare(HardWareErrorController, "Need_To_Reset", 1);
}
HardWareErrorController->Set_PCOMHardWare(HardWareErrorController, "Android_485", 1);
HardWareErrorController->Set_PCOMHardWare(HardWareErrorController, "mk32_sbus", 1);
received_android_counter++;
//读取遥控器
MB_ReadHoldingReg(&android_handler->Tx_Buf, &android_handler->TxCount, android_slave_id, 0, 20);
android_handler->AddSendList(android_handler, android_handler->Tx_Buf, android_handler->TxCount, time_to_adapt,
decode_android_Sbus);
if (received_android_counter % received_counter_max != 0) return;
switch (received_android_counter / received_counter_max % 2)
{
case 0:
{
//设定安卓数据 0x10传IV
pb_ostream_t IV_o_stream = pb_ostream_from_buffer(&send_pv_android_holdingReg_Value[1],
sizeof(send_pv_android_holdingReg_Value) - 1);
pb_encode(&IV_o_stream, IV_struct_define_fields, &IV);
android_slave_iv_holiding_register_num = (IV_o_stream.bytes_written + 1) / 2 + 1;
send_pv_android_holdingReg_Value[0] = SWAP_ENDIAN_16(IV_o_stream.bytes_written);
MB_WriteNumHoldingReg(&android_handler->Tx_Buf, &android_handler->TxCount, android_slave_id,
android_slave_iv_start_holiding_register, android_slave_iv_holiding_register_num,
send_pv_android_holdingReg_Value);
android_handler->AddSendList(android_handler, android_handler->Tx_Buf, android_handler->TxCount,
time_to_adapt, NULL);
received_android_counter = 0;
break;
}
case 1:
{ //读取安卓数据 03 PV
MB_ReadHoldingReg(&android_handler->Tx_Buf, &android_handler->TxCount, android_slave_id, 19,
(Decoded_Android_HoldingReg_Value[18] + 1) / 2);
android_handler->AddSendList(android_handler, android_handler->Tx_Buf, android_handler->TxCount,
time_to_adapt, decode_android_PV);
break;
}
}
}
else
{
LOGFF(DL_ERROR, "Android_485 decoding failed");
count++;
}
}
/*****/
void decode_android_PV(uint8_t *buffer, uint16_t length)
{
// uint8_t data1[1000];
// memcpy(data1, buffer, length);
if (length <= 5)
{
return;
}
int decoded_result = MB_Decode_HoldingRegs(buffer, length, (Decoded_Android_HoldingReg_Value[18] + 1) / 2,
&Decoded_Android_HoldingReg_Value[19]);
if (decoded_result == 1)
{
//PV解析
pb_istream_t i_pv_stream =
{ 0 };
i_pv_stream = pb_istream_from_buffer(&Decoded_Android_HoldingReg_Value[19],
Decoded_Android_HoldingReg_Value[18]);
int checkreturn = pb_decode(&i_pv_stream, PV_struct_define_fields, &_decoded_PV_temp);
if (checkreturn == 1)
{
decoded_PV = _decoded_PV_temp;
GV.PV=decoded_PV;
GV.wire_status=2; //2代表无线
}
HardWareErrorController->Set_PCOMHardWare(HardWareErrorController, "Android_485", 1);
HardWareErrorController->Set_PCOMHardWare(HardWareErrorController,"ZQ_Serial",1);
}
else
{
LOGFF(DL_ERROR, "Android_485 decoding failed");
}
}

3
Core/BASE/Src/MSP/msp_MK32_1.c

@ -44,7 +44,8 @@ void decode_MK32Data(uint8_t *buffer, uint16_t length)
if (Is_All_Button_Reset == 0) if (Is_All_Button_Reset == 0)
{ {
if (P_MK32->CH4_SA == 0 && P_MK32->CH5_SB == 0 && P_MK32->CH6_SC == 0 if (P_MK32->CH4_SA == 0 && P_MK32->CH5_SB == 0 && P_MK32->CH6_SC == 0
&& P_MK32->CH7_SD == 0 && P_MK32->IsOnline == 1) && P_MK32->CH7_SD == 0 && P_MK32->CH8_SE==0
&& P_MK32->CH9_SF == 0 && P_MK32->IsOnline == 1)
{ {
HardWareErrorController->Set_PCOMHardWare(HardWareErrorController, HardWareErrorController->Set_PCOMHardWare(HardWareErrorController,
"Need_To_Reset", 1); "Need_To_Reset", 1);

1
Core/BASE/Src/MSP/msp_TL720D.c

@ -44,6 +44,7 @@ void decode_TL720D(uint8_t *buffer, uint16_t length)
{ {
//SP_MSP_RF_TL720D_Parameters_In. //SP_MSP_RF_TL720D_Parameters_In.
SP_MSP_RF_TL720D_Parameters_In->RF_Angle_Roll = getDeci(&buffer[4]); SP_MSP_RF_TL720D_Parameters_In->RF_Angle_Roll = getDeci(&buffer[4]);
SP_MSP_RF_TL720D_Parameters_In->RF_Angle_Roll = SP_MSP_RF_TL720D_Parameters_In->RF_Angle_Roll-CV.angle_offset;
SP_MSP_RF_TL720D_Parameters_In->RF_Angle_Pitch = getDeci(&buffer[7]); SP_MSP_RF_TL720D_Parameters_In->RF_Angle_Pitch = getDeci(&buffer[7]);
SP_MSP_RF_TL720D_Parameters_In->RF_Angle_Yaw = getDeci(&buffer[10]); SP_MSP_RF_TL720D_Parameters_In->RF_Angle_Yaw = getDeci(&buffer[10]);
SP_MSP_RF_TL720D_Parameters_In->RF_Acc_X = getDeci(&buffer[13]); SP_MSP_RF_TL720D_Parameters_In->RF_Acc_X = getDeci(&buffer[13]);

426
Core/BASE/Src/MSP/msp_WH_LTE_7S0.c

@ -46,8 +46,8 @@ void WH_LTE_7S0_intialize(struct UARTHandler *Handler)
void Send_WH_LTE_7S0_Data(uint8_t *data, int length) void Send_WH_LTE_7S0_Data(uint8_t *data, int length)
{ {
char datass[100]; // char datass[256];
memcpy(datass, data, length); // memcpy(datass, data, length);
wh_LTE_7S0_Handler->UART_Decode = decode_received_data_from_computer; wh_LTE_7S0_Handler->UART_Decode = decode_received_data_from_computer;
memcpy(wh_LTE_7S0_Handler->Tx_Buf, data, length); memcpy(wh_LTE_7S0_Handler->Tx_Buf, data, length);
wh_LTE_7S0_Handler->TxCount = length; wh_LTE_7S0_Handler->TxCount = length;
@ -71,7 +71,7 @@ void UpdateGV()
//wh_LTE_7S0_Handler->Tx_Buf[2]='1'; //wh_LTE_7S0_Handler->Tx_Buf[2]='1';
wh_LTE_7S0_Handler->TxCount = GV_o_stream.bytes_written+2; wh_LTE_7S0_Handler->TxCount = GV_o_stream.bytes_written+2;
wh_LTE_7S0_Handler->UART_Tx(wh_LTE_7S0_Handler); //wh_LTE_7S0_Handler->UART_Tx(wh_LTE_7S0_Handler); //先不发
} }
void decode_received_data_from_computer(uint8_t *buffer, uint16_t length) void decode_received_data_from_computer(uint8_t *buffer, uint16_t length)
@ -94,5 +94,425 @@ void decode_received_data_from_computer(uint8_t *buffer, uint16_t length)
void LTE7S0_Init_MQTT(void)
{
uint8_t cmd_buf[128];
int cmd_len;
// 1. 检测模块是否开机
uint8_t at_test[] = "AT\r\n";
Send_WH_LTE_7S0_Data(at_test, sizeof(at_test)-1);
HAL_Delay(500);
// 2. 配置MQTT服务器IP端口
uint8_t srv_cfg[] = "AT+MQTTSRV=TCP,120.xx.xx.xx,1883\r\n";
Send_WH_LTE_7S0_Data(srv_cfg, sizeof(srv_cfg)-1);
HAL_Delay(300);
// 3. 设置发布主题(机器人上传数据用)
uint8_t pub_cfg[] = "AT+MQTTPUB=robot/weld/data\r\n";
Send_WH_LTE_7S0_Data(pub_cfg, sizeof(pub_cfg)-1);
HAL_Delay(300);
// 4. 设置订阅主题(接收手机下发控制指令)
uint8_t sub_cfg[] = "AT+MQTTSUB=robot/cmd/control\r\n";
Send_WH_LTE_7S0_Data(sub_cfg, sizeof(sub_cfg)-1);
HAL_Delay(300);
// 5. 开启MQTT纯透传模式
uint8_t mqtt_trans[] = "AT+MQTTMOD=1\r\n";
Send_WH_LTE_7S0_Data(mqtt_trans, sizeof(mqtt_trans)-1);
HAL_Delay(300);
// 6. 保存配置
uint8_t save_cfg[] = "AT+S\r\n";
Send_WH_LTE_7S0_Data(save_cfg, sizeof(save_cfg)-1);
}
void LTE7S0_Init_MQTT2(void)
{
uint8_t cmd_buf[128];
// 1. AT+E=OFF
uint8_t cmd1[] = "AT+E=OFF\r\n";
Send_WH_LTE_7S0_Data(cmd1, sizeof(cmd1)-1);
HAL_Delay(100);
// 2. AT+MQTTCFG=120,0
uint8_t cmd2[] = "AT+MQTTCFG=120,0\r\n";
Send_WH_LTE_7S0_Data(cmd2, sizeof(cmd2)-1);
HAL_Delay(100);
// 3. 发布主题1
uint8_t cmd3[] = "AT+MQTTPUBTP=1,1,BHBF/ROBOT/JC-01/DP/GVUP,0,1\r\n";
Send_WH_LTE_7S0_Data(cmd3, sizeof(cmd3)-1);
HAL_Delay(100);
// 4. 发布主题2
uint8_t cmd4[] = "AT+MQTTPUBTP=2,1,BHBF/ROBOT/JC-01/DP/CVUP,0,1\r\n";
Send_WH_LTE_7S0_Data(cmd4, sizeof(cmd4)-1);
HAL_Delay(100);
// 5. 发布主题3
uint8_t cmd5[] = "AT+MQTTPUBTP=3,1,BHBF/ROBOT/JC-01/DP/MESSAGE,0,1\r\n";
Send_WH_LTE_7S0_Data(cmd5, sizeof(cmd5)-1);
HAL_Delay(100);
// 6. 订阅主题1
uint8_t cmd6[] = "AT+MQTTSUBTP=1,1,BHBF/HMI/1/CP/name,0\r\n";
Send_WH_LTE_7S0_Data(cmd6, sizeof(cmd6)-1);
HAL_Delay(100);
// 7. 订阅主题2
uint8_t cmd7[] = "AT+MQTTSUBTP=2,1,BHBF/HMI/1/CP/CV,0\r\n";
Send_WH_LTE_7S0_Data(cmd7, sizeof(cmd7)-1);
HAL_Delay(100);
// 8. 订阅主题3
uint8_t cmd8[] = "AT+MQTTSUBTP=3,1,BHBF/HMI/SoftWareID/CP/RobotName/CONFIG,0\r\n";
Send_WH_LTE_7S0_Data(cmd8, sizeof(cmd8)-1);
HAL_Delay(100);
// 9. 订阅主题4
uint8_t cmd9[] = "AT+MQTTSUBTP=4,1,BHBF/HMI/SoftWareID/CP/RobotName/Reset,0\r\n";
Send_WH_LTE_7S0_Data(cmd9, sizeof(cmd9)-1);
HAL_Delay(100);
// 10. MQTT服务器地址端口
uint8_t cmd10[] = "AT+MQTTSVR=123.207.52.103,10086\r\n";
Send_WH_LTE_7S0_Data(cmd10, sizeof(cmd10)-1);
HAL_Delay(100);
// 11. ClientID
uint8_t cmd11[] = "AT+MQTTCID=0240012205270000\r\n";
Send_WH_LTE_7S0_Data(cmd11, sizeof(cmd11)-1);
HAL_Delay(100);
// 12. MQTT用户名
uint8_t cmd12[] = "AT+MQTTUSER=bingoorobot\r\n";
Send_WH_LTE_7S0_Data(cmd12, sizeof(cmd12)-1);
HAL_Delay(100);
// 13. MQTT密码
uint8_t cmd13[] = "AT+MQTTPSW=123456\r\n";
Send_WH_LTE_7S0_Data(cmd13, sizeof(cmd13)-1);
HAL_Delay(100);
// 14. 切换工作模式为MQTT
uint8_t cmd14[] = "AT+WKMOD=MQTT\r\n";
Send_WH_LTE_7S0_Data(cmd14, sizeof(cmd14)-1);
HAL_Delay(100);
// 15. 开启MQTT分发透传模式
uint8_t cmd15[] = "AT+MQTTMOD=1\r\n";
Send_WH_LTE_7S0_Data(cmd15, sizeof(cmd15)-1);
HAL_Delay(100);
// 16. 保存全部配置
uint8_t cmd16[] = "AT+S\r\n";
Send_WH_LTE_7S0_Data(cmd16, sizeof(cmd16)-1);
HAL_Delay(100);
}
void LTE_StepIntoConfigMode(void)
{
// +++ 无\r\n
uint8_t cmd1[] = "+++";
Send_WH_LTE_7S0_Data(cmd1, sizeof(cmd1)-1);
HAL_Delay(100);
// a 带换行
uint8_t cmd2[] = "a\r\n";
Send_WH_LTE_7S0_Data(cmd2, sizeof(cmd2)-1);
}
void LTE_StepOutOfConfigMode(void)
{
uint8_t cmd[] = "AT+ENTM\r\n";
Send_WH_LTE_7S0_Data(cmd, sizeof(cmd)-1);
HAL_Delay(200);
}
void LTE_CheckModuleAlive(void)
{
uint8_t at_test[] = "AT\r\n";
Send_WH_LTE_7S0_Data(at_test, sizeof(at_test)-1);
HAL_Delay(200);
}
void LTE7S0_Init_HuaWei_MQTT(void)
{
uint8_t cmd_buf[128];
// 1. 关闭串口回显 WH-LTE-7S0标准指令AT+E=OFF
uint8_t cmd1[] = "AT+E=OFF\r\n";
Send_WH_LTE_7S0_Data(cmd1, sizeof(cmd1)-1);
HAL_Delay(100);
// 2. MQTT心跳120s
uint8_t cmd2[] = "AT+MQTTCFG=120,0\r\n";
Send_WH_LTE_7S0_Data(cmd2, sizeof(cmd2)-1);
HAL_Delay(100);
// 3. 发布主题1:华为云系统上报Topic 设备->云端
uint8_t cmd3[] = "AT+MQTTPUBTP=4,1,$oc/devices/BHBF_ROBOT_01/sys/messages/up,0,1\r\n";
Send_WH_LTE_7S0_Data(cmd3, sizeof(cmd3)-1);
HAL_Delay(100);
// 4. 订阅主题1:华为云系统下行Topic 云端->设备
uint8_t cmd4[] = "AT+MQTTSUBTP=1,1,$oc/devices/BHBF_ROBOT_01/sys/messages/down,0\r\n";
Send_WH_LTE_7S0_Data(cmd4, sizeof(cmd4)-1);
HAL_Delay(100);
// 5. MQTT服务器:明文TCP域名+1883端口(模组仅支持明文,不能用8883加密端口)
uint8_t cmd10[] = "AT+MQTTSVR=TCP,744d3b81cd.st1.iotda-device.cn-north-4.myhuaweicloud.com,1883\r\n";
Send_WH_LTE_7S0_Data(cmd10, sizeof(cmd10)-1);
HAL_Delay(300);
// 6. ClientId 直接复制你给出的值
uint8_t cmd11[] = "AT+MQTTCID=6a447a97cbb0cf6bb96ac1a7_BHBF_ROBOT_01_0_0_2026071701\r\n";
Send_WH_LTE_7S0_Data(cmd11, sizeof(cmd11)-1);
HAL_Delay(100);
// 7. Username 复制你给出的值
uint8_t cmd12[] = "AT+MQTTUSER=6a447a97cbb0cf6bb96ac1a7_BHBF_ROBOT_01\r\n";
Send_WH_LTE_7S0_Data(cmd12, sizeof(cmd12)-1);
HAL_Delay(100);
// 8. Password 复制加密后的密钥
uint8_t cmd13[] = "AT+MQTTPSW=0fb0063aec42956c51dccb48c89ac170aefd68a1bc6832bbf68d824432132a5b\r\n";
Send_WH_LTE_7S0_Data(cmd13, sizeof(cmd13)-1);
HAL_Delay(100);
// 9. 切换工作模式为MQTT
uint8_t cmd14[] = "AT+WKMOD=MQTT\r\n";
Send_WH_LTE_7S0_Data(cmd14, sizeof(cmd14)-1);
HAL_Delay(100);
// 10. MQTT分发透传模式1:串口发送数据自动走1号发布主题
uint8_t cmd15[] = "AT+MQTTMOD=4\r\n";
Send_WH_LTE_7S0_Data(cmd15, sizeof(cmd15)-1);
HAL_Delay(100);
// 11. 开启MQTT纯透传模式
uint8_t mqtt_trans[] = "AT+MQTTMOD=0\r\n";
Send_WH_LTE_7S0_Data(mqtt_trans, sizeof(mqtt_trans)-1);
HAL_Delay(300);
// 12. 清空出厂默认载荷,杜绝厂商测试字符混入
uint8_t cmd16[] = "AT+MQTTPAYLOAD=""\r\n";
Send_WH_LTE_7S0_Data(cmd16, sizeof(cmd16)-1);
HAL_Delay(300);
// 13. 保存全部配置到模组Flash
uint8_t cmd17[] = "AT+S\r\n";
Send_WH_LTE_7S0_Data(cmd17, sizeof(cmd17)-1);
HAL_Delay(300);
}
void LTE7S0_Init_HuaWei_MQTT2(void)
{
// 1. 关闭串口回显 WH-LTE-7S0标准指令AT+E=OFF
uint8_t cmd1[] = "AT+WKMOD=MQTT\r\n";
Send_WH_LTE_7S0_Data(cmd1, sizeof(cmd1)-1);
HAL_Delay(100);
// 2. MQTT心跳120s
uint8_t cmd2[] = "AT+MQTTSVR=744d3b81cd.st1.iotda-device.cn-north-4.myhuaweicloud.com,1883\r\n";
Send_WH_LTE_7S0_Data(cmd2, sizeof(cmd2)-1);
HAL_Delay(100);
// 3. 发布主题1:华为云系统上报Topic 设备->云端
uint8_t cmd3[] = "AT+MQTTUSER=6a447a97cbb0cf6bb96ac1a7_BHBF_ROBOT_01\r\n";
Send_WH_LTE_7S0_Data(cmd3, sizeof(cmd3)-1);
HAL_Delay(100);
// 4. 订阅主题1:华为云系统下行Topic 云端->设备
uint8_t cmd4[] = "AT+MQTTPSW=4380927792e69477f605e2720c409969e80a42cb612657f7c3591a6b36c3083d\r\n";
Send_WH_LTE_7S0_Data(cmd4, sizeof(cmd4)-1);
HAL_Delay(100);
// 5. MQTT服务器:明文TCP域名+1883端口(模组仅支持明文,不能用8883加密端口)
uint8_t cmd10[] = "AT+MQTTCID=6a447a97cbb0cf6bb96ac1a7_BHBF_ROBOT_01_0_0_2026071606\r\n";
Send_WH_LTE_7S0_Data(cmd10, sizeof(cmd10)-1);
HAL_Delay(300);
// 6. ClientId 直接复制你给出的值
uint8_t cmd11[] = "AT+MQTTVER=4\r\n";
Send_WH_LTE_7S0_Data(cmd11, sizeof(cmd11)-1);
HAL_Delay(100);
// 7. Username 复制你给出的值
uint8_t cmd12[] = "AT+SOCKRSTIM=10\r\n";
Send_WH_LTE_7S0_Data(cmd12, sizeof(cmd12)-1);
HAL_Delay(100);
// 8. Password 复制加密后的密钥
uint8_t cmd13[] = "AT+SOCKRSNUM=60\r\n";
Send_WH_LTE_7S0_Data(cmd13, sizeof(cmd13)-1);
HAL_Delay(100);
// 9. 切换工作模式为MQTT
uint8_t cmd14[] = "AT+MQTTMOD=0\r\n";
Send_WH_LTE_7S0_Data(cmd14, sizeof(cmd14)-1);
HAL_Delay(100);
// 10. MQTT分发透传模式1:串口发送数据自动走1号发布主题
uint8_t cmd15[] = "AT+MQTTCFG=120,0\r\n";
Send_WH_LTE_7S0_Data(cmd15, sizeof(cmd15)-1);
HAL_Delay(100);
// 11. 开启MQTT纯透传模式
uint8_t cmd16[] = "AT+HEARTEN=OFF\r\n";
Send_WH_LTE_7S0_Data(cmd16, sizeof(cmd16)-1);
HAL_Delay(300);
// 11. 开启MQTT纯透传模式
uint8_t cmd17[] = "AT+MQTTWILL=0\r\n";
Send_WH_LTE_7S0_Data(cmd17, sizeof(cmd17)-1);
HAL_Delay(300);
// 11. 开启MQTT纯透传模式
uint8_t cmd18[] = "AT+MQTTPUBTP=4,1,$oc/devices/6a447a97cbb0cf6bb96ac1a7_BHBF_ROBOT_01/sys/messages/up,0,1\r\n";
Send_WH_LTE_7S0_Data(cmd18, sizeof(cmd18)-1);
HAL_Delay(300);
// 11. 开启MQTT纯透传模式
uint8_t cmd19[] = "AT+GNSSFUNEN=0\r\n";
Send_WH_LTE_7S0_Data(cmd19, sizeof(cmd19)-1);
HAL_Delay(300);
// 11. 开启MQTT纯透传模式
uint8_t cmd20[] = "AT+SSLEN=OFF\r\n";
Send_WH_LTE_7S0_Data(cmd20, sizeof(cmd20)-1);
HAL_Delay(300);
// 11. 开启MQTT纯透传模式
uint8_t cmd21[] = "AT+UART=115200,8,1,NONE,0\r\n";
Send_WH_LTE_7S0_Data(cmd21, sizeof(cmd21)-1);
HAL_Delay(300);
// 11. 开启MQTT纯透传模式
uint8_t cmd22[] = "AT+UARTFT=50\r\n";
Send_WH_LTE_7S0_Data(cmd22, sizeof(cmd22)-1);
HAL_Delay(300);
// 11. 开启MQTT纯透传模式 AT+MQTTPAYLOAD=""
uint8_t cmd23[] = "AT+UARTFL=1024\r\n";
Send_WH_LTE_7S0_Data(cmd23, sizeof(cmd23)-1);
HAL_Delay(300);
// 11. 开启MQTT纯透传模式 AT+MQTTPAYLOAD=""
uint8_t cmd24[] = "AT+MQTTPAYLOAD=""\r\n";
Send_WH_LTE_7S0_Data(cmd24, sizeof(cmd24)-1);
HAL_Delay(300);
// 13. 保存全部配置到模组Flash
uint8_t cmd25[] = "AT+S\r\n";
Send_WH_LTE_7S0_Data(cmd25, sizeof(cmd25)-1);
HAL_Delay(300);
}
// 进入配置模式(无需改动)
void LTE_StepIntoConfigMode_HuaWei(void)
{
uint8_t cmd1[] = "+++";
Send_WH_LTE_7S0_Data(cmd1, sizeof(cmd1)-1);
HAL_Delay(100);
// uint8_t cmd2[] = "a\r\n";
// Send_WH_LTE_7S0_Data(cmd2, sizeof(cmd2)-1);
}
// 退出配置模式,延长延时保证MQTT重连
void LTE_StepOutOfConfigMode_HuaWei(void)
{
uint8_t cmd[] = "AT+ENTM\r\n";
Send_WH_LTE_7S0_Data(cmd, sizeof(cmd)-1);
HAL_Delay(1000);
}
// 配置好参数后连接到服务器
void LTE_Connect_HuaWei(void)
{
HAL_Delay(3000);
uint8_t cmd[] = "AT+MQTTCONN=1\r\n";
Send_WH_LTE_7S0_Data(cmd, sizeof(cmd)-1);
HAL_Delay(1000);
}
// 模组存活检测(延长等待时间)
void LTE_CheckModuleAlive_HuaWei(void)
{
uint8_t at_test[] = "AT\r\n";
Send_WH_LTE_7S0_Data(at_test, sizeof(at_test)-1);
HAL_Delay(500);
}
int time_cut=0;
char jsonBuf[256];
int send_times=0;
uint8_t *send_data = NULL;
char online[8] = {0};
void Upload_Data_To_HuaWeiCloud(void)
{
// 1. 定义online字符串缓冲区,存储"断开"/"已连接"
if(IV.Is_Online == 0)
{
strcpy(online, "断开");
}
else if(IV.Is_Online == 1)
{
strcpy(online, "已连接");
}
online[sizeof(online)-1] = '\0';
// 2. 正确sprintf转义双引号,workStatus是字符串用%s包裹引号
snprintf(jsonBuf,256,
"{\"workStatus\":\"%s\",\"MoveSpeed\":%d,\"SetSpeed\":%f,\"Angle\":%d,\"LeftCompensation\":%f,\"RightCompensation\":%f,\"Press\":%d}",
online,
GV.robot_real_speed,
GV.Robot_Move_Speed,
GV.TL720DParameters.RF_Angle_Roll,
GV.Left_Compensation,
GV.Right_Compensation,
GV.Now_press / 10
);
// snprintf(jsonBuf,256,
// "{\"workStatus\":\"%s\",\"MoveSpeed\":1,\"SetSpeed\":0.1,\"Angle\":90,\"LeftCompensation\":1.1,\"RightCompensation\":-2.1,\"Press\":100}",
// online
// );
jsonBuf[255] = '\0'; // 强制末尾结束符
// 3. 发送指针直接强转,无需额外data数组
send_data = (uint8_t *)jsonBuf;
time_cut++;
// 定时发送逻辑
if(time_cut > 5000) // 1s需要计数500下
{
time_cut = 0;
// strlen获取真实报文长度,-1去掉结束符\0
//Send_WH_LTE_7S0_Data(send_data, strlen(jsonBuf));
uint16_t send_len = strlen(jsonBuf);
if(send_data != NULL && send_len > 0)
{
Send_WH_LTE_7S0_Data(send_data, send_len);
send_times++;
}
}
//HAL_Delay(1000);
}

24
Core/FSM/Src/Handset_Status_Setting.c

@ -381,7 +381,7 @@ IO_State GetIOState(void)
*/ */
void PV_control(void) void PV_control(void)
{ {
GV.PV = decoded_PV_variable; //GV.PV = decoded_PV_variable;
//GV.Robot_Move_Speed = ((float)GV.PV.Robot_Move_Speed) / 10; //GV.Robot_Move_Speed = ((float)GV.PV.Robot_Move_Speed) / 10;
GV.Robot_Move_Speed = ((P_MK32->CH11_RD1+1000)*14)/2000; GV.Robot_Move_Speed = ((P_MK32->CH11_RD1+1000)*14)/2000;
GV.LaneChangeDistance = GV.PV.Robot_Change_Lane_Distance; GV.LaneChangeDistance = GV.PV.Robot_Change_Lane_Distance;
@ -395,11 +395,11 @@ void PV_control(void)
GV.Robot_Move_Speed=1; GV.Robot_Move_Speed=1;
} }
//摆臂速度不允许为1,若设置了1,则强制置为2 //摆臂速度不允许为1,若设置了1,则强制置为0
// if(GV.Robot_Swing_Speed==1) if(GV.Robot_Swing_Speed==1)
// { {
// GV.Robot_Swing_Speed=2; GV.Robot_Swing_Speed=0;
// } }
} }
/** /**
@ -409,10 +409,11 @@ void PV_control(void)
*/ */
void IV_control(void) void IV_control(void)
{ {
GV.PV = decoded_PV_variable; //GV.PV = decoded_PV_variable;
GV.Vertical_Adjust = ((float)GV.PV.Robot_Vertical_Adjust) / 10; GV.Vertical_Adjust = ((float)GV.PV.Robot_Vertical_Adjust) / 10;
GV.symmetricalOrNot = GV.PV.Robot_symmetricalOrNot; GV.symmetricalOrNot = GV.PV.Robot_symmetricalOrNot;
GV.Robot_Swing_Speed = GV.PV.Robot_Swing_Speed; GV.Robot_Swing_Speed = GV.PV.Robot_Swing_Speed;
GV.Robot_Move_Speed = ((P_MK32->CH11_RD1+1000)*14)/2000;
IV.SystemError = GV.SystemErrorData.Com_Error_Code; IV.SystemError = GV.SystemErrorData.Com_Error_Code;
IV.Robot_Gyro = GV.TL720DParameters.RF_Angle_Roll; IV.Robot_Gyro = GV.TL720DParameters.RF_Angle_Roll;
IV.Is_Online = GV.P_MK32.IsOnline; IV.Is_Online = GV.P_MK32.IsOnline;
@ -426,6 +427,7 @@ void IV_control(void)
IV.left_angle = left_compare_value; IV.left_angle = left_compare_value;
IV.right_angle = right_compare_value; IV.right_angle = right_compare_value;
IV.robot_set_speed =((float)(P_MK32->CH11_RD1+1000)*14)/2000; IV.robot_set_speed =((float)(P_MK32->CH11_RD1+1000)*14)/2000;
IV.wire_or_wireless = GV.wire_status;
//机器人运行速度不允许为0,最小为1 //机器人运行速度不允许为0,最小为1
@ -435,10 +437,10 @@ void IV_control(void)
} }
//摆臂速度不允许为1,若设置了1,则强制置为2 //摆臂速度不允许为1,若设置了1,则强制置为2
// if(GV.Robot_Swing_Speed==1) if(GV.Robot_Swing_Speed==1)
// { {
// GV.Robot_Swing_Speed=2; GV.Robot_Swing_Speed=0;
// } }
if((P_MK32->CH5_SB!=0)||(P_MK32->CH7_SD!=0)) if((P_MK32->CH5_SB!=0)||(P_MK32->CH7_SD!=0))
{ {

39
Core/FSM/Src/fsm_state_control.c

@ -13,6 +13,7 @@
#include "swing_action.h" #include "swing_action.h"
#include "motors_power_action.h" #include "motors_power_action.h"
#include "BHBF_ROBOT.h" #include "BHBF_ROBOT.h"
#include "B03_Para_01_100.h"
/*=========================== 2. 宏定义 ===========================*/ /*=========================== 2. 宏定义 ===========================*/
/* 本文件无宏定义,预留 */ /* 本文件无宏定义,预留 */
@ -29,6 +30,8 @@ int error_detcet=0; //获取机器人错误
uint32_t NVIC_Priority_Group; // 中断优先级分组 uint32_t NVIC_Priority_Group; // 中断优先级分组
uint32_t TIM8_PreemptPrio; // 定时器8 抢占优先级 uint32_t TIM8_PreemptPrio; // 定时器8 抢占优先级
uint32_t TIM8_SubPrio; // 定时器8 子优先级 uint32_t TIM8_SubPrio; // 定时器8 子优先级
uint32_t Operating_times=0; // 统计运行时间
uint32_t Total_times=0;
/*=========================== 5. 静态函数声明 ===========================*/ /*=========================== 5. 静态函数声明 ===========================*/
/* 组函数(仅本文件使用) */ /* 组函数(仅本文件使用) */
@ -295,7 +298,7 @@ void GF_Dispatch(void)
&&(Get_BIT(SystemErrorCode, ComError_ZQ_CAN_ID1_LeftMotor) == CONNECTED) &&(Get_BIT(SystemErrorCode, ComError_ZQ_CAN_ID1_LeftMotor) == CONNECTED)
&&(Get_BIT(SystemErrorCode, ComError_ZQ_CAN_ID2_RightMotor) == CONNECTED) &&(Get_BIT(SystemErrorCode, ComError_ZQ_CAN_ID2_RightMotor) == CONNECTED)
&&(Get_BIT(SystemErrorCode, ComError_ZQ_CAN_ID3_SwingMotor) == CONNECTED) &&(Get_BIT(SystemErrorCode, ComError_ZQ_CAN_ID3_SwingMotor) == CONNECTED)
&&((Get_BIT(SystemErrorCode, ComError_MK32_Serial) == CONNECTED))) &&Is_All_Button_Reset==1)
{ {
start_flag=1; start_flag=1;
//SystemErrorCode = 0; //SystemErrorCode = 0;
@ -369,6 +372,18 @@ void GF_Dispatch(void)
watch_dog=DevMon_IsOnline(DEV_LEFT_MOTOR); watch_dog=DevMon_IsOnline(DEV_LEFT_MOTOR);
//统计机器人总运行时间
Operating_times++;
if(Operating_times>30000)
{
Operating_times=0;
CV = GF_BSP_EEPROM_Get_CV();
Total_times=CV.operating_times+1;
g_B03_param_table[ROBOT_NUMBER].operating_times=Total_times;
memcpy(&CV, &g_B03_param_table[ROBOT_NUMBER], sizeof(CV));
GF_BSP_EEPROM_Set_CV(CV);
}
} }
/*------------------------------------------------------------------- /*-------------------------------------------------------------------
@ -386,11 +401,6 @@ int AbnormalDetect(void)
{ {
is_error = 1; is_error = 1;
} }
/* 串口出错 */
else if (Get_BIT(SystemErrorCode, ComError_MK32_Serial) == DISCONNECTED)
{
is_error = 2;
}
/* 地面端出错 */ /* 地面端出错 */
else if(Get_BIT(SystemErrorCode, ComError_Ground_Management) == DISCONNECTED) else if(Get_BIT(SystemErrorCode, ComError_Ground_Management) == DISCONNECTED)
{ {
@ -418,6 +428,14 @@ int AbnormalDetect(void)
{ {
is_error = 8; is_error = 8;
} }
/* 串口出错 */
else if (Get_BIT(SystemErrorCode, ComError_MK32_Serial) == DISCONNECTED)
{
if(GV.wire_status==1) //无线连接状态
{
is_error = 2;
}
}
else else
{ {
// 完全正常 → 立刻清0计数 // 完全正常 → 立刻清0计数
@ -440,21 +458,24 @@ int AbnormalDetect(void)
} }
if (is_error == 1) return 1; if (is_error == 1) return 1;
//if (is_error == 2) return 2;
if (is_error == 3) return 3; if (is_error == 3) return 3;
if (is_error == 6) return 6; if (is_error == 6) return 6;
if (is_error == 8) return 8; if (is_error == 8) return 8;
} }
// ====================== 第四步:不需要延迟,直接触发 ====================== // ====================== 第四步:不需要延迟,直接触发 ======================
else if (is_error == 3) else if (is_error == 2)
{ {
return 3; return 2;
} }
else if (is_error == 4) else if (is_error == 4)
{ {
return 4; return 4;
} }
else if(is_error == 5)
{
return 5;
}
// 正在计数,还没到触发条件 // 正在计数,还没到触发条件
return 0; return 0;

10
Core/FSM/Src/motor.c

@ -72,6 +72,7 @@ void Motor_Controller_intialize_CAN2(FDCANHandler *Handler)
} }
int heart_count=0;
void MotorCommandsLoop() void MotorCommandsLoop()
{ {
@ -125,13 +126,12 @@ void MotorCommandsLoop()
Consumer_Or_microcontroller_Heartbeat(0x707, Roughening_Motor_Controller, 4); Consumer_Or_microcontroller_Heartbeat(0x707, Roughening_Motor_Controller, 4);
Consumer_Or_microcontroller_Heartbeat(0x708, Roughening_Motor_Controller, 4); Consumer_Or_microcontroller_Heartbeat(0x708, Roughening_Motor_Controller, 4);
Heartbeat_Flag_01=0; Heartbeat_Flag_01=0;
heart_count++;
} }
} }
int32_t LAST_POSITON=0;
int32_t LAST_SPEED=0;
int32_t delta_pos=0;
void MotorCommandsLoop_2_Position() void MotorCommandsLoop_2_Position()
{ {
@ -139,7 +139,6 @@ void MotorCommandsLoop_2_Position()
GV.SwingMotor.Tar_Position_Velcity_RPM=GV.Tar_Position_Velcity_Degree_S*Swing_Speed_Deg_Sencond_motor; GV.SwingMotor.Tar_Position_Velcity_RPM=GV.Tar_Position_Velcity_Degree_S*Swing_Speed_Deg_Sencond_motor;
delta_pos=GV.SwingMotor.Real_Position-GV.SwingMotor.Last_Real_Position;
if (TT_Motor_Need_To_Activate_1 == 1) if (TT_Motor_Need_To_Activate_1 == 1)
{ {
ActivateMotor(3, Roughening_Motor_Controller_CAN2, 6000); ActivateMotor(3, Roughening_Motor_Controller_CAN2, 6000);
@ -165,9 +164,6 @@ void MotorCommandsLoop_2_Position()
Position_Immediately_Setting(3,Roughening_Motor_Controller_CAN2, GV.SwingMotor.Tar_Position_count,GV.SwingMotor.Tar_Position_Velcity_RPM,30); Position_Immediately_Setting(3,Roughening_Motor_Controller_CAN2, GV.SwingMotor.Tar_Position_count,GV.SwingMotor.Tar_Position_Velcity_RPM,30);
LAST_POSITON=GV.SwingMotor.Tar_Position_count;
LAST_SPEED=GV.SwingMotor.Tar_Position_Velcity_RPM;
break; break;
case 2: case 2:
Position_Lag_Setting(3,Roughening_Motor_Controller_CAN2, GV.SwingMotor.Tar_Position_count,GV.SwingMotor.Tar_Position_Velcity_RPM,30); Position_Lag_Setting(3,Roughening_Motor_Controller_CAN2, GV.SwingMotor.Tar_Position_count,GV.SwingMotor.Tar_Position_Velcity_RPM,30);

4
Core/FSM/Src/paint_gun_action.c

@ -70,7 +70,7 @@ void PaintGun_Contronl()
} }
else //受到限制控制推杆 else //受到限制控制推杆
{ {
if(GV.Now_press>3000) //若压力太大则强制抬起 if(GV.Now_press>6000) //若压力太大则强制抬起
{ {
strainGaugeValue->MotorControl=1; strainGaugeValue->MotorControl=1;
} }
@ -103,7 +103,7 @@ void PaintGun_Contronl_Press()
{ {
GV.Now_press=strainGaugeValue->Pressure; GV.Now_press=strainGaugeValue->Pressure;
curr_io_state = GetIOState(); curr_io_state = GetIOState();
if(curr_io_state==IO_STATE_RISE||(GV.Now_press>3000)) if(curr_io_state==IO_STATE_RISE||(GV.Now_press>6000))
{ {
strainGaugeValue->MotorControl=1; strainGaugeValue->MotorControl=1;
} }

53
Core/FSM/Src/robot_move_actions.c

@ -28,7 +28,7 @@
#define SPEED_FACTOR_SMALL 0.15f /* 小误差速度系数 */ #define SPEED_FACTOR_SMALL 0.15f /* 小误差速度系数 */
#define SPEED_BASE 4.0f /* 电机速度基准 (m/min) */ #define SPEED_BASE 4.0f /* 电机速度基准 (m/min) */
#define K_OF_DIS_VER 1.011189f /* 最小二乘拟合的k */ #define K_OF_DIS_VER 1.011189f /* 最小二乘拟合的k */
#define B_OF_DIS_VER 0.387616f /* 最小二乘拟合的b */ #define B_OF_DIS_VER -0.612384f // 0.387616f /* 最小二乘拟合的b */
#define K_OF_DIS_HOR 1.013714f /* 最小二乘拟合的k */ #define K_OF_DIS_HOR 1.013714f /* 最小二乘拟合的k */
#define B_OF_DIS_HOR 3.226667f /* 最小二乘拟合的b */ #define B_OF_DIS_HOR 3.226667f /* 最小二乘拟合的b */
@ -126,6 +126,7 @@ typedef enum {
static FsmType s_activeFsm; static FsmType s_activeFsm;
static FsmType s_lastActiveFsm=FSM_init_state; static FsmType s_lastActiveFsm=FSM_init_state;
static int s_fsmState[FSM_COUNT] = {0}; static int s_fsmState[FSM_COUNT] = {0};
extern int pos_flag; //控制延时停摆臂只读一次角度
int s_currentState = STATE_ATTITUDE_JUDGE; int s_currentState = STATE_ATTITUDE_JUDGE;
int horizontal_s_currentState = STATE_ATTITUDE_JUDGE; int horizontal_s_currentState = STATE_ATTITUDE_JUDGE;
int vertical_s_currentState = STATE_ATTITUDE_JUDGE; int vertical_s_currentState = STATE_ATTITUDE_JUDGE;
@ -397,6 +398,7 @@ void Robot_Stop(void)
alternately_times =0; alternately_times =0;
alternately_times_total=0; alternately_times_total=0;
alternately_flag=0; alternately_flag=0;
pos_flag=0;
GV.auto_working=0; GV.auto_working=0;
get_swing_mode(); //仅在机器人停的时候允许更新摆臂模式 get_swing_mode(); //仅在机器人停的时候允许更新摆臂模式
@ -477,9 +479,25 @@ static void handleAttitudeJudge_horizontal(void)
{ {
float robotRoll = (float)GV.TL720DParameters.RF_Angle_Roll / 100.0f; float robotRoll = (float)GV.TL720DParameters.RF_Angle_Roll / 100.0f;
if (robotRoll > -180.0f && robotRoll < 0.0f) { // if (robotRoll > -180.0f && robotRoll < 0.0f) {
// GV.Robot_Angle_Desire = -90.0f + (float)GV.Right_Compensation / 100.0f + GV.Vertical_Adjust;
// } else {
// GV.Robot_Angle_Desire = 90.0f + (float)GV.Left_Compensation / 100.0f + GV.Vertical_Adjust;
// }
if(GV.Robot_Desired_Speed>0&&robotRoll < 0.0f) //向左前进
{
GV.Robot_Angle_Desire = -90.0f + (float)GV.Left_Compensation / 100.0f + GV.Vertical_Adjust;
}
else if(GV.Robot_Desired_Speed<0&&robotRoll < 0.0f) //向右后退
{
GV.Robot_Angle_Desire = -90.0f + (float)GV.Right_Compensation / 100.0f + GV.Vertical_Adjust; GV.Robot_Angle_Desire = -90.0f + (float)GV.Right_Compensation / 100.0f + GV.Vertical_Adjust;
} else { }
else if(GV.Robot_Desired_Speed>0&&robotRoll >= 0.0f) //向右前进
{
GV.Robot_Angle_Desire = 90.0f + (float)GV.Right_Compensation / 100.0f + GV.Vertical_Adjust;
}
else if(GV.Robot_Desired_Speed<0&&robotRoll >= 0.0f) //向左后退
{
GV.Robot_Angle_Desire = 90.0f + (float)GV.Left_Compensation / 100.0f + GV.Vertical_Adjust; GV.Robot_Angle_Desire = 90.0f + (float)GV.Left_Compensation / 100.0f + GV.Vertical_Adjust;
} }
s_fsmState[s_activeFsm]=STATE_ATTITUDE_ADJUST; s_fsmState[s_activeFsm]=STATE_ATTITUDE_ADJUST;
@ -759,9 +777,26 @@ void Update_Angle_compensation_hor(void)
{ {
float robotRoll = (float)GV.TL720DParameters.RF_Angle_Roll / 100.0f; float robotRoll = (float)GV.TL720DParameters.RF_Angle_Roll / 100.0f;
if (robotRoll > -180.0f && robotRoll < 0.0f) { // if (robotRoll > -180.0f && robotRoll < 0.0f) {
// GV.Robot_Angle_Desire = -90.0f + (float)GV.Right_Compensation / 100.0f + GV.Vertical_Adjust;
// } else {
// GV.Robot_Angle_Desire = 90.0f + (float)GV.Left_Compensation / 100.0f + GV.Vertical_Adjust;
// }
if(GV.Robot_Desired_Speed>0&&robotRoll < 0.0f) //向左前进
{
GV.Robot_Angle_Desire = -90.0f + (float)GV.Left_Compensation / 100.0f + GV.Vertical_Adjust;
}
else if(GV.Robot_Desired_Speed<0&&robotRoll < 0.0f) //向右后退
{
GV.Robot_Angle_Desire = -90.0f + (float)GV.Right_Compensation / 100.0f + GV.Vertical_Adjust; GV.Robot_Angle_Desire = -90.0f + (float)GV.Right_Compensation / 100.0f + GV.Vertical_Adjust;
} else { }
else if(GV.Robot_Desired_Speed>0&&robotRoll >= 0.0f) //向右前进
{
GV.Robot_Angle_Desire = 90.0f + (float)GV.Right_Compensation / 100.0f + GV.Vertical_Adjust;
}
else if(GV.Robot_Desired_Speed<0&&robotRoll >= 0.0f) //向左后退
{
GV.Robot_Angle_Desire = 90.0f + (float)GV.Left_Compensation / 100.0f + GV.Vertical_Adjust; GV.Robot_Angle_Desire = 90.0f + (float)GV.Left_Compensation / 100.0f + GV.Vertical_Adjust;
} }
} }
@ -930,7 +965,15 @@ void get_swing_mode(void)
left_compare_value=center_angle-offset_angle/2; left_compare_value=center_angle-offset_angle/2;
if(left_compare_value<-90) //左限位
{
left_compare_value=-90;
}
right_compare_value=center_angle+offset_angle/2; right_compare_value=center_angle+offset_angle/2;
if(right_compare_value>90) //右限位
{
right_compare_value=90;
}
} }
else if(GV.symmetricalOrNot==2) //非对称式 else if(GV.symmetricalOrNot==2) //非对称式

8
Core/FSM/Src/swing_action.c

@ -127,7 +127,7 @@ void Move_Swing_Halt_Func_Do(void)
//延几度再停 //延几度再停
Position_angle= -(float)GV.SwingMotor.Real_Position/11014 Position_angle= -(float)GV.SwingMotor.Real_Position/11014
+GV.Robot_Swing_Speed*0.5; +GV.Robot_Swing_Speed*0.5;
if(Position_angle>90) if(Position_angle>90) //别超右极限
{ {
Position_angle=90; Position_angle=90;
} }
@ -139,7 +139,7 @@ void Move_Swing_Halt_Func_Do(void)
//延几度再停 //延几度再停
Position_angle= -(float)GV.SwingMotor.Real_Position/11014 Position_angle= -(float)GV.SwingMotor.Real_Position/11014
-GV.Robot_Swing_Speed*0.5; -GV.Robot_Swing_Speed*0.5;
if(Position_angle<-90) if(Position_angle<-90) //别超左极限
{ {
Position_angle=-90; Position_angle=-90;
} }
@ -149,12 +149,16 @@ void Move_Swing_Halt_Func_Do(void)
else else
{ {
GV.Tar_Position_Velcity_Degree_S=0; GV.Tar_Position_Velcity_Degree_S=0;
GV.SwingMotor.Tar_Position_count=0;
} }
} }
else else
{ {
//GV.Tar_Position_Velcity_Degree_S=0; //GV.Tar_Position_Velcity_Degree_S=0;
//GV.SwingMotor.Tar_Position_count=0;
//GV.Tar_Position_Velcity_Degree_S=0;
} }

38
Core/Src/main.c

@ -110,6 +110,7 @@ int main(void)
// the baud rate of the pressure sensor is 19200 // the baud rate of the pressure sensor is 19200
// tdl720 115200 // tdl720 115200
/* USER CODE END 1 */ /* USER CODE END 1 */
/* MPU Configuration--------------------------------------------------------*/ /* MPU Configuration--------------------------------------------------------*/
@ -127,12 +128,12 @@ int main(void)
HAL_Init(); HAL_Init();
/* USER CODE BEGIN Init */ /* USER CODE BEGIN Init */
// 强制 PH0 内部下拉,消除干扰,防止推杆导致单片机死�???? // 强制 PH0 内部下拉,消除干扰,防止推杆导致单片机死
// __HAL_RCC_GPIOH_CLK_ENABLE(); // __HAL_RCC_GPIOH_CLK_ENABLE();
// GPIO_InitTypeDef gpio_conf = {0}; // GPIO_InitTypeDef gpio_conf = {0};
// gpio_conf.Pin = GPIO_PIN_0; // gpio_conf.Pin = GPIO_PIN_0;
// gpio_conf.Mode = GPIO_MODE_INPUT; // gpio_conf.Mode = GPIO_MODE_INPUT;
// gpio_conf.Pull = GPIO_PULLDOWN; // 关键:内部下�???? // gpio_conf.Pull = GPIO_PULLDOWN; // 关键:内部下
// HAL_GPIO_Init(GPIOH, &gpio_conf); // HAL_GPIO_Init(GPIOH, &gpio_conf);
/* USER CODE END Init */ /* USER CODE END Init */
@ -190,16 +191,18 @@ int main(void)
if(dog_flag==0) if(dog_flag==0)
{ {
//HAL_IWDG_Refresh(&hiwdg1); // 喂狗 //HAL_IWDG_Refresh(&hiwdg1); // 喂狗
Upload_Data_To_HuaWeiCloud();
} }
if (SAVE_To_CV == 1) if (SAVE_To_CV == 1)
{ {
//�??0号机器人的参数传入CV�?? //�????0号机器人的参数传入CV�????
memcpy(&CV, &g_B03_param_table[0], sizeof(CV)); memcpy(&CV, &g_B03_param_table[ROBOT_NUMBER], sizeof(CV));
//恢复SAVE_To_CV值防止重复设�?? //恢复SAVE_To_CV值防止重复设�????
SAVE_To_CV = 0; SAVE_To_CV = 0;
} }
//&CV.operating_times
//CV写入EEPROM //CV写入EEPROM
else if (SAVE_To_CV == 2) else if (SAVE_To_CV == 2)
@ -218,7 +221,7 @@ int main(void)
// if (SAVE_To_CV == 1) // if (SAVE_To_CV == 1)
// { // {
// SAVE_To_CV = 0; // SAVE_To_CV = 0;
// //CV写入falsh�?????????????????????? // //CV写入falsh�????????????????????????
// GF_BSP_EEPROM_Set_CV(CV); // GF_BSP_EEPROM_Set_CV(CV);
// CV = GF_BSP_EEPROM_Get_CV(); // CV = GF_BSP_EEPROM_Get_CV();
// //FS_SetZero(); // //FS_SetZero();
@ -377,7 +380,8 @@ void GF_Robot_Init()
MK32_Sbus_UART_Handler_intialize(&E28_SBUS_UART_Handler); //huart5 MK32_Sbus_UART_Handler_intialize(&E28_SBUS_UART_Handler); //huart5
client_setting_intialize(&LPUART1_UART_Handler); client_setting_intialize(&LPUART1_UART_Handler);
//WH_LTE_7S0_intialize(&LTE_7S0_Serial_UART_Handler);//huart2 WH_LTE_7S0_intialize(&LTE_7S0_Serial_UART_Handler);//huart2
android_485_intialize(&RS_485_2_UART_Handler);
GF_BSP_FDCAN_Init();//初始化FDCAN GF_BSP_FDCAN_Init();//初始化FDCAN
@ -393,6 +397,26 @@ void GF_Robot_Init()
GF_BSP_TIMER_Init(); //定时器最后启 GF_BSP_TIMER_Init(); //定时器最后启
// // 1. �??测模块是否上电正�??
// LTE_CheckModuleAlive();
// // 2. 进入配置命令模式
// LTE_StepIntoConfigMode();
// // 3. 下发全套MQTT参数
// LTE7S0_Init_MQTT();
// // 4. �??出配置模式,进入正常透传收发
// LTE_StepOutOfConfigMode();
// 1. �??测模组串口�?�信
//LTE_CheckModuleAlive_HuaWei();
// 2. 进入AT配置模式
//LTE_StepIntoConfigMode_HuaWei();
// 3. 下发华为云全套MQTT参数
//LTE7S0_Init_HuaWei_MQTT();
// 4. �??出配置,模组自动发起MQTT连接云端
LTE_StepOutOfConfigMode_HuaWei();
// 5.连接到服务器
//LTE_Connect_HuaWei();
} }
/* USER CODE END 4 */ /* USER CODE END 4 */

8
Core/Src/usart.c

@ -53,7 +53,7 @@ void MX_LPUART1_UART_Init(void)
/* USER CODE END LPUART1_Init 1 */ /* USER CODE END LPUART1_Init 1 */
hlpuart1.Instance = LPUART1; hlpuart1.Instance = LPUART1;
hlpuart1.Init.BaudRate = 115200; hlpuart1.Init.BaudRate = 57600;
hlpuart1.Init.WordLength = UART_WORDLENGTH_8B; hlpuart1.Init.WordLength = UART_WORDLENGTH_8B;
hlpuart1.Init.StopBits = UART_STOPBITS_1; hlpuart1.Init.StopBits = UART_STOPBITS_1;
hlpuart1.Init.Parity = UART_PARITY_NONE; hlpuart1.Init.Parity = UART_PARITY_NONE;
@ -327,10 +327,10 @@ void MX_USART3_UART_Init(void)
/* USER CODE END USART3_Init 1 */ /* USER CODE END USART3_Init 1 */
huart3.Instance = USART3; huart3.Instance = USART3;
huart3.Init.BaudRate = 921600; huart3.Init.BaudRate = 115200;
huart3.Init.WordLength = UART_WORDLENGTH_9B; huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1; huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_EVEN; huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX; huart3.Init.Mode = UART_MODE_TX_RX;
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart3.Init.OverSampling = UART_OVERSAMPLING_16; huart3.Init.OverSampling = UART_OVERSAMPLING_16;

80
Swing_Rust_UDP_cabled Debug.launch

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.st.stm32cube.ide.mcu.debug.launch.launchConfigurationType">
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.access_port_id" value="0"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_live_expr" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_swv" value="false"/>
<intAttribute key="com.st.stm32cube.ide.mcu.debug.launch.formatVersion" value="2"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.ip_address_local" value="localhost"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.enabled" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.value" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.loadList" value="{&quot;fItems&quot;:[{&quot;fIsFromMainTab&quot;:true,&quot;fPath&quot;:&quot;Debug/Swing_Rust_UDP_cabled.elf&quot;,&quot;fProjectName&quot;:&quot;Swing_Rust_UDP_cabled&quot;,&quot;fPerformBuild&quot;:true,&quot;fDownload&quot;:true,&quot;fLoadSymbols&quot;:true}]}"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.override_start_address_mode" value="default"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.remoteCommand" value="target remote"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startServer" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.divby0" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.unaligned" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.haltonexception" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swd_mode" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="61235"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_trace_hclk" value="16000000"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.useRemoteTarget" value="true"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.vector_table" value=""/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.verify_flash_download" value="true"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_allow_halt" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_signal_halt" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_external_loader" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_logging" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_max_halt_delay" value="false"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_shared_stlink" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.external_loader" value=""/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.external_loader_init" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.frequency" value="0"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.halt_all_on_reset" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.log_file" value="C:\Users\42961\STM32CubeIDE\workspace_1.10.1\Swing_Rust_UDP_cabled\Debug\st-link_gdbserver_log.txt"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.low_power_debug" value="enable"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.max_halt_delay" value="2"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.reset_strategy" value="connect_under_reset"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverPort" value="cortex_m0"/>
<intAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyPort" value="60000"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="com.st.stm32cube.ide.mcu.debug.stlink"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="61234"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="false"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/Swing_Rust_UDP_cabled.elf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Swing_Rust_UDP_cabled"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.456396271"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/Swing_Rust_UDP_cabled"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;"/>
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
</launchConfiguration>

14
Swing_Rust_UDPV2.ioc → Swing_Rust_UDP_cabled.ioc

@ -201,7 +201,7 @@ GPIO.groupedBy=Group By Peripherals
I2C4.IPParameters=Timing I2C4.IPParameters=Timing
I2C4.Timing=0x10C0ECFF I2C4.Timing=0x10C0ECFF
KeepUserPlacement=false KeepUserPlacement=false
LPUART1.BaudRate=115200 LPUART1.BaudRate=57600
LPUART1.DMADisableonRxErrorParam=UART_ADVFEATURE_DMA_DISABLEONRXERROR LPUART1.DMADisableonRxErrorParam=UART_ADVFEATURE_DMA_DISABLEONRXERROR
LPUART1.IPParameters=BaudRate,OverrunDisableParam,DMADisableonRxErrorParam LPUART1.IPParameters=BaudRate,OverrunDisableParam,DMADisableonRxErrorParam
LPUART1.OverrunDisableParam=UART_ADVFEATURE_OVERRUN_DISABLE LPUART1.OverrunDisableParam=UART_ADVFEATURE_OVERRUN_DISABLE
@ -722,14 +722,14 @@ ProjectManager.MainLocation=Core/Src
ProjectManager.NoMain=false ProjectManager.NoMain=false
ProjectManager.PreviousToolchain=STM32CubeIDE ProjectManager.PreviousToolchain=STM32CubeIDE
ProjectManager.ProjectBuild=false ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=Swing_Rust_UDPV2.ioc ProjectManager.ProjectFileName=Swing_Rust_UDP_cabled.ioc
ProjectManager.ProjectName=Swing_Rust_UDPV2 ProjectManager.ProjectName=Swing_Rust_UDP_cabled
ProjectManager.RegisterCallBack= ProjectManager.RegisterCallBack=
ProjectManager.StackSize=0x2000 ProjectManager.StackSize=0x2000
ProjectManager.TargetToolchain=STM32CubeIDE ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ToolChainLocation= ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=true ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_FDCAN1_Init-FDCAN1-false-HAL-true,5-MX_FDCAN2_Init-FDCAN2-false-HAL-true,6-MX_I2C4_Init-I2C4-false-HAL-true,7-MX_TIM1_Init-TIM1-false-HAL-true,8-MX_UART4_Init-UART4-false-HAL-true,9-MX_UART5_Init-UART5-false-HAL-true,10-MX_UART7_Init-UART7-false-HAL-true,11-MX_USART1_UART_Init-USART1-false-HAL-true,12-MX_USART3_UART_Init-USART3-false-HAL-true,13-MX_USART2_UART_Init-USART2-false-HAL-true,14-MX_USART6_UART_Init-USART6-false-HAL-true,15-MX_TIM8_Init-TIM8-false-HAL-true,16-MX_QUADSPI_Init-QUADSPI-false-HAL-true,17-MX_LPUART1_UART_Init-LPUART1-false-HAL-true,18-MX_ADC2_Init-ADC2-false-HAL-true,19-MX_LWIP_Init-LWIP-false-HAL-false,20-MX_IWDG1_Init-IWDG1-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_FDCAN1_Init-FDCAN1-false-HAL-true,5-MX_FDCAN2_Init-FDCAN2-false-HAL-true,6-MX_I2C4_Init-I2C4-false-HAL-true,7-MX_TIM1_Init-TIM1-false-HAL-true,8-MX_UART4_Init-UART4-false-HAL-true,9-MX_UART5_Init-UART5-false-HAL-true,10-MX_UART7_Init-UART7-false-HAL-true,11-MX_USART1_UART_Init-USART1-false-HAL-true,12-MX_USART3_UART_Init-USART3-false-HAL-true,13-MX_USART2_UART_Init-USART2-false-HAL-true,14-MX_USART6_UART_Init-USART6-false-HAL-true,15-MX_TIM8_Init-TIM8-false-HAL-true,16-MX_QUADSPI_Init-QUADSPI-false-HAL-true,17-MX_LPUART1_UART_Init-LPUART1-false-HAL-true,18-MX_ADC2_Init-ADC2-false-HAL-true,19-MX_LWIP_Init-LWIP-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
QUADSPI.ChipSelectHighTime=QSPI_CS_HIGH_TIME_5_CYCLE QUADSPI.ChipSelectHighTime=QSPI_CS_HIGH_TIME_5_CYCLE
QUADSPI.ClockMode=QSPI_CLOCK_MODE_3 QUADSPI.ClockMode=QSPI_CLOCK_MODE_3
QUADSPI.ClockPrescaler=2-1 QUADSPI.ClockPrescaler=2-1
@ -861,14 +861,14 @@ USART2.DMADisableonRxErrorParam=ADVFEATURE_DMA_DISABLEONRXERROR
USART2.IPParameters=VirtualMode-Asynchronous,OverrunDisableParam,DMADisableonRxErrorParam USART2.IPParameters=VirtualMode-Asynchronous,OverrunDisableParam,DMADisableonRxErrorParam
USART2.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE USART2.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE
USART2.VirtualMode-Asynchronous=VM_ASYNC USART2.VirtualMode-Asynchronous=VM_ASYNC
USART3.BaudRate=921600 USART3.BaudRate=115200
USART3.DMADisableonRxErrorParam=ADVFEATURE_DMA_DISABLEONRXERROR USART3.DMADisableonRxErrorParam=ADVFEATURE_DMA_DISABLEONRXERROR
USART3.FIFOMode=FIFOMODE_ENABLE USART3.FIFOMode=FIFOMODE_ENABLE
USART3.IPParameters=VirtualMode-Asynchronous,DMADisableonRxErrorParam,OverrunDisableParam,FIFOMode,BaudRate,WordLength,Parity USART3.IPParameters=VirtualMode-Asynchronous,DMADisableonRxErrorParam,OverrunDisableParam,FIFOMode,BaudRate,WordLength,Parity
USART3.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE USART3.OverrunDisableParam=ADVFEATURE_OVERRUN_DISABLE
USART3.Parity=PARITY_EVEN USART3.Parity=PARITY_NONE
USART3.VirtualMode-Asynchronous=VM_ASYNC USART3.VirtualMode-Asynchronous=VM_ASYNC
USART3.WordLength=WORDLENGTH_9B USART3.WordLength=WORDLENGTH_8B
USART6.BaudRate=19200 USART6.BaudRate=19200
USART6.DMADisableonRxErrorParam=ADVFEATURE_DMA_ENABLEONRXERROR USART6.DMADisableonRxErrorParam=ADVFEATURE_DMA_ENABLEONRXERROR
USART6.FIFOMode=FIFOMODE_ENABLE USART6.FIFOMode=FIFOMODE_ENABLE
Loading…
Cancel
Save