Browse Source

平峰项目BMS协议更改-未测试

LAPTOP-KB7QFH2U\ChenJie-PC 2 years ago
parent
commit
004fdb5876

+ 4 - 4
.settings/language.settings.xml

@@ -5,7 +5,7 @@
 			<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.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1789340707480773096" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1225283376601702587" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS 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.g++"/>
 			</provider>
@@ -16,7 +16,7 @@
 			<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.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1789340707480773096" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1225283376601702587" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS 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.g++"/>
 			</provider>
@@ -27,7 +27,7 @@
 			<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.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1789340707480773096" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1225283376601702587" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS 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.g++"/>
 			</provider>
@@ -38,7 +38,7 @@
 			<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.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
-			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1789340707480773096" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+			<provider class="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1225283376601702587" id="com.freescale.s32ds.cross.gnu.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT S32DS 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.g++"/>
 			</provider>

+ 17 - 0
.vscode/c_cpp_properties.json

@@ -0,0 +1,17 @@
+{
+    "configurations": [
+        {
+            "name": "Win32",
+            "includePath": [
+                "${workspaceFolder}/**"
+            ],
+            "defines": [
+                "_DEBUG",
+                "UNICODE",
+                "_UNICODE"
+            ],
+            "intelliSenseMode": "windows-msvc-x64"
+        }
+    ],
+    "version": 4
+}

+ 34 - 34
src/AppFuncLib.c

@@ -9,8 +9,8 @@
  */
 /*
  * AppFuncLib.c
- *应用层函数库
- *  Created on: 2022年1月21日
+ *搴旂敤灞傚嚱鏁板簱
+ *  Created on: 2022骞�1鏈�21鏃�
  *      Author: QiXiang_CHENJIE
  */
 
@@ -19,7 +19,7 @@
 #include "Hal_Fls.h"
 #include "AppTaskUart1.h"
 /**
- * @brief : 获取故障码函数,从故障数组中获取故障码,并将之前的故障码向前移动
+ * @brief : 鑾峰彇鏁呴殰鐮佸嚱鏁帮紝浠庢晠闅滄暟缁勪腑鑾峰彇鏁呴殰鐮侊紝骞跺皢涔嬪墠鐨勬晠闅滅爜鍚戝墠绉诲姩
  * @param {UINT16} *ErrorArray
  * @param {UINT8} Errorlen
  * @return {*}
@@ -112,7 +112,7 @@ unsigned char HexToChar(unsigned char bHex)
 {
     if ((bHex >= 0) && (bHex <= 9))
         bHex += 0x30;
-    else if ((bHex >= 10) && (bHex <= 15)) //大写字母
+    else if ((bHex >= 10) && (bHex <= 15)) //澶у啓瀛楁瘝
         bHex += 0x37;
     else
         bHex = 0xff;
@@ -122,9 +122,9 @@ unsigned char CharToHex(unsigned char bChar)
 {
     if ((bChar >= 0x30) && (bChar <= 0x39))
         bChar -= 0x30;
-    else if ((bChar >= 0x41) && (bChar <= 0x46)) //大写字母
+    else if ((bChar >= 0x41) && (bChar <= 0x46)) //澶у啓瀛楁瘝
         bChar -= 0x37;
-    else if ((bChar >= 0x61) && (bChar <= 0x66)) //小写字母
+    else if ((bChar >= 0x61) && (bChar <= 0x66)) //灏忓啓瀛楁瘝
         bChar -= 0x57;
     else
         bChar = 0xff;
@@ -135,7 +135,7 @@ uint8 AtStrCompare(const char *a, const char *b)
     uint8 out = 1;
     while (1)
     {
-        if (*a == '\0' || *b == '\0') //判断其中是否有字符串结束
+        if (*a == '\0' || *b == '\0') //鍒ゆ柇鍏朵腑鏄�惁鏈夊瓧绗︿覆缁撴潫
         {
             if (strlen(a) == strlen(b))
             {
@@ -219,10 +219,10 @@ char *Myitoa(int value, char *result, int base)
 }
 
 /************************************************************************
- * @brief 整数转字符串
- * @param[in] num 整数
- * @param[out] buf 字符串
- * @return 返回字符串长度
+ * @brief 鏁存暟杞�瓧绗︿覆
+ * @param[in] num 鏁存暟
+ * @param[out] buf 瀛楃�涓�
+ * @return 杩斿洖瀛楃�涓查暱搴�
  ************************************************************************/
 inline int _itoa(int num, char buf[32])
 {
@@ -230,11 +230,11 @@ inline int _itoa(int num, char buf[32])
 }
 
 /************************************************************************
- * @brief 整数转字符串
- * @param[in] num 整数
- * @param[out] buf 字符串
- * @param[in] radix 进位制整数
- * @return 返回字符串长度
+ * @brief 鏁存暟杞�瓧绗︿覆
+ * @param[in] num 鏁存暟
+ * @param[out] buf 瀛楃�涓�
+ * @param[in] radix 杩涗綅鍒舵暣鏁�
+ * @return 杩斿洖瀛楃�涓查暱搴�
  ************************************************************************/
 int _i2a(int num, char buf[32], int radix)
 {
@@ -268,11 +268,11 @@ int _i2a(int num, char buf[32], int radix)
 }
 
 /************************************************************************
- * @brief 浮点数转字符串
- * @param[in] val 浮点数
- * @param[out] buf 字符串
- * @param[in] eps 精度(小数位)
- * @return 返回字符串长度
+ * @brief 娴�偣鏁拌浆瀛楃�涓�
+ * @param[in] val 娴�偣鏁�
+ * @param[out] buf 瀛楃�涓�
+ * @param[in] eps 绮惧害(灏忔暟浣�)
+ * @return 杩斿洖瀛楃�涓查暱搴�
  ************************************************************************/
 int _ftoa(double val, char buf[32], int eps)
 {
@@ -289,11 +289,11 @@ int _ftoa(double val, char buf[32], int eps)
 }
 
 /************************************************************************
- * @brief 浮点数转字符串:范围(-1, 1)
- * @param[in] val 浮点数
- * @param[out] buf 字符串
- * @param[in] eps 精度(小数位)
- * @return 返回字符串长度
+ * @brief 娴�偣鏁拌浆瀛楃�涓诧細鑼冨洿(-1, 1)
+ * @param[in] val 娴�偣鏁�
+ * @param[out] buf 瀛楃�涓�
+ * @param[in] eps 绮惧害(灏忔暟浣�)
+ * @return 杩斿洖瀛楃�涓查暱搴�
  ************************************************************************/
 int __ftoa(double val, char buf[32], int eps)
 {
@@ -313,8 +313,8 @@ int __ftoa(double val, char buf[32], int eps)
 }
 
 /************************************************************************
- * @brief 替换sprintf
- * @ref 可变长参数列表误区与陷阱——va_arg不可接受的类型
+ * @brief 鏇挎崲sprintf
+ * @ref 鍙�彉闀垮弬鏁板垪琛ㄨ�鍖轰笌闄烽槺鈥斺€攙a_arg涓嶅彲鎺ュ彈鐨勭被鍨�
  * http://www.cppblog.com/ownwaterloo/archive/2009/04/21/80655.aspx
  ************************************************************************/
 int _sprintf(char *dst, const char *format, ...)
@@ -336,7 +336,7 @@ int _sprintf(char *dst, const char *format, ...)
             ++f;
             switch (*f)
             {
-            case 's': // 字符串
+            case 's': // 瀛楃�涓�
             {
                 const char *p = va_arg(ap, char *);
                 n = strlen(p);
@@ -345,7 +345,7 @@ int _sprintf(char *dst, const char *format, ...)
             break;
 
             case 'd':
-            case 'u': // 整数
+            case 'u': // 鏁存暟
             {
                 char buf[32];
                 n = _itoa(va_arg(ap, int), buf);
@@ -353,7 +353,7 @@ int _sprintf(char *dst, const char *format, ...)
             }
             break;
 
-            case 'f': // 浮点数
+            case 'f': // 娴�偣鏁�
             {
                 char buf[32];
                 n = _ftoa(va_arg(ap, double), buf, 6);
@@ -361,7 +361,7 @@ int _sprintf(char *dst, const char *format, ...)
             }
             break;
 
-            case 'x': // 16进制数
+            case 'x': // 16杩涘埗鏁�
             {
                 char buf[32];
                 n = _i2a(va_arg(ap, int), buf, 16);
@@ -369,13 +369,13 @@ int _sprintf(char *dst, const char *format, ...)
             }
             break;
 
-            case 'c': // 字符
+            case 'c': // 瀛楃�
             {
                 *s = va_arg(ap, int);
             }
             break;
 
-            case '%': // 百分号
+            case '%': // 鐧惧垎鍙�
             {
                 *s = '%';
             }

+ 7 - 7
src/AppFuncLib.h

@@ -9,8 +9,8 @@
  */
 /*
  * AppFunc.h
- *Ó¦Óò㺯Êý¿â
- *  Created on: 2022Äê1ÔÂ21ÈÕ
+ *应用层函数库
+ *  Created on: 2022年1月21日
  *      Author: QiXiang_CHENJIE
  */
 
@@ -33,19 +33,19 @@ uint8 AtStrCompare(const char *a, const char *b);
 unsigned short CRC16_Modbus(unsigned char *pdata, int len);
 uint8 bcc_chk(uint8 *data, uint16 length);
 char *Myitoa(int value, char *result, int base);
-// ÕûÊýת×Ö·û´®
+// 整数转字符串
 int _itoa(int num, char buf[32]);
 
 int _i2a(int num, char buf[32], int radix);
 
-// ¸¡µãת×Ö·û´®
+// 浮点转字符串
 int _ftoa(double val, char buf[32], int eps);
 
-// ¸¡µãת×Ö·û´®£¬·¶Î§£¨-1£¬1£©
+// 浮点转字符串,范围(-1,1)
 int __ftoa(double val, char buf[32], int eps);
 
-// Ìæ´úsprintf
+// 替代sprintf
 int _sprintf(char *dst, const char *format, ...);
-//´®¿ÚУÑé
+//串�校验
 uint16 crc_chk(uint8 *data, uint8 length);
 #endif /* APPFUNCLIB_H_ */

+ 36 - 33
src/AppGlobalVar.c

@@ -9,18 +9,18 @@
  */
 /*
  * AppGlobalVar.c
- *应用层全局变量
- *  Created on: 2022年1月19日
+ *搴旂敤灞傚叏灞€鍙橀噺
+ *  Created on: 2022骞�1鏈�19鏃�
  *      Author: QiXiang_CHENJIE
  */
 
 #include "AppGlobalVar.h"
-//测试
+//娴嬭瘯
 
 //*????*//
 uint8 TcpbattSN[17] = {0x31}; //???SN??
 
-volatile uint32 TimerCounter = 0; // ms单位
+volatile uint32 TimerCounter = 0; // ms鍗曚綅
 uint8 Fota_update_flag = 0;
 uint8 Fota_error_flag = 0;
 /*GPS*/
@@ -33,19 +33,22 @@ uint8 CanIf_u8RxIndicationCnt = 0U;
 boolean CanIf_bRxFlag = false;
 QueueHandle_t CanRecvQueueHandle;
 
-/*TCP相关变量*/
-bool TcpSysReboot = 1;//tcp无法联网时,重启使能
+/*TCP鐩稿叧鍙橀噺*/
+bool TcpSysReboot = 1;//tcp鏃犳硶鑱旂綉鏃讹紝閲嶅惎浣胯兘
 char ImeiNum[15] = {0};
 char IccidNum[20] = {0};
 uint8 CSQValue = 0;
-sint8 SocketId = -1;//联网状态
-sint8 RegChkRet = 0;//驻网状态
+sint8 SocketId = -1;//鑱旂綉鐘舵€�
+sint8 RegChkRet = 0;//椹荤綉鐘舵€�
 char WebSiteIp[20] = {0};
 uint8 TcpWorkState = 0;
-//const char WebSiteName[] = "\"iotp.fast-fun.cn\"";
-//uint16 WebSitePort = 8712;
+#if 1
+const char WebSiteName[] = "\"iotp.fast-fun.cn\"";
+uint16 WebSitePort = 8712;
+#else
 const char WebSiteName[] = "\"nas.fast-fun.cn\"";
 uint16 WebSitePort = 8812;
+#endif
 
 #define EEP_START_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"
@@ -53,34 +56,34 @@ AppConfigBody AppConfigInfo={false,true,{defaultSn},{0}};
 #define EEP_STOP_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"
 
-/*以下变量均为串口协议相关变量*/
+/*浠ヤ笅鍙橀噺鍧囦负涓插彛鍗忚�鐩稿叧鍙橀噺*/
 #ifdef APP_UART0_ENABLE
 AppDataBody AppDataInfo = {BMS_CELLNUM, BMS_TEMPNUM};
-uint16 avrgCellVol = 0;			 //平均电压
+uint16 avrgCellVol = 0;			 //骞冲潎鐢靛帇
 uint16 bmsHwVersion = 0;
 uint32 bmsSwVersion = 0;
-uint16 battCellU[BMS_CELLNUM];	 //电池电压
-uint16 battI = 0;				 // BMS电流(tcp上传)
-uint16 battPackVol = 0;			 // bms电压
-uint16 maxCellVol = 0;			 //最大单体电压
-uint16 minCellVol = 0;			 //最小单体电压
-//uint16 socd_pct_vcuSoc = 0;		 // soc(tcp上传,精度0.1)
-//uint16 sohd_pct_bcuSoh = 0;		 // soh(tcp上传,精度0.1)
+uint16 battCellU[BMS_CELLNUM];	 //鐢垫睜鐢靛帇
+uint16 battI = 0;				 // BMS鐢垫祦锛坱cp涓婁紶锛�
+uint16 battPackVol = 0;			 // bms鐢靛帇
+uint16 maxCellVol = 0;			 //鏈€澶у崟浣撶數鍘�
+uint16 minCellVol = 0;			 //鏈€灏忓崟浣撶數鍘�
+//uint16 socd_pct_vcuSoc = 0;		 // soc(tcp涓婁紶锛岀簿搴�0.1)
+//uint16 sohd_pct_bcuSoh = 0;		 // soh(tcp涓婁紶锛岀簿搴�0.1)
 uint32 battBalanceoInfo = 0;  //
-uint32 battProtectState = 0;	 // bms保护状态
-uint32 battWarningState = 0;	 // bms告警状态
-uint8 AvgBattTemp = 0;			 //平均单体温度
-uint8 battCellTemp[BMS_TEMPNUM]; //电池温度
-uint8 Battdesigncap = 0;		 //电池包设计容量
-uint8 battHeatEnableState = 0;	 // bms加热状态
-uint8 battMOSSwitchState = 0;	 // bms mos开关状态
-uint8 battSOC = 0;				 // bms发送soc
-uint8 battSOH = 0;				 // bms发送soh
-uint8 battWorkState = 0;		 // bms工作状态
-uint8 BmsOtherTemp = 0;			 // BMS其他温度,没有其他温度,为0
-uint8 maxCellTemp = 0;			 //最大单体温度
-uint8 minCellTemp = 0;			 //最小单体温度
-uint8 OtherTemp = 0;			 //通讯模块其他温度
+uint32 battProtectState = 0;	 // bms淇濇姢鐘舵€�
+uint32 battWarningState = 0;	 // bms鍛婅�鐘舵€�
+uint8 AvgBattTemp = 0;			 //骞冲潎鍗曚綋娓╁害
+uint8 battCellTemp[BMS_TEMPNUM]; //鐢垫睜娓╁害
+uint8 Battdesigncap = 0;		 //鐢垫睜鍖呰�璁″�閲�
+uint8 battHeatEnableState = 0;	 // bms鍔犵儹鐘舵€�
+uint8 battMOSSwitchState = 0;	 // bms mos寮€鍏崇姸鎬�
+uint8 battSOC = 0;				 // bms鍙戦€乻oc
+uint8 battSOH = 0;				 // bms鍙戦€乻oh
+uint8 battWorkState = 0;		 // bms宸ヤ綔鐘舵€�
+uint8 BmsOtherTemp = 0;			 // BMS鍏朵粬娓╁害,娌℃湁鍏朵粬娓╁害锛屼负0
+uint8 maxCellTemp = 0;			 //鏈€澶у崟浣撴俯搴�
+uint8 minCellTemp = 0;			 //鏈€灏忓崟浣撴俯搴�
+uint8 OtherTemp = 0;			 //閫氳�妯″潡鍏朵粬娓╁害
 uint8 battHeatState = 0;
 uint8 battFanState = 0;
 uint8 battRelayState = 0;

+ 42 - 46
src/AppGlobalVar.h

@@ -16,8 +16,8 @@
 #ifndef APPGLOBALVAR_H_
 #define APPGLOBALVAR_H_
 
-#define APP_UART0_ENABLE //ƽ����Ŀ
-//#define APP_CAN_ENABLE //�ؿ���Ŀ
+#define APP_UART0_ENABLE
+//#define APP_CAN_ENABLE
 
 #include "hal_adapter.h"
 
@@ -30,7 +30,7 @@
 #define BMS_MANUFACTURE 0xFF
 #define BMS_INFO 0xFF
 #define DATA_MODULE_TYPE 0x02
-//*ȫ�ֱ���*//
+
 extern bool TcpSysReboot;
 extern uint8 TcpbattSN[17];
 extern uint8 VIN[17];
@@ -39,8 +39,8 @@ extern uint8 Fota_update_flag;
 extern uint8 Fota_error_flag;
 typedef struct
 {
-    uint8 RealLen;
-    uint8 *DataPtr;
+	uint8 RealLen;
+	uint8 *DataPtr;
 } QueueDataTrans_Type;
 /*GPS*/
 extern QueueHandle_t GpsDataQueueHandle;
@@ -52,7 +52,6 @@ extern uint8 CanIf_u8RxIndicationCnt;
 extern boolean CanIf_bRxFlag;
 extern QueueHandle_t CanRecvQueueHandle;
 
-/*���±�����ΪTCP��ر���*/
 extern uint8 CSQValue;
 extern sint8 SocketId;
 extern sint8 RegChkRet;
@@ -64,10 +63,10 @@ extern char IccidNum[20];
 extern uint8 TcpWorkState;
 typedef struct _AppEppType
 {
-	uint32 battDischrgAccCap; //单位maH
-	uint32 battDischrgAccEnrg;//单位wh
+	uint32 battDischrgAccCap;  //单位maH
+	uint32 battDischrgAccEnrg; //单位wh
 	uint16 battCycleTimes;
-}AppEppBody;
+} AppEppBody;
 typedef struct _AppConfigType
 {
 	bool appSaveFlg;
@@ -77,55 +76,52 @@ typedef struct _AppConfigType
 	uint8 re[20];
 } AppConfigBody;
 extern AppConfigBody AppConfigInfo;
-
-/*���±�����Ϊ����Э����ر���*/
 #define BMS_CELLNUM 120
 #define BMS_TEMPNUM 40
 typedef struct _AppDataType
 {
-    uint8 BattCellCount; //���ģ�����
-    uint8 BattTempCount; //����¶ȸ���
+	uint8 BattCellCount;
+	uint8 BattTempCount;
 } AppDataBody;
 extern AppDataBody AppDataInfo;
-extern uint16 avrgCellVol;              //ƽ����ѹ
-extern uint16 battCellU[BMS_CELLNUM];   //��ص�ѹ
-extern uint16 battI;                    // BMS������tcp�ϴ���
+extern uint16 avrgCellVol;
+extern uint16 battCellU[BMS_CELLNUM];
+extern uint16 battI;
 extern uint16 bmsHwVersion;
 extern uint32 bmsSwVersion;
-extern uint16 battPackVol;              // bms��ѹ
-
-extern uint16 maxCellVol;               //������ѹ
-extern uint16 minCellVol;               //��С�����ѹ
-//extern uint16 socd_pct_vcuSoc;          // soc(tcp�ϴ�������0.1)
-//extern uint16 sohd_pct_bcuSoh;          // soh(tcp�ϴ�������0.1)
+extern uint16 battPackVol;
+extern uint16 maxCellVol;
+extern uint16 minCellVol;
+// extern uint16 socd_pct_vcuSoc;
+// extern uint16 sohd_pct_bcuSoh;
 extern uint32 battBalanceoInfo;
-extern uint32 battProtectState;         // bms����״̬
-extern uint32 battWarningState;         // bms�澯״̬
-extern uint8 AvgBattTemp;               //ƽ�������¶�
-extern uint8 battCellTemp[BMS_TEMPNUM]; //����¶�
-extern uint8 Battdesigncap;             //��ذ��������
-extern uint8 battHeatEnableState;       // bms����ʹ��״̬
-extern uint8 battMOSSwitchState;        // bms mos����״̬
-extern uint8 battSOC;                   // bms����soc
-extern uint8 battSOH;                   // bms����soh
-extern uint8 battWorkState;             // bms����״̬
-extern uint8 BmsOtherTemp;              // BMS�����¶�
-extern uint8 maxCellTemp;               //������¶�
-extern uint8 minCellTemp;               //��С�����¶�
-extern uint8 OtherTemp;                 //ͨѶģ�������¶�
-extern uint8 battHeatState ;
-extern uint8 battFanState ;
-extern uint8 battRelayState ;
-extern uint8 battConverState ;
-extern uint8 battSeparateEnable ;
-extern uint8 battSeparateCtlState ;
-extern uint8 battSeparateState ;
+extern uint32 battProtectState;
+extern uint32 battWarningState;
+extern uint8 AvgBattTemp;
+extern uint8 battCellTemp[BMS_TEMPNUM];
+extern uint8 Battdesigncap;
+extern uint8 battHeatEnableState;
+extern uint8 battMOSSwitchState;
+extern uint8 battSOC;
+extern uint8 battSOH;
+extern uint8 battWorkState;
+extern uint8 BmsOtherTemp;
+extern uint8 maxCellTemp;
+extern uint8 minCellTemp;
+extern uint8 OtherTemp;
+extern uint8 battHeatState;
+extern uint8 battFanState;
+extern uint8 battRelayState;
+extern uint8 battConverState;
+extern uint8 battSeparateEnable;
+extern uint8 battSeparateCtlState;
+extern uint8 battSeparateState;
 extern uint16 ErrorArray[5];
 extern uint32 meterAllPwr[2];
 extern uint32 meterPosPwr[2];
 extern uint32 meterNegPwr[2];
 extern uint32 BattTempR[4];
-extern uint32 battAccEnrg ;
-extern uint32 battAccCap ;
-extern uint16 battAccUseTimes ;
+extern uint32 battAccEnrg;
+extern uint32 battAccCap;
+extern uint16 battAccUseTimes;
 #endif /* APPGLOBALVAR_H_ */

+ 22 - 22
src/AppTaskCan.c

@@ -1,7 +1,7 @@
 /*
  * AppTaskCan.c
  *
- *  Created on: 2022Äê2ÔÂ13ÈÕ
+ *  Created on: 2022年2月13日
  *      Author: QiXiang_CHENJIE
  */
 #include "AppTaskCan.h"
@@ -47,7 +47,7 @@ void CanTask(void *pvParameters)
 				}
 				else
 				{
-					BcuDecodeFunction(CanRxMsg.id,CanRxMsg.data);//canЭÒé½âÎö
+					BcuDecodeFunction(CanRxMsg.id,CanRxMsg.data);//can�议解�
 				}
 			}
 		}while(ret == pdPASS);
