From b53fff11e6f0d560594834de32886239cbba90a3 Mon Sep 17 00:00:00 2001
From: yincheng.zhong <634916154@qq.com>
Date: 星期二, 16 十二月 2025 15:48:58 +0800
Subject: [PATCH] 外部调完,可以解析下发的MQTT数据了,但是路径文件太大准备换成http模式
---
STM32H743/FML/DBG.c | 134 +++++++++++++++++++++++++-------------------
1 files changed, 76 insertions(+), 58 deletions(-)
diff --git a/STM32H743/FML/DBG.c b/STM32H743/FML/DBG.c
index cc69f6d..3eb71a5 100644
--- a/STM32H743/FML/DBG.c
+++ b/STM32H743/FML/DBG.c
@@ -1,8 +1,8 @@
/*******************************************************************************
* File Name : DBG.c
* Description :
- * Created on : 2018年7月23日
- * Author : 杜键
+ * Created on : 2018锟斤拷7锟斤拷23锟斤拷
+ * Author : 锟脚硷拷
*******************************************************************************/
/*******************************************************************************
@@ -36,7 +36,7 @@
static HIDO_UINT8 l_au8DBGUartTxBuf[DBG_UART_TX_BUF_SIZE];
static HIDO_UINT8 l_u8DBGFlag = DBG_FLAG_ON;
-static E_DBGMode l_eDBGMode = DBG_MODE_CHARGE;
+static E_DBGMode l_eDBGMode = DBG_MODE_SHELL;
/*******************************************************************************
* Local Function Declaration *
*******************************************************************************/
@@ -53,8 +53,8 @@
* Input :
* Output :
* Return :
- * Author : 杜键
- * Modified Date: : 2018年7月23日
+ * Author : 锟脚硷拷
+ * Modified Date: : 2018锟斤拷7锟斤拷23锟斤拷
*******************************************************************************/
static HIDO_INT32 DBG_SerialGetChar(HIDO_UINT8 *_pu8Char)
{
@@ -67,8 +67,8 @@
* Input :
* Output :
* Return :
- * Author : 杜键
- * Modified Date: : 2018年7月23日
+ * Author : 锟脚硷拷
+ * Modified Date: : 2018锟斤拷7锟斤拷23锟斤拷
*******************************************************************************/
static HIDO_INT32 DBG_SerialPrintf(const HIDO_CHAR *_pcFmt, ...)
{
@@ -85,12 +85,12 @@
/*******************************************************************************
* Function Name : DBG_SerialPutString
* Description :
- * Input : _pcString 输出字符串
+ * Input : _pcString 锟斤拷锟斤拷址锟斤拷锟�
* Output :
- * Return : HIDO_OK 成功
- * HIDO_ERR 失败
- * Author : 杜键
- * Modified Date: : 2018年7月23日
+ * Return : HIDO_OK 锟缴癸拷
+ * HIDO_ERR 失锟斤拷
+ * Author : 锟脚硷拷
+ * Modified Date: : 2018锟斤拷7锟斤拷23锟斤拷
*******************************************************************************/
static HIDO_INT32 DBG_SerialPutString(const char *_pcString)
{
@@ -103,13 +103,13 @@
/*******************************************************************************
* Function Name : DBG_SerialPutChar
- * Description : DBG输出一个字符
- * Input : _u8Char 输出字符
+ * Description : DBG锟斤拷锟揭伙拷锟斤拷址锟�
+ * Input : _u8Char 锟斤拷锟斤拷址锟�
* Output :
- * Return : HIDO_OK 成功
- * HIDO_ERR 失败
- * Author : 杜键
- * Modified Date: : 2018年7月23日
+ * Return : HIDO_OK 锟缴癸拷
+ * HIDO_ERR 失锟斤拷
+ * Author : 锟脚硷拷
+ * Modified Date: : 2018锟斤拷7锟斤拷23锟斤拷
*******************************************************************************/
static HIDO_INT32 DBG_SerialPutChar(HIDO_UINT8 _u8Char)
{
@@ -129,8 +129,8 @@
* Input :
* Output :
* Return :
- * Author : 杜键
- * Modified Date: : 2018年7月23日
+ * Author : 锟脚硷拷
+ * Modified Date: : 2018锟斤拷7锟斤拷23锟斤拷
*******************************************************************************/
HIDO_INT32 HIDO_Debug(const HIDO_CHAR *_pcFmt, ...)
{
@@ -176,7 +176,7 @@
u32Len = sizeof(acOutputBuf) - 1;
}
- Uart_Send(UART_ID_DBG, (HIDO_UINT8 *)acOutputBuf, u32Len);
+ Uart_Send(UART_ID_PYTHON, (HIDO_UINT8 *)acOutputBuf, u32Len);
return HIDO_OK;
}
@@ -187,8 +187,8 @@
* Input :
* Output :
* Return :
- * Author : 杜键
- * Modified Date: : 2018年7月23日
+ * Author : 锟脚硷拷
+ * Modified Date: : 2018锟斤拷7锟斤拷23锟斤拷
*******************************************************************************/
HIDO_INT32 HIDO_DebugEx(const HIDO_CHAR *_pcFmt, ...)
{
@@ -202,7 +202,7 @@
HIDO_UINT32 u32Len = 0;
// ST_RTCDateTime stRTCDateTime;
- /* 输出日志格式 */
+ /* 锟斤拷锟斤拷锟街撅拷锟绞� */
// RTC_GetDateTime(&stRTCDateTime);
// u32Len = HIDO_UtilSnprintf(acOutputBuf, sizeof(acOutputBuf), "%04u-%02u-%02u %02u:%02u:%02u.%03u ",
// stRTCDateTime.m_u16Year, stRTCDateTime.m_u8Month, stRTCDateTime.m_u8Day, stRTCDateTime.m_u8Hour,
@@ -224,14 +224,32 @@
return HIDO_OK;
}
+HIDO_INT32 DBG_Printf(const HIDO_CHAR *_pcFmt, ...)
+{
+ va_list ap;
+ HIDO_CHAR acOutputBuf[OUTPUT_BUF_SIZE];
+ HIDO_UINT32 u32Len = 0;
+
+ va_start(ap, _pcFmt);
+ u32Len = vsnprintf(acOutputBuf, sizeof(acOutputBuf), _pcFmt, ap);
+ va_end(ap);
+
+ if (u32Len > (sizeof(acOutputBuf) - 1))
+ {
+ u32Len = sizeof(acOutputBuf) - 1;
+ }
+
+ return Uart_Send(UART_ID_DBG, (HIDO_UINT8 *)acOutputBuf, u32Len);
+}
+
/*******************************************************************************
* Function Name : HIDO_DebugHex
* Description :
* Input :
* Output :
* Return :
- * Author : 杜键
- * Modified Date: : 2018年7月23日
+ * Author : 锟脚硷拷
+ * Modified Date: : 2018锟斤拷7锟斤拷23锟斤拷
*******************************************************************************/
HIDO_INT32 HIDO_DebugHex(const HIDO_UINT8 *_pu8Data, HIDO_UINT32 _u32Len)
{
@@ -277,8 +295,8 @@
* Input :
* Output :
* Return :
- * Author : 杜键
- * Modified Date: : 2018年7月23日
+ * Author : 锟脚硷拷
+ * Modified Date: : 2018锟斤拷7锟斤拷23锟斤拷
*******************************************************************************/
HIDO_INT32 HIDO_DebugString(const HIDO_CHAR *_pu8String, HIDO_UINT32 _u32StringLen)
{
@@ -292,7 +310,7 @@
HIDO_UINT32 u32Len = 0;
ST_RTCDateTime stRTCDateTime;
- /* 输出日志格式 */
+ /* 锟斤拷锟斤拷锟街撅拷锟绞� */
RTC_GetDateTime(&stRTCDateTime);
u32Len = HIDO_UtilSnprintf(acOutputBuf, sizeof(acOutputBuf), "%04u-%02u-%02u %02u:%02u:%02u.%03u ",
stRTCDateTime.m_u16Year, stRTCDateTime.m_u8Month, stRTCDateTime.m_u8Day, stRTCDateTime.m_u8Hour,
@@ -309,8 +327,8 @@
* Input :
* Output :
* Return :
- * Author : 杜键
- * Modified Date: : 2018年7月23日
+ * Author : 锟脚硷拷
+ * Modified Date: : 2018锟斤拷7锟斤拷23锟斤拷
*******************************************************************************/
HIDO_VOID DBG_SetDebugFlag(HIDO_UINT8 _u8Flag)
{
@@ -323,8 +341,8 @@
* Input :
* Output :
* Return :
- * Author : 杜键
- * Modified Date: : 2018年7月23日
+ * Author : 锟脚硷拷
+ * Modified Date: : 2018锟斤拷7锟斤拷23锟斤拷
*******************************************************************************/
HIDO_INT32 DBG_SetMode(E_DBGMode _eMode)
{
@@ -339,8 +357,8 @@
* Input :
* Output :
* Return :
- * Author : 杜键
- * Modified Date: : 2018年7月23日
+ * Author : 锟脚硷拷
+ * Modified Date: : 2018锟斤拷7锟斤拷23锟斤拷
*******************************************************************************/
E_DBGMode DBG_GetMode(void)
{
@@ -349,7 +367,7 @@
#ifdef __APP_CODE__
-// 组包参数
+// 锟斤拷锟斤拷锟斤拷锟�
#define MAX_PACKET_SIZE 1000
#define TIMEOUT_MS 100
@@ -363,7 +381,7 @@
static uart_packet_t g_uart_packet = {0};
-//// 初始化组包结构
+//// 锟斤拷始锟斤拷锟斤拷锟斤拷峁�
//void uart_packet_init(void)
//{
// memset(&g_uart_packet, 0, sizeof(g_uart_packet));
@@ -371,50 +389,50 @@
// lora_uart_receiver_init();
//}
-// 检查超时并处理完整数据包
+// 锟斤拷槌憋拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷莅锟�
void check_timeout_and_process(void)
{
uint32_t current_time = HIDO_TimerGetTick();
- // 检查是否超时且缓冲区有数据
+ // 锟斤拷锟斤拷欠锟绞憋拷一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
if ((g_uart_packet.length > 0) &&
((current_time - g_uart_packet.last_receive_time) >= TIMEOUT_MS))
{
- // 标记数据包就绪
+ // 锟斤拷锟斤拷锟斤拷莅锟斤拷锟斤拷锟�
g_uart_packet.packet_ready = 1;
- // 这里可以调用处理函数,比如:
+ // 锟斤拷锟斤拷锟斤拷缘锟斤拷么锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷纾�
// process_uart_packet(g_uart_packet.buffer, g_uart_packet.length);
UDPClient_Uploadhex(g_uart_packet.buffer, g_uart_packet.length);
- // 重置缓冲区,准备接收下一个数据包
+ // 锟斤拷锟矫伙拷锟斤拷锟斤拷锟斤拷准锟斤拷锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷锟捷帮拷
g_uart_packet.length = 0;
}
}
-//// 主循环中的串口数据处理函数
+//// 锟斤拷循锟斤拷锟叫的达拷锟斤拷锟斤拷锟捷达拷锟斤拷锟斤拷锟斤拷
// void uart_data_handler(void)
//{
// uint8_t u8RecvChar;
//
-// // 检查超时
+// // 锟斤拷槌�
// check_timeout_and_process();
//
-// // 轮询读取串口数据
+// // 锟斤拷询锟斤拷取锟斤拷锟斤拷锟斤拷锟斤拷
// while (Uart_GetChar(UART_ID_DBG, &u8RecvChar) == HIDO_OK) {
-// // 更新最后接收时间
+// // 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷时锟斤拷
// g_uart_packet.last_receive_time = HIDO_TimerGetTick();
//
-// // 检查缓冲区是否已满
+// // 锟斤拷榛猴拷锟斤拷锟斤拷欠锟斤拷锟斤拷锟�
// if (g_uart_packet.length < MAX_PACKET_SIZE) {
-// // 存储接收到的字符
+// // 锟芥储锟斤拷锟秸碉拷锟斤拷锟街凤拷
// g_uart_packet.buffer[g_uart_packet.length++] = u8RecvChar;
//
// } else {
-// // 缓冲区溢出处理
+// // 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
// printf("Buffer overflow!\n");
-// g_uart_packet.length = 0; // 清空缓冲区
+// g_uart_packet.length = 0; // 锟斤拷栈锟斤拷锟斤拷锟�
// }
// }
// }
@@ -423,7 +441,7 @@
uint8_t chargedbg_flag;
HIDO_VOID DBG_Poll(void)
{
- // 有5V输入的时候,默认是给调试口
+ // 锟斤拷5V锟斤拷锟斤拷锟绞憋拷锟侥拷锟斤拷歉锟斤拷锟斤拷钥锟�
if (DBG_GetMode() == DBG_MODE_SHELL)
{
HIDO_InputPoll();
@@ -539,17 +557,17 @@
{
g_uart_packet.last_receive_time = HIDO_TimerGetTick();
- // 检查缓冲区是否已满
+ // 锟斤拷榛猴拷锟斤拷锟斤拷欠锟斤拷锟斤拷锟�
if (g_uart_packet.length < MAX_PACKET_SIZE)
{
- // 存储接收到的字符
+ // 锟芥储锟斤拷锟秸碉拷锟斤拷锟街凤拷
g_uart_packet.buffer[g_uart_packet.length++] = u8RecvChar;
}
else
{
- // 缓冲区溢出处理
+ // 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
printf("Buffer overflow!\n");
- g_uart_packet.length = 0; // 清空缓冲区
+ g_uart_packet.length = 0; // 锟斤拷栈锟斤拷锟斤拷锟�
}
}
// HAL_UART_Transmit(pstUartHandle, &u8RecvChar, 1, 1000);
@@ -560,12 +578,12 @@
/*******************************************************************************
* Function Name : DBG_Init
- * Description : 调试打印初始化
+ * Description : 锟斤拷锟皆达拷印锟斤拷始锟斤拷
* Input : None
* Output : None
* Return : None
- * Author : 杜键
- * Modified Date: : 2018年7月23日
+ * Author : 锟脚硷拷
+ * Modified Date: : 2018锟斤拷7锟斤拷23锟斤拷
*******************************************************************************/
HIDO_VOID DBG_Init(void)
{
--
Gitblit v1.10.0