Просмотр исходного кода

1.新增了一些变动的代码注释; 2.修正了变量错别字之emergy改为emergencyflag;

xuy лет назад: 3
Родитель
Сommit
fcfc9e0659
3 измененных файлов с 28 добавлено и 27 удалено
  1. 1 1
      Inc/CollectMaster485.h
  2. 23 23
      Src/TerminalSlave485.c
  3. 4 3
      Src/freertos.c

+ 1 - 1
Inc/CollectMaster485.h

@@ -280,7 +280,7 @@ typedef union {
 
 typedef struct
 {
-	uint8_t enable;
+	uint8_t enable; // 对应存储区首地址字节内容为0x5A,表示使能开启
 	uint8_t step;  // 构建周期
 	uint8_t nstep; // 上报周期,是step的倍数
 	uint8_t cmd_num;  // 命令数据的总数

+ 23 - 23
Src/TerminalSlave485.c

@@ -1127,10 +1127,10 @@ void Send_A1_Cmd(unsigned char scrAddr, unsigned char funCode, unsigned char scr
  * 返回: 构建数据的字节总数
  ***************************************
  */
-int BuildA1Cmd(uint8_t *pBuf, uint32_t flowID, uint8_t *pEmergy)
+int BuildA1Cmd(uint8_t *pBuf, uint32_t flowID, uint8_t *pEmergencyflag)
 {
 	int send_pos=0;
-	unsigned char emergy=0;
+	unsigned char emergencyflag=0;
 	unsigned char Lrc_temp;
 	unsigned char overflow_flag=0;
 	int i,j;
@@ -1142,7 +1142,7 @@ int BuildA1Cmd(uint8_t *pBuf, uint32_t flowID, uint8_t *pEmergy)
 	{
 		if(memcmp(Cang_IO_tbak[0],Cang01_IO,64))
 		{
-			emergy=0x80;
+			emergencyflag=0x80;
 		}
 		memcpy(Cang_IO_tbak[0],Cang01_IO,64);
 	}
@@ -1150,7 +1150,7 @@ int BuildA1Cmd(uint8_t *pBuf, uint32_t flowID, uint8_t *pEmergy)
 	{
 		if(memcmp(Cang_IO_tbak[1],Cang02_IO,64))
 		{
-			emergy=0x80;
+			emergencyflag=0x80;
 		}
 		memcpy(Cang_IO_tbak[1],Cang02_IO,64);
 	}
@@ -1158,7 +1158,7 @@ int BuildA1Cmd(uint8_t *pBuf, uint32_t flowID, uint8_t *pEmergy)
 	{
 		if(memcmp(Cang_IO_tbak[2],Cang03_IO,64))
 		{
-			emergy=0x80;
+			emergencyflag=0x80;
 		}
 		memcpy(Cang_IO_tbak[2],Cang03_IO,64);
 	}
@@ -1166,7 +1166,7 @@ int BuildA1Cmd(uint8_t *pBuf, uint32_t flowID, uint8_t *pEmergy)
 	{
 		if(memcmp(Cang_IO_tbak[3],Cang04_IO,64))
 		{
-			emergy=0x80;
+			emergencyflag=0x80;
 		}
 		memcpy(Cang_IO_tbak[3],Cang04_IO,64);
 	}
@@ -1181,11 +1181,11 @@ int BuildA1Cmd(uint8_t *pBuf, uint32_t flowID, uint8_t *pEmergy)
 	overflow_cnt_bak=overflow_cnt;
 	if(overflow_flag_bak!=overflow_flag)
 	{
-		emergy=0x80;	
+		emergencyflag=0x80;	
 	}
 	overflow_flag_bak=overflow_flag;
 
-	pBuf[send_pos++] = emergy;
+	pBuf[send_pos++] = emergencyflag;
 	pBuf[send_pos++] = StoreNumber;
 	pBuf[send_pos++] = 0x22;
 	pBuf[send_pos++] = overflow_flag;
@@ -1245,7 +1245,7 @@ int BuildA1Cmd(uint8_t *pBuf, uint32_t flowID, uint8_t *pEmergy)
 		pBuf[send_pos++] = 0;
 	}
 
-	if (pEmergy) *pEmergy = emergy;
+	if (pEmergencyflag) *pEmergencyflag = emergencyflag;
 	return send_pos;
 }
 
@@ -1280,11 +1280,11 @@ int BuildTimeCmd(uint8_t *pBuf)
  * 返回: 构建数据的字节总数
  ***************************************
  */
-int BuildSealTxCmd(uint8_t *pBuf, uint8_t *pEmergy) // 40命令
+int BuildSealTxCmd(uint8_t *pBuf, uint8_t *pEmergencyflag) // 40命令
 {
 	Return_data *ret;
 	int n = 0;
-	uint8_t emergy = 0;
+	uint8_t emergencyflag = 0;
 
 	*pBuf++ = 0x40;
 	ret = Seal_Tx_Readvalue(0,0);
@@ -1294,8 +1294,8 @@ int BuildSealTxCmd(uint8_t *pBuf, uint8_t *pEmergy) // 40
 		pBuf[n] = MODBUS_ASCII_AsciiToHex(ret->data + 2*n);
 	}
 
-	emergy = pBuf[0];
-	if(pEmergy) *pEmergy = emergy;
+	emergencyflag = pBuf[0];
+	if(pEmergencyflag) *pEmergencyflag = emergencyflag;
 	return n+2;
 }
 
@@ -1306,11 +1306,11 @@ int BuildSealTxCmd(uint8_t *pBuf, uint8_t *pEmergy) // 40
  * 返回: 构建数据的字节总数
  ***************************************
  */
-int Build91Cmd(uint8_t *pBuf, uint8_t *pEmergy) 
+int Build91Cmd(uint8_t *pBuf, uint8_t *pEmergencyflag) 
 {
 	Return_data *ret;
 	int n = 0;
-	uint8_t emergy = 0;
+	uint8_t emergencyflag = 0;
 
 	*pBuf++ = 0x91;
 	ret = IO_Tx_Readvalue(0,0);
@@ -1320,8 +1320,8 @@ int Build91Cmd(uint8_t *pBuf, uint8_t *pEmergy)
 		pBuf[n] = MODBUS_ASCII_AsciiToHex(ret->data + 2*n);
 	}
 
-	emergy = pBuf[0];
-	if(pEmergy) *pEmergy = emergy;
+	emergencyflag = pBuf[0];
+	if(pEmergencyflag) *pEmergencyflag = emergencyflag;
 	return n+2;
 }
 