@@ -59,12 +59,12 @@ void CanTask(void *pvParameters)
 		if((TimerCounter - timerCounterNow)>=100)
 		{
 			timerCounterNow = TimerCounter;
-			//ζȲɼ¯
+			//温度采集
 			ADC_ReadValue();
 		}
 	}
 }
-//×¢Òâ½âÂ볬ÏÞÎÊÌâ
+//注�解�超�问题
 void BcuDecodeFunction(uint32 ID, uint8 *rawData)
 {
 	switch(ID)
@@ -89,18 +89,18 @@ static void UDSAnsFunc(uint8 *rawData)
 	static uint8 deviceSnRecvFlg = 0;
 	switch(UdsService)
 	{
-	case 0x10://ģʽÇл»
+	case 0x10://模�切�
 	{
 		if(UdsSubService==0x01)
 		{
-			UdsStates = 0x01;//¹Ø±ÕUDSÕï¶Ï
+			UdsStates = 0x01;//关闭UDS诊断
 			UdsAns(true,UdsService,UdsSubService,0x00,NULL,0);
 		}
 		else if(UdsSubService==0x02)
 		{
 			if(UdsStates==0x01||UdsStates==0x02)
 			{
-				UdsStates = 0x02;//´ò¿ªUDSÕï¶Ï
+				UdsStates = 0x02;//打开UDS诊断
 				UdsAns(true,UdsService,UdsSubService,0x00,NULL,0);
 			}
 			else
@@ -110,13 +110,13 @@ static void UDSAnsFunc(uint8 *rawData)
 		}
 		break;
 	}
-	case 0x11://¿ØÖÆ
+	case 0x11://控制
 	{
 		if(UdsStates==0x02)
 		{
 			switch(UdsSubService)
 			{
-				case 0x01://ÖØÆô
+				case 0x01://��
 				{
 					AnsData[0] = APPSWVERSION>>24;
 					AnsData[1] = APPSWVERSION>>16;
@@ -141,13 +141,13 @@ static void UDSAnsFunc(uint8 *rawData)
 		}
 		break;
 	}
-	case 0x22://²éѯ
+	case 0x22://查询
 	{
 		if(UdsStates==0x02)
 		{
 			switch(UdsSubService)
 			{
-			case 0x01://°æ±¾ºÅ²éѯ
+			case 0x01://版本�查询
 			{
 				AnsData[0] = APPSWVERSION>>24;
 				AnsData[1] = APPSWVERSION>>16;
@@ -156,7 +156,7 @@ static void UDSAnsFunc(uint8 *rawData)
 				UdsAns(true,UdsService,UdsSubService,0x00,AnsData,4);
 				break;
 			}
-			case 0x02://SNºÅÂë²éѯ
+			case 0x02://SN��查询
 			{
 				memcpy(AnsData,AppConfigInfo.deviceSn,17);
 				for(uint8 i=0;i<5;i++)
@@ -165,7 +165,7 @@ static void UDSAnsFunc(uint8 *rawData)
 				}
 				break;
 			}
-			case 0x03://ICCID²éѯ
+			case 0x03://ICCID查询
 			{
 				memcpy(AnsData,IccidNum,20);
 				for(uint8 i=0;i<5;i++)
@@ -174,7 +174,7 @@ static void UDSAnsFunc(uint8 *rawData)
 				}
 				break;
 			}
-			case 0x04://IMEI²éѯ
+			case 0x04://IMEI查询
 			{
 				memcpy(AnsData,ImeiNum,15);
 				for(uint8 i=0;i<4;i++)
@@ -183,19 +183,19 @@ static void UDSAnsFunc(uint8 *rawData)
 				}
 				break;
 			}
-			case 0x05://פÍø״̬²éѯ
+			case 0x05://驻网状�查询
 			{
 				AnsData[0]= RegChkRet;
 				UdsAns(true,UdsService,UdsSubService,0x00,AnsData,1);
 				break;
 			}
-			case 0x06://ÁªÍø״̬²éѯ
+			case 0x06://�网状�查询
 			{
 				AnsData[0]= SocketId;
 				UdsAns(true,UdsService,UdsSubService,0x00,AnsData,1);
 				break;
 			}
-			case 0x07://¶¨Î»ÐÅÏ¢²éѯ
+			case 0x07://定�信�查询
 			{
 				GPSInfo GpsRecvData;
 				if (xQueuePeek(GpsDataQueueHandle, &GpsRecvData, 0) == pdPASS)
@@ -225,18 +225,18 @@ static void UDSAnsFunc(uint8 *rawData)
 				}
 				break;
 			}
-			case 0x08://ζȼì²â²éѯ
+			case 0x08://温度检测查询
 			{
 				UdsAns(true,UdsService,UdsSubService,0x00,AnsData,1);
 				break;
 			}
-			case 0x09://µç³ØÐÅÏ¢²éѯ
+			case 0x09://电池信�查询
 			{
 				UdsAns(true,UdsService,UdsSubService,0x00,AnsData,1);
 				BattSendFlg = 1;
 				break;
 			}
-			case 0x0A://ÈýÖáÊý¾Ý²éѯ
+			case 0x0A://三轴数�查询
 			{
 				AnsData[0] = xyzData[0]>>8;
 				AnsData[1] = xyzData[0]>>0;
@@ -258,7 +258,7 @@ static void UDSAnsFunc(uint8 *rawData)
 		}
 		break;
 	}
-	case 0x2E://дÈë
+	case 0x2E://写入
 	{
 		if(UdsStates==0x02)
 		{
@@ -293,7 +293,7 @@ static void UDSAnsFunc(uint8 *rawData)
 		}
 		break;
 	}
-	case 0x31://¿ØÖÆ
+	case 0x31://控制
 	{
 		if(UdsStates==0x02)
 		{

+ 1 - 1
src/AppTaskCan.h

@@ -1,7 +1,7 @@
 /*
  * AppTaskCan.h
  *
- *  Created on: 2022Äê2ÔÂ13ÈÕ
+ *  Created on: 2022Äê2ÔÂ13ÈÕ
  *      Author: QiXiang_CHENJIE
  */
 

+ 13 - 13
src/AppTaskGps.c

@@ -1,7 +1,7 @@
 /*
  * AppTaskGps.c
  *
- *  Created on: 2022Äê2ÔÂ16ÈÕ
+ *  Created on: 2022年2月16日
  *      Author: QiXiang_CHENJIE
  */
 #include "AppTaskGps.h"
@@ -12,8 +12,8 @@ uint8 GpsRecvPtr[1024];
 void GpsTask(void *pvParameters)
 {
 	(void)pvParameters;
-	GpsDataQueueHandle = xQueueCreate(1, sizeof(GPSInfo));//³¤¶ÈΪ1²Å¿ÉÒÔÔÊÐí¸²Ð´
-	Dio_WriteChannel(DioConf_DioChannel_PTD1_GPIO_OUT_MCU_GPS_POW_EN, STD_ON);//GPS¿ª»ú
+	GpsDataQueueHandle = xQueueCreate(1, sizeof(GPSInfo));//长度为1��以�许覆写
+	Dio_WriteChannel(DioConf_DioChannel_PTD1_GPIO_OUT_MCU_GPS_POW_EN, STD_ON);//GPS开机
 	uint16 pReadLen = 0;
 	while(1)
 	{
@@ -40,10 +40,10 @@ void GpsDataDecode(uint8 *msg)
 	uint32 longitude;
 	uint16 direction;
 	memset((uint8 *)&GpsInfoData, 0x00, sizeof(GPSInfo));
-	p = strtok(msg, delim); //½«ÐÅÏ¢½øÐзָî
+	p = strtok(msg, delim); //将信�进行分割
 	p2 = strtok(NULL, delim);
-	p = strtok(p, ","); //ֻȡµÚ1ÐеÄÐÅÏ¢RMC
-	//p = strtok(temp,",");//Ä£Äâ²âÊÔ
+	p = strtok(p, ","); //��第1行的信�RMC
+	//p = strtok(temp,",");//模拟测试
 	if (strcmp(p, "$GNRMC") == 0)
 	{
 		index = 0;
@@ -55,11 +55,11 @@ void GpsDataDecode(uint8 *msg)
 		}
 		if (index > 5 && strcmp(databuffer[2], "A") == 0)
 		{
-			GpsInfoData.locateMark = 0x01; //ÓÐЧ£¬¶«¾­£¬±±Î³Ð´¶¨
+			GpsInfoData.locateMark = 0x01; //有效,东�,北纬写定
 			strdel(databuffer[3], '.');
 			strdel(databuffer[5], '.');
 			strdel(databuffer[7], '.');
-			speedtemp = atol(databuffer[7]) * 1852 / 1e5; //½Ú»»Ë㵥룬1½Ú=1.852kmÿСʱ
+			speedtemp = atol(databuffer[7]) * 1852 / 1e5; //节�算��,1节=1.852km��时
 			GpsInfoData.speed[0] = (speedtemp >> 8) & 0xFF;
 			GpsInfoData.speed[1] = speedtemp & 0xFF;
 			latitude = location_handle(databuffer[3]);
@@ -72,7 +72,7 @@ void GpsDataDecode(uint8 *msg)
 			GpsInfoData.longitude[1] = longitude >> 16;
 			GpsInfoData.longitude[2] = longitude >> 8;
 			GpsInfoData.longitude[3] = longitude;
-			if (speedtemp >= 50) //´óÓÚ5km/h²ÅÊä³ö·½Î»
+			if (speedtemp >= 50) //大于5km/h�输出方�
 			{
 				direction = atol(databuffer[8]);
 				GpsInfoData.direction[0] = direction >> 8;
@@ -91,14 +91,14 @@ void GpsDataDecode(uint8 *msg)
 //				{
 //					AppDataInfo.AccMileage = 0;
 //				}
-//			}ÀÛ¼ÆÀï³ÌµÄÀÛ¼Ó
+//			}累计里程的累加
 		}
 //		GpsInfoData.AccMileage[0] = AppDataInfo.AccMileage >> 24;
 //		GpsInfoData.AccMileage[1] = AppDataInfo.AccMileage >> 16;
 //		GpsInfoData.AccMileage[2] = AppDataInfo.AccMileage >> 8;
 //		GpsInfoData.AccMileage[3] = AppDataInfo.AccMileage;
 	}
-	p2 = strtok(p2, ","); //ֻȡµÚ2ÐеÄÐÅÏ¢GGA
+	p2 = strtok(p2, ","); //��第2行的信�GGA
 	memset(databuffer, 0x00, 20);
 	if (strcmp(p2, "$GNGGA") == 0)
 	{
@@ -111,11 +111,11 @@ void GpsDataDecode(uint8 *msg)
 		}
 		if (index > 9 && (strcmp(databuffer[6], "1") == 0 || strcmp(databuffer[6], "2") == 0))
 		{
-			GpsInfoData.satelliteNum = atol(databuffer[7]); //ÎÀÐÇÊýĿдÈë
+			GpsInfoData.satelliteNum = atol(databuffer[7]); //�星数目写入
 			strdel(databuffer[9], '.');
 			uint16 alt = 0;
 			alt = atol(databuffer[9]) / 10 + 1000;
-			GpsInfoData.altitude[0] = alt >> 8; //º£°Î
+			GpsInfoData.altitude[0] = alt >> 8; //æµ·æ‹”
 			GpsInfoData.altitude[1] = alt;
 			strdel(databuffer[2], '.');
 			strdel(databuffer[4], '.');

+ 1 - 1
src/AppTaskGps.h

@@ -1,7 +1,7 @@
 /*
  * AppTaskGps.h
  *
- *  Created on: 2022Äê2ÔÂ16ÈÕ
+ *  Created on: 2022Äê2ÔÂ16ÈÕ
  *      Author: QiXiang_CHENJIE
  */
 

+ 3 - 3
src/AppTaskMain.c

@@ -1,7 +1,7 @@
 /*
  * AppTaskMain.c
  *
- *  Created on: 2022Äê2ÔÂ22ÈÕ
+ *  Created on: 2022年2月22日
  *      Author: QiXiang_CHENJIE
  */
 
@@ -65,9 +65,9 @@ void MainTask(void *pvParameters)
 			AppConfigInfo.appSaveFlg = false;
 			HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
 		}
-		if(Fota_update_flag || Fota_error_flag)//Éý¼¶Ö¸Áî·¢³ö£¬½øÐÐÖØÆô,»òÕßFTP·þÎñÆ÷³öÏÖÎÊÌ⣬½øÐÐÖØÆô
+		if(Fota_update_flag || Fota_error_flag)//�级指令�出,进行��,或者FTP�务器出现问题,进行��
 		{
-			//ÖØÆôÇ°±£´æÊý¾Ý
+			//����存数�
 			AppConfigInfo.appSaveFlg = false;
 			HAL_EEP_Write(0,(uint8 *)&AppConfigInfo,sizeof(AppConfigInfo));
 			SystemSoftwareReset();

+ 1 - 1
src/AppTaskMain.h

@@ -1,7 +1,7 @@
 /*
  * AppTaskMain.h
  *
- *  Created on: 2022Äê2ÔÂ22ÈÕ
+ *  Created on: 2022Äê2ÔÂ22ÈÕ
  *      Author: QiXiang_CHENJIE
  */
 

+ 184 - 362
src/AppTaskUart0.c

@@ -1,7 +1,7 @@
 /*
  * AppTaskUart0.c
  *
- *  Created on: 2022Äê2ÔÂ22ÈÕ
+ *  Created on: 2022年2月22日
  *      Author: QiXiang_CHENJIE
  */
 #include "AppTaskUart0.h"
@@ -9,20 +9,17 @@
 static process_Uart0 gProcess_Uart0_Task = PROCESS_UART_STATE_IDLE;
 #define PROC_UART0_STATE_SWITCH(a) (gProcess_Uart0_Task = a)
 bool bmsCellInfoDecode(uint8 *dataPtr);
+bool bmsTempInfoDecode(uint8 *dataPtr);
 bool bmsOtherInfoDecode(uint8 *dataPtr);
-void battDataCalFunc(void);
+void UartBusReadDataFunc(uint16 RegAddrBegin, uint16 Reg_Num, bool (*decodeFunc)(uint8 *dataPtr));
+// void battDataCalFunc(void);
+static uint16 UartNoDataReadCounter = 0;
 void Uart0Task(void *pvParameters)
 {
 	(void)pvParameters;
-	UartQueryType Uart0AskMsg;
-	uint16 Reg_Num = 0;
-	uint16 RegAddrBegin = 0;
-	uint16 CRC_chk_buffer = 0;
-	uint16 pReadLen = 0;
 	UartAnsType UartAnsData;
+	uint16 pReadLen = 0;
 	static uint8 writecounter = 0;
-	uint16 UartNoDataReadCounter = 0;
-	uint8 UartDataRecv[256];
 	while (1)
 	{
 		switch (gProcess_Uart0_Task)
@@ -42,239 +39,43 @@ void Uart0Task(void *pvParameters)
 		}
 		case PROCESS_UART_STATE_READ:
 		{
-
-			static uint16 readCnt = 0;
-			/*µçѹµçÁ÷Êý¾Ý¶ÁÈ¡£¨µÚÒ»´Î¶ÁÈ¡£©*/
-			pReadLen = 0;
 			Dio_FlipChannel(DioConf_DioChannel_PTE1_GPIO_OUT_MCU_LED2);
-			RegAddrBegin = 0x00;
-			Reg_Num =AppDataInfo.BattCellCount + 3;
-			Uart0AskMsg.Bms_Address = BMS_ADDRESS_CODE;
-			Uart0AskMsg.Bms_Funcode = UART_READ_CODE;
-			Uart0AskMsg.Reg_Begin_H = RegAddrBegin>>8;
-			Uart0AskMsg.Reg_Begin_L = RegAddrBegin;
-			Uart0AskMsg.Reg_Num_H = Reg_Num >> 8;
-			Uart0AskMsg.Reg_Num_L = Reg_Num;
-			CRC_chk_buffer = crc_chk((uint8 *)&Uart0AskMsg, 6);
-			Uart0AskMsg.CRC_L = CRC_chk_buffer;
-			Uart0AskMsg.CRC_H = CRC_chk_buffer >> 8;
-			/*RS485²éѯÃüÁîÐèҪʹÄÜ*/
-			UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 1000);
-			uint16 ReadLen1 = 0;
-			uint16 ReadLenTar = 0;
-			uint8 ReadDelayCounter = 0;
-			ReadLenTar = (Reg_Num)*2+5;
-			memset((uint8 *)&UartAnsData,0x00,sizeof(UartAnsData));
-			while(1)
-			{
-				UART_Receive_Data(UART_LPUART0, UartDataRecv, &pReadLen, 100);
-				if(pReadLen>2)
-				{
-					memcpy((uint8 *)&UartAnsData+ReadLen1,UartDataRecv,pReadLen);
-					ReadLen1 = ReadLen1 + pReadLen;
-				}
-				else
-				{
-					ReadDelayCounter++;
-				}
-				if(ReadLen1>=ReadLenTar)
-				{
-					ReadDelayCounter = 0;
-					pReadLen = ReadLen1;
-					ReadLen1 = 0;
-					break;
-				}
-				if(ReadDelayCounter>=20)
-				{
-					ReadDelayCounter = 0;
-					pReadLen = 0;
-					ReadLen1 = 0;
-					break;
-				}
-			}
-			if (pReadLen > 0)
-			{
-				uint16 CrcChkGet = 0xffff;
-				uint16 CrcChkCal = 0x0000;
-				CrcChkCal = crc_chk((uint8 *)&UartAnsData, pReadLen-2);
-				CrcChkGet = ((uint16)(UartAnsData.Data[pReadLen-1-3])<<8) | ((uint16)(UartAnsData.Data[pReadLen-2-3]));
-				if(CrcChkCal==CrcChkGet)
-				{
-					bmsCellInfoDecode(UartAnsData.Data);
-					UartNoDataReadCounter = 0;
-				}
-				else
-				{
-					UartNoDataReadCounter++;
-				}
-			}
-			else
-			{
-				UartNoDataReadCounter++;
-			}
-			/*ζȼ°ÆäËû״̬ÐÅÏ¢¶ÁÈ¡£¨µÚ¶þ´Î¶ÁÈ¡£©*/
-			pReadLen = 0;
-			RegAddrBegin = 0x03 + AppDataInfo.BattCellCount;
-			Reg_Num = 0x1B + AppDataInfo.BattTempCount; //¶ÁÈ¡µÄ¼Ä´æÆ÷Êý¾Ý£¬Ôݶ¨£¬·Ö¿ª¶ÁÈ¡
-			Uart0AskMsg.Bms_Address = BMS_ADDRESS_CODE;
-			Uart0AskMsg.Bms_Funcode = UART_READ_CODE;
-			Uart0AskMsg.Reg_Begin_H = RegAddrBegin>>8;
-			Uart0AskMsg.Reg_Begin_L = RegAddrBegin;
-			Uart0AskMsg.Reg_Num_H = Reg_Num >> 8;
-			Uart0AskMsg.Reg_Num_L = Reg_Num;
-			CRC_chk_buffer = crc_chk((uint8 *)&Uart0AskMsg, 6);
-			Uart0AskMsg.CRC_L = CRC_chk_buffer;
-			Uart0AskMsg.CRC_H = CRC_chk_buffer >> 8;
-			/*RS485²éѯÃüÁîÐèҪʹÄÜ*/
-			UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 1000);
-			memset((uint8 *)&UartAnsData,0x00,sizeof(UartAnsData));
-			ReadLenTar = (Reg_Num)*2+5;
-			while(1)
-			{
-				UART_Receive_Data(UART_LPUART0, UartDataRecv, &pReadLen, 100);
-				if(pReadLen>2)
-				{
-					memcpy((uint8 *)&UartAnsData+ReadLen1,UartDataRecv,pReadLen);
-					ReadLen1 = ReadLen1 + pReadLen;
-				}
-				else
-				{
-					ReadDelayCounter++;
-				}
-				if(ReadLen1>=ReadLenTar)
-				{
-					ReadDelayCounter = 0;
-					pReadLen = ReadLen1;
-					ReadLen1 = 0;
-					break;
-				}
-				if(ReadDelayCounter>=20)
-				{
-					ReadDelayCounter = 0;
-					pReadLen = 0;
-					ReadLen1 = 0;
-					break;
-				}
-			}
-			if (pReadLen > 0)
+			//其他�数读�
+			UartBusReadDataFunc(0x01, 0x38, bmsOtherInfoDecode);
+			//电压读�
+			UartBusReadDataFunc(0x64, 120, bmsCellInfoDecode);
+			//温度读�
+			UartBusReadDataFunc(0x190, 40, bmsTempInfoDecode);
+			//没有读到数�时的默认值
+			if (UartNoDataReadCounter > 10)
 			{
-				uint16 CrcChkGet = 0xffff;
-				uint16 CrcChkCal = 0x0000;
-				CrcChkCal = crc_chk((uint8 *)&UartAnsData, pReadLen-2);
-				CrcChkGet =  ((uint16)(UartAnsData.Data[pReadLen-1-3])<<8) | ((uint16)(UartAnsData.Data[pReadLen-2-3]));
-				if(CrcChkCal==CrcChkGet)
-				{
-					bmsOtherInfoDecode(UartAnsData.Data);
-					UartNoDataReadCounter = 0;
-				}
-				else
-				{
-					UartNoDataReadCounter++;
-				}
-			}
-			else
-			{
-				UartNoDataReadCounter++;
-			}
-			//ûÓжÁµ½Êý¾ÝʱµÄĬÈÏÖµ
-			if(UartNoDataReadCounter>10)
-			{
-				memset((uint8 *)&UartAnsData,0x00,sizeof(UartAnsData));
+				memset((uint8 *)&UartAnsData, 0x00, sizeof(UartAnsData));
 				bmsCellInfoDecode(UartAnsData.Data);
+				bmsTempInfoDecode(UartAnsData.Data);
 				bmsOtherInfoDecode(UartAnsData.Data);
-				PutErrorNum(ErrorArray, sizeof(ErrorArray)/2, 1);
+				PutErrorNum(ErrorArray, sizeof(ErrorArray) / 2, 1);
 				vTaskDelay(pdMS_TO_TICKS(5000));
 			}
-			if(readCnt%10==0||0)
-			{
-				/**µç±íÊý¾Ý¶ÁÈ¡*/
-				for(uint8 i=0;i<2;i++)
-				{
-					/*µç±í²ÎÊý¶ÁÈ¡*/
-					static uint16 pt[2] = {0};
-					static uint16 ct[2] = {0};
-					pReadLen = 0;
-					RegAddrBegin = 0x03;
-					Reg_Num = 0x02;
-					Uart0AskMsg.Bms_Address = METER1_ADDRESS_CODE+i;//µÚÒ»´Î¶Á02£¬µÚ¶þ´Î¶Á03
-					Uart0AskMsg.Bms_Funcode = UART_READ_CODE;
-					Uart0AskMsg.Reg_Begin_H = RegAddrBegin>>8;
-					Uart0AskMsg.Reg_Begin_L = RegAddrBegin;
-					Uart0AskMsg.Reg_Num_H = Reg_Num >> 8;
-					Uart0AskMsg.Reg_Num_L = Reg_Num;
-					CRC_chk_buffer = crc_chk((uint8 *)&Uart0AskMsg, 6);
-					Uart0AskMsg.CRC_L = CRC_chk_buffer;
-					Uart0AskMsg.CRC_H = CRC_chk_buffer >> 8;
-					UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 100);
-					UART_Receive_Data(UART_LPUART0, UartDataRecv, &pReadLen, 1000);
-					//µç±íÊý¾Ý½âÎö
-					if (pReadLen > 5)
-					{
-						uint16 CrcChkGet = 0xffff;
-						uint16 CrcChkCal = 0x0000;
-						CrcChkCal = crc_chk(UartDataRecv, pReadLen-2);
-						CrcChkGet =  ((uint16)(*(UartDataRecv+pReadLen-1))<<8) | ((uint16)(*(UartDataRecv+pReadLen-2)));
-						if(CrcChkCal==CrcChkGet)
-						{
-							pt[i] = ((uint16)(*(UartDataRecv+3))<<8) | ((uint16)(*(UartDataRecv+4)));
-							ct[i] = ((uint16)(*(UartDataRecv+5))<<8) | ((uint16)(*(UartDataRecv+6)));
-						}
-					}
-					/*µç±íµçÁ¿Êý¾Ý¶ÁÈ¡*/
-					pReadLen = 0;
-					RegAddrBegin = 0x3F;
-					Reg_Num = 0x04;
-					Uart0AskMsg.Bms_Address = METER1_ADDRESS_CODE+i;//µÚÒ»´Î¶Á02£¬µÚ¶þ´Î¶Á03
-					Uart0AskMsg.Bms_Funcode = UART_READ_CODE;
-					Uart0AskMsg.Reg_Begin_H = RegAddrBegin>>8;
-					Uart0AskMsg.Reg_Begin_L = RegAddrBegin;
-					Uart0AskMsg.Reg_Num_H = Reg_Num >> 8;
-					Uart0AskMsg.Reg_Num_L = Reg_Num;
-					CRC_chk_buffer = crc_chk((uint8 *)&Uart0AskMsg, 6);
-					Uart0AskMsg.CRC_L = CRC_chk_buffer;
-					Uart0AskMsg.CRC_H = CRC_chk_buffer >> 8;
-					UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 100);
-					UART_Receive_Data(UART_LPUART0, UartDataRecv, &pReadLen, 1000);
-					//µç±íÊý¾Ý½âÎö
-					if (pReadLen > 5)
-					{
-						uint16 CrcChkGet = 0xffff;
-						uint16 CrcChkCal = 0x0000;
-						CrcChkCal = crc_chk(UartDataRecv, pReadLen-2);
-						CrcChkGet =  ((uint16)(*(UartDataRecv+pReadLen-1))<<8) | ((uint16)(*(UartDataRecv+pReadLen-2)));
-						if(CrcChkCal==CrcChkGet)
-						{
-							//meterAllPwr[i] = pt[i]*ct[i]*(((uint32)(*(UartRecvPtr+3))<<24)|((uint32)(*(UartRecvPtr+4))<<16)|((uint32)(*(UartRecvPtr+5))<<8) | ((uint32)(*(UartRecvPtr+6))));
-							meterPosPwr[i] = pt[i]*ct[i]*((uint32)(*(UartDataRecv+3))<<24)|((uint32)(*(UartDataRecv+4))<<16)|((uint32)(*(UartDataRecv+5))<<8) | ((uint32)(*(UartDataRecv+6)));
-							meterNegPwr[i] = pt[i]*ct[i]*((uint32)(*(UartDataRecv+7))<<24)|((uint32)(*(UartDataRecv+8))<<16)|((uint32)(*(UartDataRecv+9))<<8) | ((uint32)(*(UartDataRecv+10)));
-							meterPosPwr[i] = meterPosPwr[i] * 100;
-							meterNegPwr[i] = meterNegPwr[i] * 100;
-							meterAllPwr[i] = meterPosPwr[i] + meterNegPwr[i];
-						}
-					}
-				}
-			}
-			readCnt++;
 			PROC_UART0_STATE_SWITCH(PROCESS_UART_STATE_IDLE);
 			break;
 		}
 		case PROCESS_UART_STATE_WRITE:
 		{
-			if(battSeparateEnable)//×î¶àÖØÐÂд5´Î
+			if (battSeparateEnable) //最多�新写5次
 			{
 				uint16 RegAddress = 0;
 				uint16 CRC_chk_buffer = 0;
-				uint8 WriteData[2] = {0x00,0x00};
+				uint8 WriteData[2] = {0x00, 0x00};
 				uint8 UartRecvBuffer[10];
-				if(!battSeparateCtlState)
+				if (!battSeparateCtlState)
 				{
-					setbit(WriteData[0],7);
+					WriteData[1] = 0x55;
 				}
 				else
 				{
-					clrbit(WriteData[0],7);
+					WriteData[1] = 0xAA;
 				}
-				RegAddress = 0x1B + AppDataInfo.BattCellCount + AppDataInfo.BattTempCount;
+				RegAddress = 100;
 				UartWriteMsgType Uart_Write_Msg;
 				Uart_Write_Msg.Bms_Address = BMS_ADDRESS_CODE;
 				Uart_Write_Msg.Bms_Funcode = UART_WRITE_CODE;
@@ -282,13 +83,13 @@ void Uart0Task(void *pvParameters)
 				Uart_Write_Msg.Reg_Begin_L = RegAddress;
 				Uart_Write_Msg.Reg_Num_H = 0x00;
 				Uart_Write_Msg.Reg_Num_L = 0x01;
-				Uart_Write_Msg.Data_Count = 0x02; //ҪдÈëµÄ×Ö½ÚÊý
+				Uart_Write_Msg.Data_Count = 0x02; //�写入的字节数
 				memcpy(Uart_Write_Msg.Data, WriteData, 2);
 				CRC_chk_buffer = crc_chk((uint8 *)&Uart_Write_Msg, sizeof(Uart_Write_Msg) - 2);
 				Uart_Write_Msg.CRC_L = CRC_chk_buffer;
 				Uart_Write_Msg.CRC_H = CRC_chk_buffer >> 8;
-				UART_Query_Data(UART_LPUART0,UART_LPUART0,(uint8 *)&Uart_Write_Msg,sizeof(Uart_Write_Msg),UartRecvBuffer, &pReadLen,500);
-				if (pReadLen>3&&*(UartRecvBuffer+1) == 0x10)
+				UART_Query_Data(UART_LPUART0, UART_LPUART0, (uint8 *)&Uart_Write_Msg, sizeof(Uart_Write_Msg), UartRecvBuffer, &pReadLen, 500);
+				if (pReadLen > 3 && *(UartRecvBuffer + 1) == 0x10)
 				{
 					writecounter = 0;
 					battSeparateEnable = 0;
@@ -298,7 +99,7 @@ void Uart0Task(void *pvParameters)
 					writecounter++;
 				}
 			}
-			if(writecounter>=5)
+			if (writecounter >= 5)
 			{
 				battSeparateEnable = 0;
 				writecounter = 0;
@@ -315,162 +116,183 @@ void Uart0Task(void *pvParameters)
 		}
 	}
 }
-bool bmsCellInfoDecode(uint8 *dataPtr) //¸ù¾Ý´®¿ÚЭÒéÈ·¶¨µÄ½âÂ뺯Êý,µçѹµçÁ÷½âÂë
+bool bmsCellInfoDecode(uint8 *dataPtr) //电压数�解�
+{
+	for (uint8 i = 0; i < BMS_CELLNUM; i++)
+	{
+		battCellU[i] = ((dataPtr[(0x00 + i) * 2] << 8) | dataPtr[(0x00 + i) * 2 + 1]);
+	}
+	return true;
+}
+bool bmsTempInfoDecode(uint8 *dataPtr) //温度数�解�
+{
+	for (uint8 i = 0; i < BMS_TEMPNUM; i++)
+	{
+		battCellTemp[i] = dataPtr[(0x00 + i) * 2 + 1];
+	}
+	return true;
+}
+bool bmsOtherInfoDecode(uint8 *dataPtr) //其他数�解�
 {
-	uint8 i = 0;
-	sint8 BattCurrentNegFlag = 1;
 	uint16 Batt_current;
-	uint8 BATT_CELL_VOL_NUM = 0, BATT_TEMP_NUM = 0;
-	uint32 Battsumvoltage = 0;
-	BATT_CELL_VOL_NUM = (dataPtr[(0x00) * 2] << 8) | (dataPtr[(0x00) * 2 + 1]);
-	BATT_TEMP_NUM = ((dataPtr[(0x01) * 2] << 8) | (dataPtr[(0x01) * 2 + 1])) - BmsOtherTemp;
-	if (BATT_CELL_VOL_NUM != AppDataInfo.BattCellCount || BATT_TEMP_NUM != AppDataInfo.BattTempCount)
+	battPackVol = (dataPtr[(0x00) * 2]) << 8 | (dataPtr[(0x00) * 2 + 1]);
+	Batt_current = (dataPtr[(0x01) * 2] << 8) | (dataPtr[(0x01) * 2 + 1]);
+	battI = Batt_current - 6000; //电��移���
+	battSOC = dataPtr[(0x02) * 2 + 1];
+	battSOH = dataPtr[(0x03) * 2 + 1];
+	battWorkState = (dataPtr[(0x06) * 2 + 1]) & 0x03; //电池状�(原始数�),3表示开路,2表示放电,1表示充电
+	switch (battWorkState)							  //电池状�(上传数�),0表示开路,1表示放电,2表示充电
 	{
-		BATT_CELL_VOL_NUM = AppDataInfo.BattCellCount;
-		BATT_TEMP_NUM = AppDataInfo.BattTempCount;
+	case 0:
+		battWorkState = 0;
+		break;
+	case 1:
+		battWorkState = 2;
+		break;
+	case 2:
+		battWorkState = 1;
+		break;
+	case 3:
+		battWorkState = 0;
+		break;
+	default:
+		break;
 	}
-	Batt_current = (dataPtr[(0x02 + BATT_CELL_VOL_NUM) * 2] << 8) | (dataPtr[(0x02 + BATT_CELL_VOL_NUM) * 2 + 1]);
-	Batt_current = Batt_current*100;//ƽ·åЭÒ鵥λÊÇ1A
-	//ԭʼÊý¾Ý£º³äµçΪ¸º£¬·ÅµçΪÕý
-	if (Batt_current < 0x8000) //³äµç¹ý³Ì
+	maxCellVol = (dataPtr[(0x13) * 2] << 8) | dataPtr[(0x13) * 2 + 1];
+	minCellVol = (dataPtr[(0x16) * 2] << 8) | dataPtr[(0x16) * 2 + 1];
+	AppConfigInfo.AppDataInfo.battDischrgAccEnrg = (dataPtr[(0x34) * 2] << 8) | dataPtr[(0x34) * 2 + 1];
+	AppConfigInfo.AppDataInfo.battCycleTimes = AppConfigInfo.AppDataInfo.battDischrgAccEnrg / 49000;
+	// //故障状�映关系(先完�告警状�简�上传)
+	// uint8 ErrorArrayTemp[32] = {0};
+	// uint8 ErrorArrayNumTemp[32] = {81, 87, 83, 89, 97, 99, 132, 131, 134, 84, 90, 82, 88, 135, 136, 98, 100};
+	// ErrorArrayTemp[0] = getbit(dataPtr[(0x03 + OtherInfoAddrOffset) * 2], 0);				  //电芯电压过高切断告警-0-81
+	// ErrorArrayTemp[1] = getbit(dataPtr[(0x03 + OtherInfoAddrOffset) * 2], 1);				  //总压过高切断告警-1-87
+	// ErrorArrayTemp[2] = getbit(dataPtr[(0x04 + OtherInfoAddrOffset) * 2 + 1], 0);			  //电芯电压过低切断告警2-83
+	// ErrorArrayTemp[3] = getbit(dataPtr[(0x04 + OtherInfoAddrOffset) * 2 + 1], 1);			  //总压过低切断告警3-89
+	// ErrorArrayTemp[4] = getbit(dataPtr[(0x04 + OtherInfoAddrOffset) * 2], 4);				  //�节温度过高切断4-97
+	// ErrorArrayTemp[5] = getbit(dataPtr[(0x04 + OtherInfoAddrOffset) * 2], 5);				  //�节温度过低切断5-99
+	// ErrorArrayTemp[6] = getbit(dataPtr[(0x05 + OtherInfoAddrOffset) * 2 + 1], 1);			  //放电电�切断6-132
+	// ErrorArrayTemp[7] = getbit(dataPtr[(0x05 + OtherInfoAddrOffset) * 2 + 1], 2);			  //充电电�切断7-131
+	// ErrorArrayTemp[8] = getbit(dataPtr[(0x05 + OtherInfoAddrOffset) * 2 + 1], 3);			  // BTU连接告警8-134
+	// ErrorArrayTemp[9] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1], 0);  //�节电压下�告警9-84
+	// ErrorArrayTemp[10] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1], 1); //组电压下�告警10-90
+	// ErrorArrayTemp[11] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1], 2); //�节电压上�告警11-82
+	// ErrorArrayTemp[12] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1], 3); //组�节电压上�告警12-88
+	// ErrorArrayTemp[13] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1], 4); //放电电�告警13-135
+	// ErrorArrayTemp[14] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1], 5); //充电电�告警14-136
+	// ErrorArrayTemp[15] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1], 6); //�节温度上�告警15-98
+	// ErrorArrayTemp[16] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1], 7); //�节温度下线告警16-100
+	// for (uint8 i = 0, j = 0; (i < 32 && j < 5); i++)
+	// {
+	// 	if (ErrorArrayTemp[i] == 1)
+	// 	{
+	// 		PutErrorNum(ErrorArray, sizeof(ErrorArray) / 2, ErrorArrayNumTemp[i]);
+	// 		j++;
+	// 	}
+	// }
+	return true;
+}
+// void battDataCalFunc(void)
+// {
+// 	static uint32 timercounterCal = 0;
+// 	uint16 timediff = 0;
+// 	float battCapTempOnce = 0;
+// 	static float battCapTemp = 0;
+// 	static float battEnrgTemp = 0;
+// 	timediff = TimerCounter - timercounterCal;
+// 	timercounterCal = TimerCounter;
+// 	if (timediff == 0 || timediff > 60 * 1000)
+// 	{
+// 		return;
+// 	}
+// 	if (battI > 10000)
+// 	{
+// 		battCapTempOnce = ((battI - 10000) / 10.0) * (timediff / 3600.0);
+// 		battCapTemp = battCapTempOnce + battCapTemp;
+// 		battEnrgTemp = (battCapTempOnce * battPackVol) / 10000.0 + battEnrgTemp;
+// 		if (battEnrgTemp > 10)
+// 		{
+// 			AppConfigInfo.AppDataInfo.battDischrgAccCap = AppConfigInfo.AppDataInfo.battDischrgAccCap + (uint32)battCapTemp;
+// 			AppConfigInfo.AppDataInfo.battDischrgAccEnrg = AppConfigInfo.AppDataInfo.battDischrgAccEnrg + (uint32)battEnrgTemp;
+// 			AppConfigInfo.AppDataInfo.battCycleTimes = AppConfigInfo.AppDataInfo.battDischrgAccEnrg / 49000;
+// 			AppConfigInfo.appSaveFlg = true;
+// 			battEnrgTemp = 0;
+// 			battCapTemp = 0;
+// 		}
+// 	}
+// }
+
+void UartBusReadDataFunc(uint16 RegAddrBegin, uint16 Reg_Num, bool (*decodeFunc)(uint8 *dataPtr))
+{
+	// argv In
+	UartQueryType Uart0AskMsg;
+	uint16 ReadLen1 = 0;
+	uint16 ReadLenTar = 0;
+	uint8 ReadDelayCounter = 0;
+	uint16 CRC_chk_buffer = 0;
+	uint16 pReadLen;
+	UartAnsType UartAnsData;
+	uint8 UartDataRecv[256];
+	pReadLen = 0;
+	Uart0AskMsg.Bms_Address = BMS_ADDRESS_CODE;
+	Uart0AskMsg.Bms_Funcode = UART_READ_CODE;
+	Uart0AskMsg.Reg_Begin_H = RegAddrBegin >> 8;
+	Uart0AskMsg.Reg_Begin_L = RegAddrBegin;
+	Uart0AskMsg.Reg_Num_H = Reg_Num >> 8;
+	Uart0AskMsg.Reg_Num_L = Reg_Num;
+	CRC_chk_buffer = crc_chk((uint8 *)&Uart0AskMsg, 6);
+	Uart0AskMsg.CRC_L = CRC_chk_buffer;
+	Uart0AskMsg.CRC_H = CRC_chk_buffer >> 8;
+	UART_Send_Data(UART_LPUART0, (uint8 *)&Uart0AskMsg, sizeof(Uart0AskMsg), 1000);
+	ReadLenTar = (Reg_Num)*2 + 5;
+	memset((uint8 *)&UartAnsData, 0x00, sizeof(UartAnsData));
+	while (1)
 	{
-		if (Batt_current > 0x8000) // Êý¾ÝΪ¸º
+		UART_Receive_Data(UART_LPUART0, UartDataRecv, &pReadLen, 100);
+		if (pReadLen > 2)
 		{
-			//Çó²¹Â룬½á¹ûΪ¸º
-			Batt_current = (uint16)((uint16)(~(Batt_current)) + 1);
-			Batt_current = Batt_current / 10;
-			BattCurrentNegFlag = -1;
+			memcpy((uint8 *)&UartAnsData + ReadLen1, UartDataRecv, pReadLen);
+			ReadLen1 = ReadLen1 + pReadLen;
 		}
 		else
 		{
-			//Ô´Â룬½á¹ûΪ¸º
-			Batt_current = Batt_current / 10;
-			BattCurrentNegFlag = -1;
+			ReadDelayCounter++;
 		}
-	}
-	else //·Åµç¹ý³Ì
-	{
-		if (Batt_current > 0x8000) // Êý¾ÝΪ¸º
+		if (ReadLen1 >= ReadLenTar)
 		{
-			//Çó²¹Â룬½á¹ûΪÕý
-			Batt_current = (uint16)((uint16)(~(Batt_current)) + 1);
-			Batt_current = Batt_current / 10;
-			BattCurrentNegFlag = 1;
+			ReadDelayCounter = 0;
+			pReadLen = ReadLen1;
+			ReadLen1 = 0;
+			break;
 		}
-		else
+		if (ReadDelayCounter >= 20)
 		{
-			//Ô´Â룬½á¹ûΪÕý
-			Batt_current = Batt_current / 10;
-			BattCurrentNegFlag = 1;
+			ReadDelayCounter = 0;
+			pReadLen = 0;
+			ReadLen1 = 0;
+			break;
 		}
 	}
-	battI = Batt_current * BattCurrentNegFlag + 0x2710;
-	// sint16 BattI_Temp = 0;//×öµçѹ²¹³¥ÐèÒªµÄ²ÎÊý
-	// BattI_Temp = Batt_current * BattCurrentNegFlag;
-	for (i = 0; i < BATT_CELL_VOL_NUM; i++)
+	if (pReadLen > 0)
 	{
-		//battCellU[i] = ((dataPtr[(0x02 + i) * 2] << 8) | dataPtr[(0x02 + i) * 2 + 1]) + (INT16)(cmnm_R_voloffset[i] * BattI_Temp / 10000);//²»Ê¹Óõçѹ²¹³¥
-		battCellU[i] = ((dataPtr[(0x02 + i) * 2] << 8) | dataPtr[(0x02 + i) * 2 + 1]);
-		Battsumvoltage = Battsumvoltage + battCellU[i];
-	}
-	avrgCellVol = Battsumvoltage / BATT_CELL_VOL_NUM;
-	battPackVol = Battsumvoltage/100;
-	battDataCalFunc();
-	return true;
-}
-bool bmsOtherInfoDecode(uint8 *dataPtr)//ÆäËûÊý¾Ý½âÎö
-{
-	uint8 TEMP_NUM = 0, temp = 0;
-
-	sint8 OtherInfoAddrOffset = -3;//ÆäËûÊý¾Ý½âÎöµÄÆðʼλÖøı䣬ÐèÒªÏòÇ°¼õ3
-	TEMP_NUM = AppDataInfo.BattTempCount + BmsOtherTemp;
-	 bmsHwVersion = dataPtr[(0x08 + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1];
-	 bmsSwVersion = dataPtr[(0x08 + OtherInfoAddrOffset + TEMP_NUM) * 2];
-
-	temp = ((dataPtr[(0x09 + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1]) >> 1) & 0x03;
-	battMOSSwitchState = ((temp & 0x01) << 1) | ((temp & 0x02) >> 1);
-	battSOC = dataPtr[(0x0B + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1];
-	battSOH = dataPtr[(0x0C + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1];
-	Battdesigncap = (dataPtr[(0x0E + OtherInfoAddrOffset + TEMP_NUM) * 2]) << 24 | (dataPtr[(0x0E + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1]) << 16 | (dataPtr[(0x0F + OtherInfoAddrOffset + TEMP_NUM) * 2]) << 8 | (dataPtr[(0x0F + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1]);
-//	battPackVol = ((dataPtr[(0x18 + OtherInfoAddrOffset + TEMP_NUM) * 2]) << 8 | (dataPtr[(0x18 + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1])) / 10; // uint 100mV
-	maxCellVol = (dataPtr[(0x19 + OtherInfoAddrOffset + TEMP_NUM) * 2] << 8) | dataPtr[(0x19 + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1];
-	minCellVol = (dataPtr[(0x1A + OtherInfoAddrOffset + TEMP_NUM) * 2] << 8) | dataPtr[(0x1A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1];
-	for (uint8 i = 0; i < AppDataInfo.BattTempCount; i++)
-	{
-		battCellTemp[i] = dataPtr[(0x06 + OtherInfoAddrOffset + i) * 2 + 1];
-	}
-	battWorkState = (dataPtr[(0x03 + OtherInfoAddrOffset) * 2 + 1]) & 0x03; //µç³Ø״̬(ԭʼÊý¾Ý)£¬0±íʾ¾²Öã¬1±íʾ·Åµç£¬2±íʾ³äµç
-	//״̬Á¿ÉÏ´«
-	battHeatState = getbit(dataPtr[(0x09 + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1],5);
-	battFanState = getbit(dataPtr[(0x09 + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1],3);
-	battRelayState = getbit(dataPtr[(0x09 + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1],4);
-	battConverState = getbit(dataPtr[(0x09 + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1],6);
-	battSeparateState = !getbit(dataPtr[(0x1B + OtherInfoAddrOffset + TEMP_NUM) * 2],7);
-	if (battSeparateState==1)
-	{
-		battMOSSwitchState = battMOSSwitchState | (0x01 << 2);
-	}
-	else
-	{
-		battMOSSwitchState = battMOSSwitchState | (0x00 << 2);
-	}
-	//¹ÊÕÏ״̬ӳ¹Øϵ(ÏÈÍê³É¸æ¾¯×´Ì¬¼òµ¥ÉÏ´«)
-	uint8 ErrorArrayTemp[32] ={0};
-	uint8 ErrorArrayNumTemp[32]={81,87,83,89,97,99,132,131,134,84,90,82,88,135,136,98,100};
-	ErrorArrayTemp[0] = getbit(dataPtr[(0x03 + OtherInfoAddrOffset) * 2],0);//µçоµçѹ¹ý¸ßÇжϸ澯-0-81
-	ErrorArrayTemp[1] = getbit(dataPtr[(0x03 + OtherInfoAddrOffset) * 2],1);//×Üѹ¹ý¸ßÇжϸ澯-1-87
-	ErrorArrayTemp[2] = getbit(dataPtr[(0x04 + OtherInfoAddrOffset) * 2 + 1],0);//µçоµçѹ¹ýµÍÇжϸ澯2-83
-	ErrorArrayTemp[3] = getbit(dataPtr[(0x04 + OtherInfoAddrOffset) * 2 + 1],1);//×Üѹ¹ýµÍÇжϸ澯3-89
-	ErrorArrayTemp[4] = getbit(dataPtr[(0x04 + OtherInfoAddrOffset) * 2],4);//µ¥½Úζȹý¸ßÇжÏ4-97
-	ErrorArrayTemp[5] = getbit(dataPtr[(0x04 + OtherInfoAddrOffset) * 2],5);//µ¥½ÚζȹýµÍÇжÏ5-99
-	ErrorArrayTemp[6] = getbit(dataPtr[(0x05 + OtherInfoAddrOffset) * 2 + 1],1);//·ÅµçµçÁ÷ÇжÏ6-132
-	ErrorArrayTemp[7] = getbit(dataPtr[(0x05 + OtherInfoAddrOffset) * 2 + 1],2);//³äµçµçÁ÷ÇжÏ7-131
-	ErrorArrayTemp[8] = getbit(dataPtr[(0x05 + OtherInfoAddrOffset) * 2 + 1],3);//BTUÁ¬½Ó¸æ¾¯8-134
-	ErrorArrayTemp[9] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1],0);//µ¥½ÚµçѹÏÂÏ޸澯9-84
-	ErrorArrayTemp[10] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1],1);//×éµçѹÏÂÏ޸澯10-90
-	ErrorArrayTemp[11] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1],2);//µ¥½ÚµçѹÉÏÏ޸澯11-82
-	ErrorArrayTemp[12] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1],3);//×éµ¥½ÚµçѹÉÏÏ޸澯12-88
-	ErrorArrayTemp[13] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1],4);//·ÅµçµçÁ÷¸æ¾¯13-135
-	ErrorArrayTemp[14] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1],5);//³äµçµçÁ÷¸æ¾¯14-136
-	ErrorArrayTemp[15] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1],6);//µ¥½ÚζÈÉÏÏ޸澯15-98
-	ErrorArrayTemp[16] = getbit(dataPtr[(0x0A + OtherInfoAddrOffset + TEMP_NUM) * 2 + 1],7);//µ¥½ÚζÈÏÂÏ߸澯16-100
-	for(uint8 i=0,j=0;(i<32&&j<5);i++)
-	{
-		if(ErrorArrayTemp[i]==1)
+		uint16 CrcChkGet = 0xffff;
+		uint16 CrcChkCal = 0x0000;
+		CrcChkCal = crc_chk((uint8 *)&UartAnsData, pReadLen - 2);
+		CrcChkGet = ((uint16)(UartAnsData.Data[pReadLen - 1 - 3]) << 8) | ((uint16)(UartAnsData.Data[pReadLen - 2 - 3]));
+		if (CrcChkCal == CrcChkGet)
 		{
-			PutErrorNum(ErrorArray, sizeof(ErrorArray)/2, ErrorArrayNumTemp[i]);
-			j++;
+			decodeFunc(UartAnsData.Data);
+			UartNoDataReadCounter = 0;
 		}
-	}
-	return true;
-}
-void battDataCalFunc(void)
-{
-	static uint32 timercounterCal = 0;
-	uint16 timediff = 0;
-	float battCapTempOnce = 0;
-	static float battCapTemp = 0;
-	static float battEnrgTemp = 0;
-	timediff = TimerCounter - timercounterCal;
-	timercounterCal = TimerCounter;
-	if(timediff==0 ||timediff>60*1000)
-	{
-		return;
-	}
-	if(battI>10000)
-	{
-		battCapTempOnce = ((battI - 10000)/10.0)*(timediff/3600.0);
-		battCapTemp =  battCapTempOnce + battCapTemp;
-		battEnrgTemp = (battCapTempOnce*battPackVol)/10000.0 + battEnrgTemp;
-		if(battEnrgTemp>10)
+		else
 		{
-			AppConfigInfo.AppDataInfo.battDischrgAccCap = AppConfigInfo.AppDataInfo.battDischrgAccCap + (uint32)battCapTemp;
-			AppConfigInfo.AppDataInfo.battDischrgAccEnrg = AppConfigInfo.AppDataInfo.battDischrgAccEnrg + (uint32)battEnrgTemp;
-			AppConfigInfo.AppDataInfo.battCycleTimes = AppConfigInfo.AppDataInfo.battDischrgAccEnrg/49000;
-			AppConfigInfo.appSaveFlg = true;
-			battEnrgTemp = 0;
-			battCapTemp = 0;
+			UartNoDataReadCounter++;
 		}
 	}
+	else
+	{
+		UartNoDataReadCounter++;
+	}
 }
+
 #endif

+ 11 - 11
src/AppTaskUart0.h

@@ -1,7 +1,7 @@
 /*
  * AppTaskUart0.h
  *
- *  Created on: 2022Äê2ÔÂ22ÈÕ
+ *  Created on: 2022Äê2ÔÂ22ÈÕ
  *      Author: QiXiang_CHENJIE
  */
 
@@ -13,24 +13,24 @@
 #ifdef APP_UART0_ENABLE
 #define BMS_ADDRESS_CODE 0x01
 #define METER1_ADDRESS_CODE 0x04
-#define UART_READ_CODE 0x03
-#define UART_WRITE_CODE 0x10
+#define UART_READ_CODE 0x04
+#define UART_WRITE_CODE 0x06
 #define UART_ENCRYPT_CODE 0x05
 #define UART_WRITE_FLAG 0x01
 #define UART_READ_FLAG 0x00
 void Uart0Task(void *pvParameters);
 typedef struct _UartAnsType
 {
-	uint8 BmsAdd;
-	uint8 FunCode;
-	uint8 Datalen;
+    uint8 BmsAdd;
+    uint8 FunCode;
+    uint8 Datalen;
     uint8 Data[300];
-}UartAnsType;
+} UartAnsType;
 typedef enum
 {
     PROCESS_UART_STATE_IDLE = 0,
     PROCESS_UART_STATE_READ,
-	PROCESS_UART_STATE_WRITE,
+    PROCESS_UART_STATE_WRITE,
     PROCESS_UART_STATE_SLEEP
 } process_Uart0;
 typedef struct _UartQueryType
@@ -46,9 +46,9 @@ typedef struct _UartQueryType
 } UartQueryType;
 typedef struct _UartWriteMsgType
 {
-	uint8 Bms_Address;
-	uint8 Bms_Funcode;
-	uint8 Reg_Begin_H;
+    uint8 Bms_Address;
+    uint8 Bms_Funcode;
+    uint8 Reg_Begin_H;
     uint8 Reg_Begin_L;
     uint8 Reg_Num_H;
     uint8 Reg_Num_L;

+ 102 - 102
src/AppTaskUart1.c

@@ -9,8 +9,8 @@
  */
 /*
  * AppTaskUart2.c
- *  4GµÄ´®¿Úº¯Êý
- *  Created on: 2022Äê2ÔÂ10ÈÕ
+ *  4G的串�函数
+ *  Created on: 2022年2月10日
  *      Author: QiXiang_CHENJIE
  */
 #include "AppTaskUart1.h"
@@ -56,8 +56,8 @@ void Uart_4G_Task(void *pvParameters)
 	uint8 UartRecvPtr[512];
 	volatile uint16 tcpErrorCounter = 0;
 	uint16 pReadLen = 0;
-	// 4G¿ª»ú
-	Dio_LevelType _4G_Status = 0; // 0-¹Ø»ú£¬1-¿ª»ú
+	// 4G开机
+	Dio_LevelType _4G_Status = 0; // 0-关机,1-开机
 	Dio_WriteChannel(DioConf_DioChannel_PTA6_GPIO_OUT_MCU_4G_POW_EN, STD_ON);
 	vTaskDelay(pdMS_TO_TICKS(50));
 	Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
@@ -65,7 +65,7 @@ void Uart_4G_Task(void *pvParameters)
 	AtcmdDelayRecvFunc(UART_LPUART1,(char *)("SMS DONE"),30000);
 	Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_OFF);
 	_4G_Status = Dio_ReadChannel(DioConf_DioChannel_PTB1_GPIO_IN_MCU_4G_STATUS);