@@ -1340,7 +1340,7 @@ int Build91Cmd(uint8_t *pBuf, uint8_t *pEmergy)
 void DoInternalSensorScanAndPost()
 {
 	int xlen=0, ylen=0;
-	uint8_t emergy=0;
+	uint8_t emergencyflag=0;
 	uint8_t *pSendBuf = USART1_TX_BUF;
 	static int step = 0;
 	static int nstep = 0;
@@ -1350,17 +1350,17 @@ void DoInternalSensorScanAndPost()
 		for(int n=0; n<Pass41SensorScanParam.cmd_num; n++) {
 			switch (Pass41SensorScanParam.cmd_arr[n]){
 			case 0x40:
-				xlen = BuildSealTxCmd(pSendBuf, emergy?NULL:&emergy);
+				xlen = BuildSealTxCmd(pSendBuf, emergencyflag?NULL:&emergencyflag);
 				pSendBuf += xlen;
 			    ylen += xlen;
 				break;
 			case 0x91:
-				xlen = Build91Cmd(pSendBuf, emergy?NULL:&emergy);
+				xlen = Build91Cmd(pSendBuf, emergencyflag?NULL:&emergencyflag);
 				pSendBuf += xlen;
 			    ylen += xlen;
 				break;
 			case 0xA1:
-				xlen = BuildA1Cmd(pSendBuf, flowID, emergy?NULL:&emergy); 
+				xlen = BuildA1Cmd(pSendBuf, flowID, emergencyflag?NULL:&emergencyflag); 
 				pSendBuf += xlen;
 			    ylen += xlen;
 				break;
@@ -1369,10 +1369,10 @@ void DoInternalSensorScanAndPost()
 			}
 		}
 		
-		if(emergy) {
+		if(emergencyflag) {
 			TerminalSlave485_Send_Data(USART1_TX_BUF,ylen);
 			nstep = 0;
-			emergy = 0;
+			emergencyflag = 0;
 			flowID++;
 		} else {
 			if(++nstep % Pass41SensorScanParam.nstep == 0) {

+ 4 - 3
Src/freertos.c

@@ -1026,7 +1026,7 @@ void Task_Usart1_Terminal(void const *argument)
 void Task_GetCPU_Usage(void const *argument)
 {
 	/* USER CODE BEGIN Task_GetCPU_Usage */
-	char min=-1;
+	char hour=-1;
 	int count;
 	int i_task01;
 	EventBits_t uxBits;
@@ -1039,10 +1039,11 @@ void Task_GetCPU_Usage(void const *argument)
 		//DispRunInfo();//显示运行信息
 		cntUsage++;
 		osDelay(500); //阻塞延时,根据情况调节
-		if(m_datetime.hour!=min)
+		//2022-9-13, xy, 这里RTC时钟是按每分钟去读取一下RTC芯片校时的,但实在没必要如此频繁,优化成每小时
+		if(m_datetime.hour!=hour)
 		{
 			ds1302_SynTime(&m_datetime);
-			min = m_datetime.hour;
+			hour = m_datetime.hour;
 		}
 		uxBits = xEventGroupWaitBits(xCreatedEventGroup, /* 事件标志组句柄 */
                                      TASK_BIT_ALL,       /* 等待TASK_BIT_ALL被设置 */