-	InitFunc(); // 4GÄ£¿é³õʼ»¯,×¢£ºATͬ²½²»Í¨¹ý£¬Ã»ÓнøÐдÎÊýÅж¨¼°Ìøת
+	InitFunc(); // 4G模��始化,注:AT�步�通过,没有进行次数判定�跳转
 	TimerHandle_t monitorTimer1000ms;
 	monitorTimer1000ms = xTimerCreate("monitor1000ms",1000,pdTRUE,(void *)0,vTimer1000msCallback);
 	xTimerStart(monitorTimer1000ms,0);
@@ -73,9 +73,9 @@ void Uart_4G_Task(void *pvParameters)
 	{
 		switch (gProcess_Tcp_Task)
 		{
-		case PROCESS_TCP_IDLE: //¿ÕÏÐ״̬
+		case PROCESS_TCP_IDLE: //空闲状�
 		{
-			UART_Receive_Data(UART_LPUART1, UartRecvPtr, &pReadLen, 100);//100ms¼ì²â
+			UART_Receive_Data(UART_LPUART1, UartRecvPtr, &pReadLen, 100);//100ms检测
 			if (SocketId < 0)
 			{
 				PROC_TCP_STATE_SWITCH(PROCESS_TCP_REGCHK);
@@ -90,7 +90,7 @@ void Uart_4G_Task(void *pvParameters)
 				SendTimerFlg = false;
 				PROC_TCP_STATE_SWITCH(PROCESS_TCP_SEND);
 			}
-			if((TimerCounter-RecvTimerDelay)>=30000 && TcpWorkState==1)//10sÄÚûÓÐÃüÁîÏ·¢£¬½øÐÐÕý³£·¢ËÍÈÎÎñ
+			if((TimerCounter-RecvTimerDelay)>=30000 && TcpWorkState==1)//10s内没有命令下�,进行正常��任务
 			{
 				TcpWorkState = 0;
 			}
@@ -110,10 +110,10 @@ void Uart_4G_Task(void *pvParameters)
 			}
 			break;
 		}
-		case PROCESS_TCP_REGCHK: //פÍø¼ì²é£¬°üÀ¨SIM£¬CPIN¼ì²é,ICCID»ñÈ¡
+		case PROCESS_TCP_REGCHK: //驻网检查,包括SIM,CPIN检查,ICCID获�
 		{
 			RegChkRet = TcpRegisterChkFunc();
-			if (RegChkRet > 0) //¼ì²éͨ¹ý£¬SIM¿¨ÒѾÍÐ÷£¬ÒѽøÐÐפÍø
+			if (RegChkRet > 0) //检查通过,SIM�已就绪,已进行驻网
 			{
 				PROC_TCP_STATE_SWITCH(PROCESS_TCP_CONNECT);
 			}
@@ -123,7 +123,7 @@ void Uart_4G_Task(void *pvParameters)
 			}
 			break;
 		}
-		case PROCESS_TCP_CONNECT: //ÍøÂçÁ¬½Ó£¬°üÀ¨ÓòÃûת»»
+		case PROCESS_TCP_CONNECT: //网络连接,包括域�转�
 		{
 			if (SocketId < 0)
 			{
@@ -140,7 +140,7 @@ void Uart_4G_Task(void *pvParameters)
 			}
 			break;
 		}
-		case PROCESS_TCP_SEND: //ÍøÂçÊý¾Ý·¢ËÍ
+		case PROCESS_TCP_SEND: //网络数���
 		{
 			sint8 SendRet = -1;
 			SendRet = TcpDataSendFunc(SocketId);
@@ -156,7 +156,7 @@ void Uart_4G_Task(void *pvParameters)
 			}
 			break;
 		}
-		case PROCESS_TCP_RECV: //ÍøÂçÊý¾Ý½ÓÊÕ,100ms¿ÕÏÐ״̬ϼ´¿É½ÓÊÕ
+		case PROCESS_TCP_RECV: //网络数�接收,100ms空闲状�下��接收
 		{
 			Dio_FlipChannel(DioConf_DioChannel_PTE0_GPIO_OUT_MCU_LED1);
 
@@ -167,19 +167,19 @@ void Uart_4G_Task(void *pvParameters)
 			PROC_TCP_STATE_SWITCH(PROCESS_TCP_IDLE);
 			break;
 		}
-		case PROCESS_TCP_HEART: //ÐÄÌø°ü·¢ËÍ
+		case PROCESS_TCP_HEART: //心跳包��
 		{
 			break;
 		}
-		case PROCESS_TCP_SLEEP: //ÍøÂçÐÝÃß״̬
+		case PROCESS_TCP_SLEEP: //网络休眠状�
 		{
 			break;
 		}
-		case PROCESS_TCP_ERROR: //´íÎó״̬
+		case PROCESS_TCP_ERROR: //错误状�
 		{
 			vTaskDelay(pdMS_TO_TICKS(1000));
 			tcpErrorCounter++;
-			if(tcpErrorCounter>60&&TcpSysReboot == 1)//ÎÞ·¨×¤Íø»òÕßÁªÍø
+			if(tcpErrorCounter>60&&TcpSysReboot == 1)//无法驻网或者�网
 			{
 				Dio_WriteChannel(DioConf_DioChannel_PTA7_GPIO_OUT_MCU_4G_PWRKEY, STD_ON);
 				vTaskDelay(pdMS_TO_TICKS(2500));
@@ -208,12 +208,12 @@ sint8 TcpDataSendFunc(sint8 ConnectId)
 	sint8 outValue = -1;
 	uint32 pSendDataAddr = 0;
 	uint16 DataSendLen = 0;
-	TcpDataEncode(&pSendDataAddr, &DataSendLen); //Êý¾Ý×é°ü£¬mallocÉêÇëÔÚÀïÃæ,pSendDataÖ¸ÏòÉêÇëµÄµØÖ·
+	TcpDataEncode(&pSendDataAddr, &DataSendLen); //数�组包,malloc申请在里�,pSendData指�申请的地�
 	if (DataSendLen == 0)
 	{
-		return 0; //ÔÝʱÎÞÊý¾Ý¿ÉÒÔ·¢
+		return 0; //暂时无数��以�
 	}
-	outValue = tcpipConnectionSend(ConnectId, (uint8 *)pSendDataAddr, DataSendLen); //·¢Ëͺ¯Êý
+	outValue = tcpipConnectionSend(ConnectId, (uint8 *)pSendDataAddr, DataSendLen); //��函数
 	if (pSendDataAddr != 0)
 	{
 		vPortFree((uint8 *)(pSendDataAddr));
@@ -228,14 +228,14 @@ sint8 tcpipConnectionSend(uint8 TcpConnectId, uint8 *SendDataPtr, uint16 SendDat
 	uint16 ReadLen = 0;
 	char AtCmdSend[30] = {0};
 	uint8 AtCmdSendTotalLen = 0;
-	uint8 UartRecvPtr[128];//ÔÝ´æbuffer¸Ä´ó
+	uint8 UartRecvPtr[128];//暂存buffer改大
 	uint8 ret = 0;
 	sprintf(AtCmdSend, "AT+CIPSEND=%d,%d\r\n", TcpConnectId, SendDataLen);
 	AtCmdSendTotalLen = mstrlen(AtCmdSend);
 	while(outValue!=0&&sendErrConuter<3)
 	{
 		ret = UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)AtCmdSend, AtCmdSendTotalLen, UartRecvPtr, &ReadLen, 1000);
-		if (((ret==0)&&(ReadLen>0)&&((uint8 *)strstr((char *)UartRecvPtr, (char *)(">"))))||1)//´ËIFÌõ¼þĬÈÏͨ¹ý
+		if (((ret==0)&&(ReadLen>0)&&((uint8 *)strstr((char *)UartRecvPtr, (char *)(">"))))||1)//此IF�件默认通过
 		{
 			UART_Send_Data(UART_LPUART1, (uint8 *)SendDataPtr, SendDataLen, 1000);
 			sint8 ret = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CIPSEND"),2000);
@@ -274,7 +274,7 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
 	{
 		switch (ConnectStep)
 		{
-		case 0: // ATÖ¸Áîͬ²½
+		case 0: // AT指令�步
 		{
 			char *ATCmdSend = (char *)("ATE0\r\n");
 			uint8 ATCmdSendLen = mstrlen(ATCmdSend);
@@ -315,9 +315,9 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
 			}
 			break;
 		}
-		case 2: //Á¬½Ó¼ì²é
+		case 2: //连接检查
 		{
-			AtcmdTransmit(AT_CONNECTCHK, NULL, 0, &ATRet,1000); // ATret·µ»ØµÄÖµÊÇÁ¬½Óid£¬Èç¹ûδÁ¬½Ó·µ»Ø-1
+			AtcmdTransmit(AT_CONNECTCHK, NULL, 0, &ATRet,1000); // ATret返回的值是连接id,如果未连接返回-1
 			if (ATRet >= 0)
 			{
 				*ConnectId = ATRet;
@@ -329,7 +329,7 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
 			}
 			break;
 		}
-		case 3: //ÓòÃûת»»
+		case 3: //域�转�
 		{
 			char AtCmdSend[30] = {0};
 			uint8 AtCmdSendLen = 0;
@@ -349,18 +349,18 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
 			}
 			break;
 		}
-		case 4: //´´½¨Á¬½Ó
+		case 4: //创建连接
 		{
 			char AtCmdSend[50] = {0};
 			uint8 AtCmdSendTotalLen = 0;
 			*ConnectId = 0;
-			/*IP²âÊÔ¸ü¸Ä*/
+			/*IP测试更改*/
 //			char *ATCmdSend = (char *)("\"120.26.68.165\"");
 //			memset(WebSiteIp,0x00,sizeof(WebSiteIp));
 //			memcpy(WebSiteIp ,ATCmdSend,strlen(ATCmdSend));
 //			WebSitePort = 14401;
 			/**/
-			sprintf(AtCmdSend, "AT+CIPOPEN=%d,\"TCP\",%s,%d\r\n", *ConnectId, WebSiteIp, WebSitePort); //´Ë´¦ÐèÒªÓÅ»¯
+			sprintf(AtCmdSend, "AT+CIPOPEN=%d,\"TCP\",%s,%d\r\n", *ConnectId, WebSiteIp, WebSitePort); //此处需�优化
 			AtCmdSendTotalLen = mstrlen(AtCmdSend);
 			UART_Send_Data(UART_LPUART1, AtCmdSend, AtCmdSendTotalLen, pdMS_TO_TICKS(100));
 			ATRet = AtcmdDelayRecvFunc(UART_LPUART1,(char *)("+CIPOPEN: 0,0"),20000);
@@ -385,13 +385,13 @@ sint8 TcpConnectFunc(sint8 *ConnectId)
 sint8 TcpRegisterChkFunc(void)
 {
 	uint8 RegChkStep = 0;
-	sint8 ChkState = 0; //ĬÈÏΪ0
+	sint8 ChkState = 0; //默认为0
 	sint8 ATRet = -1;
 	while (1)
 	{
 		switch (RegChkStep)
 		{
-		case 0: // ATÖ¸Áîͬ²½
+		case 0: // AT指令�步
 		{
 			AtcmdTransmit(AT_CMD_TEST, NULL, 0, &ATRet,100);
 			if (ATRet == 0)
@@ -405,7 +405,7 @@ sint8 TcpRegisterChkFunc(void)
 			}
 			break;
 		}
-		case 1: // CPIN¼ì²é
+		case 1: // CPIN检查
 		{
 			AtcmdTransmit(AT_SIMREADY, NULL, 0, &ATRet,100);
 			if (ATRet == 0)
@@ -421,7 +421,7 @@ sint8 TcpRegisterChkFunc(void)
 		}
 		case 2:
 		{
-			AtcmdTransmit(AT_CGREG, NULL, 0, &ATRet,1000); //פÍø¼ì²é£¬·µ»ØÖµ1ºÍ5ÊÇפÍø³É¹¦
+			AtcmdTransmit(AT_CGREG, NULL, 0, &ATRet,1000); //驻网检查,返回值1和5是驻网�功
 			if (ATRet == 1 || ATRet == 5)
 			{
 				RegChkStep++;
@@ -442,7 +442,7 @@ sint8 TcpRegisterChkFunc(void)
 }
 void InitFunc(void)
 {
-	// 4GÄ£¿é³õʼ»¯
+	// 4G模��始化
 	uint8 _4G_InitStep = 0;
 	sint8 ATRet = -1;
 	uint16 ReadLen = 0;
@@ -455,7 +455,7 @@ void InitFunc(void)
 	{
 		switch (_4G_InitStep)
 		{
-		case 0: // ATÖ¸Áîͬ²½
+		case 0: // AT指令�步
 		{
 			AtcmdTransmit(AT_CMD_TEST, NULL, 0, &ATRet,100);
 			if (ATRet == 0)
@@ -474,7 +474,7 @@ void InitFunc(void)
 			}
 			break;
 		}
-		case 1: //¹Ø±Õ»ØÏÔ
+		case 1: //关闭回显
 		{
 			ATCmdSend = (char *)("ATE0\r\n");
 			ATCmdSendLen = mstrlen(ATCmdSend);
@@ -497,7 +497,7 @@ void InitFunc(void)
 			}
 			break;
 		}
-		case 2: // IMEI»ñÈ¡
+		case 2: // IMEI获�
 		{
 			ATCmdSend = (char *)("AT+SIMEI?\r\n");
 			ATCmdSendLen = mstrlen(ATCmdSend);
@@ -521,7 +521,7 @@ void InitFunc(void)
 			}
 			break;
 		}
-		case 3: // ´ò¿ªÊ±¼ä×Ô¶¯¸üÐÂ
+		case 3: // 打开时间自动更新
 		{
 			ATCmdSend = (char *)("AT+CTZU=1\r\n");
 			ATCmdSendLen = mstrlen(ATCmdSend);
@@ -540,7 +540,7 @@ void InitFunc(void)
 			}
 			break;
 		}
-		case 4: // ICCID»ñÈ¡
+		case 4: // ICCID获�
 		{
 			AtcmdTransmit(AT_GETICCID, NULL, 0, &ATRet,1000);
 			if (ATRet == 0)
@@ -670,7 +670,7 @@ sint8 at_callbackFunc(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pRead
 		{
 			OutValue = 0;
 		}
-		retptr = (uint8 *)strstr((char *)pReadStr, (char *)("opened")); //Öظ´´ò¿ª
+		retptr = (uint8 *)strstr((char *)pReadStr, (char *)("opened")); //��打开
 		if (retptr)
 		{
 			OutValue = 0;
@@ -748,54 +748,54 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 #endif
 	if (TcpSendTimeCounter == 5)
 	{
-		DataIdx = VerMsg; //°æ±¾ÐÅÏ¢·¢ËÍ
+		DataIdx = VerMsg; //版本信���
 	}
 	else if (TcpSendTimeCounter % 10 == 1)
 	{
-		DataIdx = BattMsg; //µç³ØÐÅÏ¢·¢ËÍ
+		DataIdx = BattMsg; //电池信���
 	}
 	else if ((TcpSendTimeCounter) % 10 == 2)
 	{
-		DataIdx = 0x83; //´¢ÄÜ¿ª¹ØÐÅÏ¢·¢ËÍ
+		DataIdx = 0x83; //储能开关信���
 	}
 	else if ((TcpSendTimeCounter) % 240 == 3)
 	{
-		DataIdx = GpsMsg; //¶¨Î»ÐÅÏ¢·¢ËÍ
+		DataIdx = GpsMsg; //定�信���
 	}
 	else if ((TcpSendTimeCounter) % 240 == 4)
 	{
-		DataIdx = 0x93; //´¢ÄܵçÁ¿ÐÅÏ¢·¢ËÍ
+		DataIdx = 0x93; //储能电�信���
 	}
 	else if ((TcpSendTimeCounter) % 60 == 5)
 	{
-		DataIdx = 0x8A; //ÀÛ¼ÆÐÅÏ¢·¢ËÍ
+		DataIdx = 0x8A; //累计信���
 	}
 	else if ((TcpSendTimeCounter) % (60*60*2) == 6)
 	{
-		DataIdx = 0x01; //ʱ¼äУ׼
+		DataIdx = 0x01; //时间校准
 	}
 	else
 	{
 		*SendLen = 0;
-		DataIdx = 0; //²»·¢ËÍ,·µ»Ø
+		DataIdx = 0; //���,返回
 		return;
 	}
 #if SEGGER_PRINTF==1
 	SEGGER_RTT_printf("\r\n[%d] DataIdx -%X\r\n",__LINE__,DataIdx);
 #endif
 	memcpy(TcpbattSN, AppConfigInfo.deviceSn, 17);
-	GetUtc8Time(&UTC8TimeTcp); //ʱ¼ä»ñÈ¡
+	GetUtc8Time(&UTC8TimeTcp); //时间获�
 	vTaskDelay(pdMS_TO_TICKS(100));
 	switch (DataIdx)
 	{
-	case 0x01://ʱ¼äУ׼
+	case 0x01://时间校准
 	{
 		char *ATCmdSend = (char *)("AT+CNTP\r\n");
 		uint8 ATCmdSendLen = mstrlen(ATCmdSend);
 		uint8 ReadLen = 0;
 		uint8 UartRecvPtr[20];
 		UART_Query_Data(UART_LPUART1, UART_LPUART1, (uint8 *)ATCmdSend, ATCmdSendLen,UartRecvPtr, &ReadLen, pdMS_TO_TICKS(500));
-		*SendLen = 0;//²»·¢ËÍ£¬³¤¶ÈΪ0
+		*SendLen = 0;//���,长度为0
 		return;
 	}
 	case 0x82:
@@ -846,7 +846,7 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 		memcpy(xyzDatacahce, xyzData, 3);
 		for (uint8 i = 0; i < 3; i++)
 		{
-			if (xyzDatacahce[i] > 0x8000) // Êý¾ÝΪ¸º
+			if (xyzDatacahce[i] > 0x8000) // 数�为负
 			{
 				xyzDatacahce[i] = (uint16)((uint16)(~(xyzDatacahce[i])) + 1);
 				xyzDatacahce[i] = 20000U - xyzDatacahce[i];
@@ -929,74 +929,74 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 	{
 		uint16 ErrorTemp;
 		ErrorTemp = GetErrorNum(ErrorArray,sizeof(ErrorArray)/2);
-		uint8 ProtocolHeaderLen = 25;																					  //µç³ØÐÅϢЭÒéÍ·²¿¼ÓУÑéÂ볤¶È£¬´Ë³¤¶È²»¸ü¸Ä
-		uint8 ProtocolFixedLen = 60;																					  //µç³ØÐÅϢЭÒé¹Ì¶¨×ܳ¤¶È ÈçЭÒéÐÂÔö£¬ÐèÒª¸ü¸Ä´Ë³¤¶È
-		uint16 ProtocolFluctedLen = AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + BmsOtherTemp + OtherTemp; //µç³ØÐÅϢЭÒé±ä¶¯³¤¶È
+		uint8 ProtocolHeaderLen = 25;																					  //电池信��议头部加校验�长度,此长度�更改
+		uint8 ProtocolFixedLen = 60;																					  //电池信��议固定总长度 如�议新增,需�更改此长度
+		uint16 ProtocolFluctedLen = AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + BmsOtherTemp + OtherTemp; //电池信��议�动长度
 		uint16 DataLen;
 		*SendLen = ProtocolFixedLen + ProtocolFluctedLen;
 		SendBuffer = pvPortMalloc(*SendLen);
 		GetCSQValue(&CSQValue);
-		*(SendBuffer + 0) = TCP_START_SYM1;									 //ÆðʼÂë-1
-		*(SendBuffer + 1) = TCP_START_SYM2;									 //ÆðʼÂë-2
-		*(SendBuffer + 2) = TCP_CMD_SYM;									 //ÃüÁî±êʶ-3
-		*(SendBuffer + 3) = TCP_ANS_SYM;									 //Ó¦´ð±êʶ-4
-		memcpy(SendBuffer + 4, TcpbattSN, BATT_SN_LEN);						 // SNÂë 5-21
-		*(SendBuffer + 21) = TCP_ENCPT_DISABLE;								 //¼ÓÃÜ·½Ê½-22
-		DataLen = ProtocolFixedLen + ProtocolFluctedLen - ProtocolHeaderLen; //µç³ØÐÅÏ¢µ¥ÔªÐ­Òé¹Ì¶¨³¤¶È
-		*(SendBuffer + 22) = (DataLen >> 8) & 0xFF;							 //Êý¾Ý³¤¶ÈH-23
-		*(SendBuffer + 23) = DataLen & 0xFF;								 //Êý¾Ý³¤¶ÈL-24
+		*(SendBuffer + 0) = TCP_START_SYM1;									 //起始�-1
+		*(SendBuffer + 1) = TCP_START_SYM2;									 //起始�-2
+		*(SendBuffer + 2) = TCP_CMD_SYM;									 //命令标识-3
+		*(SendBuffer + 3) = TCP_ANS_SYM;									 //应答标识-4
+		memcpy(SendBuffer + 4, TcpbattSN, BATT_SN_LEN);						 // SNç � 5-21
+		*(SendBuffer + 21) = TCP_ENCPT_DISABLE;								 //加密方�-22
+		DataLen = ProtocolFixedLen + ProtocolFluctedLen - ProtocolHeaderLen; //电池信��元�议固定长度
+		*(SendBuffer + 22) = (DataLen >> 8) & 0xFF;							 //数�长度H-23
+		*(SendBuffer + 23) = DataLen & 0xFF;								 //数�长度L-24
 		*(SendBuffer + 24) = (UTC8TimeTcp.year) & 0xFF;						 // year-25
 		*(SendBuffer + 25) = UTC8TimeTcp.month & 0xFF;						 // month-26
 		*(SendBuffer + 26) = UTC8TimeTcp.day & 0xFF;						 // day-27
 		*(SendBuffer + 27) = UTC8TimeTcp.hour & 0xFF;						 // hour-28
 		*(SendBuffer + 28) = UTC8TimeTcp.minute & 0xFF;						 // mins-29
 		*(SendBuffer + 29) = UTC8TimeTcp.second & 0xFF;						 // sec-30
-		*(SendBuffer + 30) = DataIdx;										 //µç³ØÐÅÏ¢·¢ËÍ-31
+		*(SendBuffer + 30) = DataIdx;										 //电池信���-31
 		*(SendBuffer + 31) = (UTC8TimeTcp.year) & 0xFF;						 // year-32
 		*(SendBuffer + 32) = UTC8TimeTcp.month & 0xFF;						 // month-33
 		*(SendBuffer + 33) = UTC8TimeTcp.day & 0xFF;						 // day-34
 		*(SendBuffer + 34) = UTC8TimeTcp.hour & 0xFF;						 // hour-35
 		*(SendBuffer + 35) = UTC8TimeTcp.minute & 0xFF;						 // mins-36
 		*(SendBuffer + 36) = UTC8TimeTcp.second & 0xFF;						 // sec-37
-		*(SendBuffer + 37) = CSQValue;										 //ÐźÅÇ¿¶È-38
-		*(SendBuffer + 38) = 0;												 //¹ÊÕϵȼ¶-39
-		*(SendBuffer + 39) = ErrorTemp >> 8;								 //¹ÊÕÏ´úÂëH-40
-		*(SendBuffer + 40) = ErrorTemp & 0xFF;								 //¹ÊÕÏ´úÂëL-41
-		*(SendBuffer + 41) = battI >> 8;									 //µçÁ÷-42
-		*(SendBuffer + 42) = battI & 0xFF;									 //µçÁ÷-43
-		*(SendBuffer + 43) = battPackVol >> 8;								 //µçѹ-44
-		*(SendBuffer + 44) = battPackVol & 0xFF;							 //µçѹ-45
-		*(SendBuffer + 45) = battPackVol >> 8;								 //µçѹ-46
-		*(SendBuffer + 46) = battPackVol & 0xFF;							 //µçѹ-47
-		*(SendBuffer + 47) = battMOSSwitchState;							 // mos״̬-48
+		*(SendBuffer + 37) = CSQValue;										 //信�强度-38
+		*(SendBuffer + 38) = 0;												 //故障等级-39
+		*(SendBuffer + 39) = ErrorTemp >> 8;								 //故障代�H-40
+		*(SendBuffer + 40) = ErrorTemp & 0xFF;								 //故障代�L-41
+		*(SendBuffer + 41) = battI >> 8;									 //电�-42
+		*(SendBuffer + 42) = battI & 0xFF;									 //电�-43
+		*(SendBuffer + 43) = battPackVol >> 8;								 //电压-44
+		*(SendBuffer + 44) = battPackVol & 0xFF;							 //电压-45
+		*(SendBuffer + 45) = battPackVol >> 8;								 //电压-46
+		*(SendBuffer + 46) = battPackVol & 0xFF;							 //电压-47
+		*(SendBuffer + 47) = battMOSSwitchState;							 // mos状�-48
 		*(SendBuffer + 48) = (uint8)(battSOC);					 // soc-49
 		*(SendBuffer + 49) = (uint8)(battSOH);					 // soh-50
 		*(SendBuffer + 50) = (battBalanceoInfo >> 24) & 0xFF;
 		*(SendBuffer + 51) = (battBalanceoInfo >> 16) & 0xFF;
 		*(SendBuffer + 52) = (battBalanceoInfo >> 8) & 0xFF;
-		*(SendBuffer + 53) = battBalanceoInfo & 0xFF;		  //¾ùºâ״̬-51-54
-		*(SendBuffer + 54) = AppDataInfo.BattCellCount;		  //µçѹ¸öÊý-55
-		for (uint8 i = 0; i < AppDataInfo.BattCellCount; i++) //µ¥Ìåµçѹ
+		*(SendBuffer + 53) = battBalanceoInfo & 0xFF;		  //�衡状�-51-54
+		*(SendBuffer + 54) = AppDataInfo.BattCellCount;		  //电压个数-55
+		for (uint8 i = 0; i < AppDataInfo.BattCellCount; i++) //�体电压
 		{
 			*(SendBuffer + 54 + i * 2 + 1) = (battCellU[i] >> 8) & 0xFF;
 			*(SendBuffer + 54 + i * 2 + 2) = battCellU[i] & 0xFF;
 		}
-		*(SendBuffer + 55 + AppDataInfo.BattCellCount * 2) = AppDataInfo.BattTempCount;							   //Ä£×éζȸöÊý
-		memcpy((SendBuffer + 55 + AppDataInfo.BattCellCount * 2 + 1), &battCellTemp, AppDataInfo.BattTempCount);   //Ä£×éζÈ
-		*(SendBuffer + 56 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount) = battWorkState;			   //µç³Ø¹¤×÷״̬
-		*(SendBuffer + 57 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount) = battHeatEnableState;	   //µç³Ø¼ÓÈÈʹÄÜ״̬
-		*(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount) = BmsOtherTemp + OtherTemp; //ÆäËûζȸöÊý
-		// *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 1) = MOSTemp;																						  // mosζÈ
-		// *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 2) = packTemp;																						  //»·¾³Î¶È
-		// *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 3) = fastChargeTemp;																				  //¿ì³äζÈ
-		// *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 4) = normalChargeTemp;																				  //Âý³äζÈ
-		// *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 5) = heatTemp1;																						  //¼ÓÈÈζÈ1
-		// *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 6) = heatTemp2;																						  //¼ÓÈÈζÈ2
-		*(SendBuffer + 59 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + BmsOtherTemp + OtherTemp) = bcc_chk(SendBuffer, ProtocolFixedLen + ProtocolFluctedLen - 1); //УÑéÂë
+		*(SendBuffer + 55 + AppDataInfo.BattCellCount * 2) = AppDataInfo.BattTempCount;							   //模组温度个数
+		memcpy((SendBuffer + 55 + AppDataInfo.BattCellCount * 2 + 1), &battCellTemp, AppDataInfo.BattTempCount);   //模组温度
+		*(SendBuffer + 56 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount) = battWorkState;			   //电池工作状�
+		*(SendBuffer + 57 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount) = battHeatEnableState;	   //电池加热使能状�
+		*(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount) = BmsOtherTemp + OtherTemp; //其他温度个数
+		// *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 1) = MOSTemp;																						  // mos温度
+		// *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 2) = packTemp;																						  //环境温度
+		// *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 3) = fastChargeTemp;																				  //快充温度
+		// *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 4) = normalChargeTemp;																				  //慢充温度
+		// *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 5) = heatTemp1;																						  //加热温度1
+		// *(SendBuffer + 58 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + 6) = heatTemp2;																						  //加热温度2
+		*(SendBuffer + 59 + AppDataInfo.BattCellCount * 2 + AppDataInfo.BattTempCount + BmsOtherTemp + OtherTemp) = bcc_chk(SendBuffer, ProtocolFixedLen + ProtocolFluctedLen - 1); //校验�
 		*PtrSendAddr = (uint32)SendBuffer;
 		break;
 	}
-	case 0x83://´¢Äܳ¡¾°µÄ¿ª¹ØÐÅÏ¢
+	case 0x83://储能场景的开关信�
 	{
 		StorageInfoToTcp StorageInfo;
 		*SendLen = sizeof(StorageInfo);
@@ -1033,7 +1033,7 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 		*PtrSendAddr = (uint32)SendBuffer;
 		break;
 	}
-	case 0x93://´¢Äܳ¡¾°µÄµçÁ¿ÐÅÏ¢
+	case 0x93://储能场景的电�信�
 	{
 		StorageInfoToTcp2 StorageInfo2;
 		*SendLen = sizeof(StorageInfo2);
@@ -1234,12 +1234,12 @@ static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)
 	if (TcpDataLen > 0)
 	{
 		Ptr = retptr + 2;
-		if ((*(Ptr + 0) == TCP_START_SYM1) && (*(Ptr + 1) == TCP_START_SYM2)) //·þÎñÆ÷ÆðʼÐÅÏ¢
+		if ((*(Ptr + 0) == TCP_START_SYM1) && (*(Ptr + 1) == TCP_START_SYM2)) //�务器起始信�
 		{
-			Tcp_Cmd = *(Ptr + 2); //ÃüÁî±êÖ¾
+			Tcp_Cmd = *(Ptr + 2); //命令标志
 			if (*(Ptr + 3) == 0xFE)
 			{
-				TcpWorkState = 0x01;//ÐèÒªÔÝÍ£·¢ËÍ£¬½øÐÐÃüÁîÓ¦´ðµÄ±êÖ¾
+				TcpWorkState = 0x01;//需�暂���,进行命令应答的标志
 			}
 			else
 			{
@@ -1256,7 +1256,7 @@ static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)
 				TcpCmdAnswer[0] = TCP_START_SYM1;
 				TcpCmdAnswer[1] = TCP_START_SYM1;
 				TcpCmdAnswer[2] = TCP_CONCMD_SYM;
-				if (*(Ptr + 30) == 0x83) //Ô¶³ÌÉý¼¶Ö¸Áî
+				if (*(Ptr + 30) == 0x83) //远程�级指令
 				{
                     TcpCmdAnswer[3] = 0x01;
                     memcpy(&TcpCmdAnswer[4], (Ptr + 4), BATT_SN_LEN);
@@ -1269,7 +1269,7 @@ static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)
 					vTaskDelay(pdMS_TO_TICKS(5000));
 					Fota_Ftp(Ptr + 32);
 				}
-                else if (*(Ptr + 30) == 0x80) //Ô¶³ÌËø¶¨ÃüÁî
+                else if (*(Ptr + 30) == 0x80) //远程�定命令
                 {
                     TcpCmdAnswer[3] = 0x01;
                     memcpy(&TcpCmdAnswer[4], (Ptr + 4), BATT_SN_LEN);
@@ -1278,13 +1278,13 @@ static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)
                     TcpCmdAnswer[23] = 0x06;
                     memcpy(&TcpCmdAnswer[24], (Ptr + 24), 6);
                     TcpCmdAnswer[30] = bcc_chk(TcpCmdAnswer, 30);
-                    if (*(Ptr + 31) == 0x01) // 0x01´ú±íËø¶¨
+                    if (*(Ptr + 31) == 0x01) // 0x01代表�定
                     {
                     	battSeparateEnable = 1;
                     	battSeparateCtlState = 1;
                         tcpipConnectionSend(SocketId, TcpCmdAnswer, 31 );
                     }
-                    else if (*(Ptr + 31) == 0x02) // 0x02´ú±í½âËø
+                    else if (*(Ptr + 31) == 0x02) // 0x02代表解�
                     {
                     	battSeparateEnable = 1;
                     	battSeparateCtlState = 0;
@@ -1415,7 +1415,7 @@ void Fota_Ftp(uint8 *dataPtrIn)
 	uint16 ReadLen = 0;
 	uint8 *retptr = NULL;
 //	char temp[70]=",qx,qx900,120.27.243.131,21,0,0.0.1.5,0.0.1.5,/Debug/V0.0.1.5.bin,";
-	/*URLÐÅÏ¢½âÎö*/
+	/*URL信�解�*/
 	char *databuffer[20];
 	char *accountPtr;
 	char *passwordPtr;
@@ -1431,7 +1431,7 @@ void Fota_Ftp(uint8 *dataPtrIn)
 	while (p&&index<20)
 	{
 		databuffer[index] = p;
-		p = strtok(NULL, ",");//±¨Ó²¼þ´íÎó
+		p = strtok(NULL, ",");//报硬件错误
 		index++;
 	}
 	accountPtr = databuffer[0];

+ 7 - 7
src/AppTaskUart1.h

@@ -9,8 +9,8 @@
  */
 /*
  * AppTaskUart2.h
- *4GµÄ´®¿Úº¯Êý
- *  Created on: 2022Äê2ÔÂ10ÈÕ
+ *4G的串�函数
+ *  Created on: 2022年2月10日
  *      Author: QiXiang_CHENJIE
  */
 
@@ -24,8 +24,8 @@
 #define BATT_SN_LEN 17
 #define TCP_START_SYM1 0x23
 #define TCP_START_SYM2 0x23
-#define TCP_CMD_SYM 0x02   //ʵʱÐÅÏ¢Éϱ¨ÊÇ0x02
-#define TCP_HEART_SYM 0x07 //ÐÄÌø°ü±êÖ¾
+#define TCP_CMD_SYM 0x02   //实时信�上报是0x02
+#define TCP_HEART_SYM 0x07 //心跳包标志
 #define TCP_ANS_SYM 0xFE
 #define TCP_ENCPT_ENABLE 0x00
 #define TCP_ENCPT_DISABLE 0x01
@@ -191,9 +191,9 @@ typedef sint8 (*pFunc)(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pRea
 sint8 at_callbackFunc(char *PSendStr, char *pReadStr, uint8 CmdIdx, uint16 pReadLen);
 typedef struct
 {
-	ATCmd cmd; /*Ö¸ÁîÐòºÅ*/
-	char *str; /*Ö¸ÁîÄÚÈÝ*/
-	pFunc cb;  /*¶ÔÓ¦µÄÖ´ÐÐ*/
+	ATCmd cmd; /*指令��*/
+	char *str; /*指令内容*/
+	pFunc cb;  /*对应的执行*/
 } ATCmdFunc;
 typedef enum
 {

+ 1 - 1
src/Hal_Fls.c

@@ -1,7 +1,7 @@
 /*
  * Hal_Fls.c
  *
- *  Created on: 2022Äê4ÔÂ6ÈÕ
+ *  Created on: 2022Äê4ÔÂ6ÈÕ
  *      Author: Zhengchao
  */
 #include "Hal_Fls.h"

+ 1 - 1
src/Hal_Fls.h

@@ -1,7 +1,7 @@
 /*
  * Hal_Fls.h
  *
- *  Created on: 2022Äê4ÔÂ6ÈÕ
+ *  Created on: 2022Äê4ÔÂ6ÈÕ
  *      Author: Zhengchao
  */
 

+ 1 - 1
src/Hal_Var.c

@@ -1,7 +1,7 @@
 /*
  * Hal_Var.c
  *
- *  Created on: 2022Äê3ÔÂ14ÈÕ
+ *  Created on: 2022Äę3ÔÂ14Č�
  *      Author: Zhengchao
  */
 #include "Hal_Var.h"

+ 1 - 1
src/Hal_Var.h

@@ -1,7 +1,7 @@
 /*
  * Hal_Var.h
  *
- *  Created on: 2022Äê3ÔÂ14ÈÕ
+ *  Created on: 2022Äê3ÔÂ14ÈÕ
  *      Author: Zhengchao
  */
 

+ 1 - 1
src/Hal_Wdg.h

@@ -1,7 +1,7 @@
 /*
  * Hal_Wdg.h
  *
- *  Created on: 2022Äê3ÔÂ14ÈÕ
+ *  Created on: 2022Äê3ÔÂ14ÈÕ
  *      Author: Zhengchao
  */
 

+ 33 - 33
src/SL_Sc7a20_Driver.h

@@ -5,26 +5,26 @@
 #include "StandardTypes.h"
 #include "Spi.h"
 
-/***使用驱动前请根据实际接线情况配置******/
-/**SC7A20的SDO 脚接地:  0****************/
-/**SC7A20的SDO 脚接电源:1****************/
+/***浣跨敤椹卞姩鍓嶈�鏍规嵁瀹為檯鎺ョ嚎鎯呭喌閰嶇疆******/
+/**SC7A20鐨凷DO 鑴氭帴鍦帮細  0****************/
+/**SC7A20鐨凷DO 鑴氭帴鐢垫簮锛�1****************/
 #define SC7A20_SDO_VDD_GND            1
 /*****************************************/
 
-/***使用驱动前请根据实际IIC情况进行配置***/
-/**SC7A20的IIC 接口地址类型 7bits:  0****/
-/**SC7A20的IIC 接口地址类型 8bits:  1****/
+/***浣跨敤椹卞姩鍓嶈�鏍规嵁瀹為檯IIC鎯呭喌杩涜�閰嶇疆***/
+/**SC7A20鐨処IC 鎺ュ彛鍦板潃绫诲瀷 7bits锛�  0****/
+/**SC7A20鐨処IC 鎺ュ彛鍦板潃绫诲瀷 8bits锛�  1****/
 #define SC7A20_IIC_7BITS_8BITS        0
 /*****************************************/
 
 #define  SL_SC7A20_16BIT_8BIT         1
-/**SC7A20的数据位数选择  16bits:    1****/
-/**SC7A20的数据位数选择   8bits:    0****/
+/**SC7A20鐨勬暟鎹�綅鏁伴€夋嫨  16bits锛�    1****/
+/**SC7A20鐨勬暟鎹�綅鏁伴€夋嫨   8bits锛�    0****/
 /*****************************************/
 
 #define  SL_SC7A20_SPI_IIC_MODE       0
-/**SC7A20 SPI IIC 选择    SPI:      0****/
-/**SC7A20 SPI IIC 选择    IIC:      1****/
+/**SC7A20 SPI IIC 閫夋嫨    SPI锛�      0****/
+/**SC7A20 SPI IIC 閫夋嫨    IIC锛�      1****/
 /*****************************************/
 
 #define SL_6D4D2D1D_SEL   			 6
@@ -89,11 +89,11 @@
 #define  SL_SC7A20_ACT_THS        (uint8)0x3E
 #define  SL_SC7A20_ACT_DURATION   (uint8)0x3F
 	
-/*连续读取数据时的数据寄存器地址*/
+/*杩炵画璇诲彇鏁版嵁鏃剁殑鏁版嵁瀵勫瓨鍣ㄥ湴鍧€*/
 #define  SL_SC7A20_DATA_OUT       (uint8)(SL_SC7A20_OUT_X_L)
 
-/**********特殊功能寄存器**********/
-/*非原厂技术人员请勿修改*/
+/**********鐗规畩鍔熻兘瀵勫瓨鍣�**********/
+/*闈炲師鍘傛妧鏈�汉鍛樿�鍕夸慨鏀�*/
 #define  SL_SC7A20_MTP_ENABLE            0x00
 #define  SL_SC7A20_MTP_CFG    	  (uint8)0x1E
 #define  SL_SC7A20_MTP_VALUE   	  (uint8)0x05
@@ -102,10 +102,10 @@
 #define  SL_SC7A20_I2C_PU_MSK     (uint8)0x04
 #define  SL_SC7A20_HR_ENABLE      (uint8)0X08
 #define  SL_SC7A20_BOOT_ENABLE    (uint8)0X80
-/*非原厂技术人员请勿修改*/
+/*闈炲師鍘傛妧鏈�汉鍛樿�鍕夸慨鏀�*/
 
 
-/***************数据更新速率**加速度计使能**********/
+/***************鏁版嵁鏇存柊閫熺巼**鍔犻€熷害璁′娇鑳�**********/
 #define  SL_SC7A20_ODR_POWER_DOWN (uint8)0x00
 #define  SL_SC7A20_ODR_1HZ        (uint8)0x17
 #define  SL_SC7A20_ODR_10HZ       (uint8)0x27
@@ -125,18 +125,18 @@
 #define  SL_SC7A20_LOWER_POWER_ODR_100HZ      (uint8)0x5F
 #define  SL_SC7A20_LOWER_POWER_ODR_200HZ      (uint8)0x6F
 #define  SL_SC7A20_LOWER_POWER_ODR_400HZ      (uint8)0x7F
-/***************数据更新速率**加速度计使能**********/
+/***************鏁版嵁鏇存柊閫熺巼**鍔犻€熷害璁′娇鑳�**********/
 
 
-/***************传感器量程设置**********************/
+/***************浼犳劅鍣ㄩ噺绋嬭�缃�**********************/
 #define  SL_SC7A20_FS_2G          (uint8)0x00
 #define  SL_SC7A20_FS_4G          (uint8)0x10
 #define  SL_SC7A20_FS_8G          (uint8)0x20
 #define  SL_SC7A20_FS_16G         (uint8)0x30
-/***************传感器量程设置**********************/
+/***************浼犳劅鍣ㄩ噺绋嬭�缃�**********************/
 
 
-/***取值在0-127之间,此处仅举例****/
+/***鍙栧€煎湪0-127涔嬮棿锛屾�澶勪粎涓句緥****/
 #define SL_SC7A20_INT_THS_5PERCENT   (uint8)0x06
 #define SL_SC7A20_INT_THS_10PERCENT  (uint8)0x0C
 #define SL_SC7A20_INT_THS_20PERCENT  (uint8)0x18
@@ -144,41 +144,41 @@
 #define SL_SC7A20_INT_THS_80PERCENT  (uint8)0x60
 
 
-/***取值在0-127之间,此处仅举例 乘以ODR单位时间****/
+/***鍙栧€煎湪0-127涔嬮棿锛屾�澶勪粎涓句緥 涔樹互ODR鍗曚綅鏃堕棿****/
 #define SL_SC7A20_INT_DURATION_2CLK  (uint8)0x02
 #define SL_SC7A20_INT_DURATION_5CLK  (uint8)0x05
 #define SL_SC7A20_INT_DURATION_10CLK (uint8)0x0A
 #define SL_SC7A20_INT_DURATION_30CLK  (uint8)0x2E
 
 
-/***中断有效时的电平设置,高电平相当于上升沿,低电平相当于下降沿****/
-#define SL_SC7A20_INT_ACTIVE_LOWER_LEVEL 0x02 //0x02:中断时INT1脚输出 低电平
-#define SL_SC7A20_INT_ACTIVE_HIGH_LEVEL  0x00 //0x00:中断时INT1脚输出 高电平 
+/***涓�柇鏈夋晥鏃剁殑鐢靛钩璁剧疆锛岄珮鐢靛钩鐩稿綋浜庝笂鍗囨部锛屼綆鐢靛钩鐩稿綋浜庝笅闄嶆部****/
+#define SL_SC7A20_INT_ACTIVE_LOWER_LEVEL 0x02 //0x02:涓�柇鏃禝NT1鑴氳緭鍑� 浣庣數骞�
+#define SL_SC7A20_INT_ACTIVE_HIGH_LEVEL  0x00 //0x00:涓�柇鏃禝NT1鑴氳緭鍑� 楂樼數骞� 
 
-/***中断有效时的电平设置,高电平相当于上升沿,低电平相当于下降沿****/
+/***涓�柇鏈夋晥鏃剁殑鐢靛钩璁剧疆锛岄珮鐢靛钩鐩稿綋浜庝笂鍗囨部锛屼綆鐢靛钩鐩稿綋浜庝笅闄嶆部****/
 #define SL_SC7A20_INT_AOI1_INT1          0x40 //AOI1 TO INT1
 #define SL_SC7A20_INT_AOI2_INT1          0x20 //AOI2 TO INT1
 
-/********客户需要进行的IIC接口封包函数****************/
+/********瀹㈡埛闇€瑕佽繘琛岀殑IIC鎺ュ彛灏佸寘鍑芥暟****************/
 Std_ReturnType Gsensor_SPI_Write(uint8 Addr,uint8 *DataBufferPtr,uint16 Length);
 Std_ReturnType Gsensor_SPI_Read(uint8 Addr,uint8 *DataBufferPtr,uint16 Length);
-/**Gsensor_SPI_Write 函数中, sl_spi_iic:0=spi  1=i2c  Reg:寄存器地址   data:寄存器的配置值******************/
-/**Gsensor_SPI_Write 函数 是一个单次写的函数*******************************************************************/
-/***Gsensor_SPI_Read 函数中, sl_spi_iic:0=spi  1=i2c Reg 同上,len:读取数据长度,buf:存储数据首地址(指针)***/
-/***Gsensor_SPI_Read 函数 是可以进行单次读或多次连续读取的函数*************************************************/
+/**Gsensor_SPI_Write 鍑芥暟涓�紝 sl_spi_iic:0=spi  1=i2c  Reg锛氬瘎瀛樺櫒鍦板潃   data锛氬瘎瀛樺櫒鐨勯厤缃�€�******************/
+/**Gsensor_SPI_Write 鍑芥暟 鏄�竴涓�崟娆″啓鐨勫嚱鏁�*******************************************************************/
+/***Gsensor_SPI_Read 鍑芥暟涓�紝 sl_spi_iic:0=spi  1=i2c Reg 鍚屼笂锛宭en:璇诲彇鏁版嵁闀垮害锛宐uf:瀛樺偍鏁版嵁棣栧湴鍧€锛堟寚閽堬級***/
+/***Gsensor_SPI_Read 鍑芥暟 鏄�彲浠ヨ繘琛屽崟娆¤�鎴栧�娆¤繛缁��鍙栫殑鍑芥暟*************************************************/
 
 
 
-/*** 客户IIC函数封装举例
+/*** 瀹㈡埛IIC鍑芥暟灏佽�涓句緥
 uint8 SL_MEMS_i2c_spi_Write(uint8 reg, uint8 data)
 {
-    i2cWrite(SC7A20_IIC_ADDRESS,  reg,  data);       //由客户的II函数接口决定
+    i2cWrite(SC7A20_IIC_ADDRESS,  reg,  data);       //鐢卞�鎴风殑II鍑芥暟鎺ュ彛鍐冲畾
     return 1;
 }
 
 uint8 SL_MEMS_i2c_spi_Read(uint8 reg, uint8 len, uint8 *buf)
 {
-    i2cRead( SC7A20_IIC_ADDRESS,  reg,  len, buf);//由客户的II函数接口决定
+    i2cRead( SC7A20_IIC_ADDRESS,  reg,  len, buf);//鐢卞�鎴风殑II鍑芥暟鎺ュ彛鍐冲畾
     return 1;
 }
 ***/
@@ -200,7 +200,7 @@ void  SL_SC7A20_AOI2_event(void);
 void  SL_SC7A20_Reg_read_all(void);
 Std_ReturnType GsensorInit(void);
 
-//步骤如下:
+//姝ラ�濡備笅锛�
 //0.signed char  SL_SC7A20_BOOT(void);
 //1.signed char  SL_SC7A20_Online_Test(void);
 //2.signed char  SL_SC7A20_FS_Config(uint8 Sc7a20_FS_Reg);

+ 1 - 1
src/UDSTask.c

@@ -1,7 +1,7 @@
 /*
  * UDSTask.c
  *
- *  Created on: 2022Äê3ÔÂ14ÈÕ
+ *  Created on: 2022Äê3ÔÂ14ÈÕ
  *      Author: Zhengchao
  */
 #include "UDSTask.h"

+ 1 - 1
src/UDSTask.h

@@ -1,7 +1,7 @@
 /*
  * UDSTask.h
  *
- *  Created on: 2022Äê3ÔÂ14ÈÕ
+ *  Created on: 2022Äê3ÔÂ14ÈÕ
  *      Author: Zhengchao
  */
 

+ 1 - 1
src/USER_CONFIG.h

@@ -1,7 +1,7 @@
 /*
  * USER_CONFIG.h
  *
- *  Created on: 2022Äê4ÔÂ27ÈÕ
+ *  Created on: 2022Äê4ÔÂ27ÈÕ
  *      Author: Zhengchao
  */
 

+ 5 - 5
src/hal_adapter.c

@@ -1,7 +1,7 @@
 /*
  * hal_adapter.c
- *中间层函数调用库
- *  Created on: 2022年1月18日
+ *涓�棿灞傚嚱鏁拌皟鐢ㄥ簱
+ *  Created on: 2022骞�1鏈�18鏃�
  *      Author: QiXiang_CHENJIE
  */
 #include "hal_adapter.h"
@@ -300,7 +300,7 @@ Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32
 	 uint8 UartState[3] = {UartAbortRecv,UartAbortRecv,UartAbortRecv};
 	 while(1)
 	 {
-		 if((T_timeout[UartIdx]>1000) && (Uart_ReceiveStatus[UartIdx] != UART_STATUS_NO_ERROR) )//判定UART停止,超时停止,不是接收状态则停止
+		 if((T_timeout[UartIdx]>1000) && (Uart_ReceiveStatus[UartIdx] != UART_STATUS_NO_ERROR) )//鍒ゅ畾UART鍋滄�锛岃秴鏃跺仠姝�紝涓嶆槸鎺ユ敹鐘舵€佸垯鍋滄�
 		 {
 			  Uart_Abort(UartIdx, UART_RECEIVE);
 			  UartState[UartIdx] = UartAbortRecv;
@@ -311,7 +311,7 @@ Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32
 			 UartState[UartIdx] = UartRecvComplete;
 		 }
 
-		 if((UartState[UartIdx] == UartAbortRecv) || (UartState[UartIdx] == UartRecvComplete)) //判定UART开始接收:UART停止后开始接收
+		 if((UartState[UartIdx] == UartAbortRecv) || (UartState[UartIdx] == UartRecvComplete)) //鍒ゅ畾UART寮€濮嬫帴鏀讹細UART鍋滄�鍚庡紑濮嬫帴鏀�
 		 {
 			 if(E_OK == UartStartRecvFunc(UartIdx))
 			 {
@@ -385,7 +385,7 @@ Std_ReturnType UART_Send_Data(uint8 transChannel, const uint8 *txBuffer, uint32
 		    	 UartSendState[UartIdx] = UartStartSend;
 		     }
 		 }
-		 /*开始发送后的判定*/
+		 /*寮€濮嬪彂閫佸悗鐨勫垽瀹�*/
 		 if(UartSendState[UartIdx] == UartStartSend)
 		 {
 			 Uart_TransmitStatus[UartIdx] = Uart_GetStatus(UartIdx, &T_bytesRemaining[UartIdx], UART_SEND);

+ 6 - 6
src/hal_adapter.h

@@ -9,8 +9,8 @@
  */
 /*
  * hal_adapter.h
- *Öмä²ãº¯Êýµ÷Óÿâ
- *  Created on: 2022Äê1ÔÂ18ÈÕ
+ *中间层函数调用库
+ *  Created on: 2022年1月18日
  *      Author: QiXiang_CHENJIE
  */
 
@@ -43,7 +43,7 @@
 #include "SL_Sc7a20_Driver.h"
 #include "SEGGER_RTT_Conf.h"
 #include "SEGGER_RTT.h"
-/*ÊÊÓ¦ÐÔ¶¨Òå*/
+/*适应性定义*/
 typedef unsigned char UINT8;
 typedef unsigned short UINT16;
 typedef unsigned long UINT32;
@@ -62,9 +62,9 @@ typedef signed long INT32;
 #ifndef max
 #define max(A, B) ((A) < (B) ? (B) : (A))
 #endif
-#define getbit(x, y) ((x) >> (y)&1) //»ñÈ¡xµÄµÚyλµÄÊýÖµ
-#define setbit(x, y) x |= (1 << y)  // xµÄµÚyλÖÃ1
-#define clrbit(x, y) x &= ~(1 << y) // xµÄµÚyλÖÃ0
+#define getbit(x, y) ((x) >> (y)&1) //获�x的第y�的数值
+#define setbit(x, y) x |= (1 << y)  // x的第y�置1
+#define clrbit(x, y) x &= ~(1 << y) // x的第y�置0
 #define UART_LPUART0 0
 #define UART_LPUART1 1
 #define UART_LPUART2 2

+ 1 - 1
src/main.c

@@ -24,7 +24,7 @@
 
 /**
  *   @file main.c
- * Ö÷º¯ÊýÈë¿Ú
+ * 主函数入�
  *   @addtogroup main_module main module documentation
  *   @{
  */