Browse Source

继电器网络端控制完成,仍使用高压互锁测试

CHENJIE-PC\QiXiang_CHENJIE 3 years ago
parent
commit
207debed9c
4 changed files with 53 additions and 9 deletions
  1. 1 1
      inc/Signal.h
  2. 1 0
      src/Signal.c
  3. 47 1
      src/TcpTask.c
  4. 4 7
      src/UartTask.c

+ 1 - 1
inc/Signal.h

@@ -29,7 +29,7 @@ extern	UINT8	reservedSignal6;
 extern	UINT8	reservedSignal7;
 extern	UINT8	reservedSignal7;
 extern	UINT8	reservedSignal8;
 extern	UINT8	reservedSignal8;
 extern  UINT8   RelayControlState;
 extern  UINT8   RelayControlState;
-
+extern  UINT8	BuzzerControl;
 
 
 
 
 //declear the UINT16 vars
 //declear the UINT16 vars

+ 1 - 0
src/Signal.c

@@ -61,6 +61,7 @@ UINT8	reservedSignal6 = 0xFF;
 UINT8	reservedSignal7 = 0xFF;
 UINT8	reservedSignal7 = 0xFF;
 UINT8	reservedSignal8 = 0xFF;
 UINT8	reservedSignal8 = 0xFF;
 UINT8   RelayControlState = 0x00;
 UINT8   RelayControlState = 0x00;
+UINT8	BuzzerControl = 0x00;
 //declear the UINT16 vars
 //declear the UINT16 vars
 UINT16	battCellU[28] = {0xFFFF};
 UINT16	battCellU[28] = {0xFFFF};
 UINT16	minCellVol = 0xFFFF;
 UINT16	minCellVol = 0xFFFF;

+ 47 - 1
src/TcpTask.c

@@ -692,7 +692,7 @@ static void TcpDataInfoRecvHandle()
                             AppNVMData.isBattLocked = TRUE;
                             AppNVMData.isBattLocked = TRUE;
                             tcpipConnectionSend(socContext.id,TcpCmdAnswer,31,0,0,0);
                             tcpipConnectionSend(socContext.id,TcpCmdAnswer,31,0,0,0);
                         }
                         }
-                        else                //0x02代表解锁
+                        else if(*(Ptr+31)==0x02)              //0x02代表解锁
                         {
                         {
                             AppNVMData.appDataModify = TRUE;
                             AppNVMData.appDataModify = TRUE;
                             AppNVMData.isBattLocked = FALSE;
                             AppNVMData.isBattLocked = FALSE;
@@ -700,6 +700,52 @@ static void TcpDataInfoRecvHandle()
                         }
                         }
                         TcpService=0x00;
                         TcpService=0x00;
                         
                         
+                    }
+                    else if(*(Ptr+30)==0x8A)//继电器控制
+                    {
+                        TcpCmdAnswer[3] = 0x01;
+                        memcpy(&TcpCmdAnswer[4],(Ptr+4),BATT_SN_LEN);
+                        TcpCmdAnswer[21] = TCP_ENCPT_DISABLE;
+                        TcpCmdAnswer[22] = 0x00;
+                        TcpCmdAnswer[23] = 0x06;
+                        memcpy(&TcpCmdAnswer[24],(Ptr+24),6);
+                        TcpCmdAnswer[30] = bcc_chk(TcpCmdAnswer,30);
+                        if(*(Ptr+31)==0x01)//0x01代表断开
+                        {
+                            AppDataInfo.appDataModify = TRUE;
+                            AppDataInfo.RelayControl = TRUE;
+                            tcpipConnectionSend(socContext.id,TcpCmdAnswer,31,0,0,0);
+                        }
+                        else if(*(Ptr+31)==0x00)             //0x00代表关闭
+                        {
+                            AppDataInfo.appDataModify = TRUE;
+                            AppDataInfo.RelayControl = FALSE;
+                            tcpipConnectionSend(socContext.id,TcpCmdAnswer,31,0,0,0);
+                        }
+                        TcpService=0x00;
+                        
+                    }
+                    else if(*(Ptr+30)==0x89)//蜂鸣器控制
+                    {
+                        TcpCmdAnswer[3] = 0x01;
+                        memcpy(&TcpCmdAnswer[4],(Ptr+4),BATT_SN_LEN);
+                        TcpCmdAnswer[21] = TCP_ENCPT_DISABLE;
+                        TcpCmdAnswer[22] = 0x00;
+                        TcpCmdAnswer[23] = 0x06;
+                        memcpy(&TcpCmdAnswer[24],(Ptr+24),6);
+                        TcpCmdAnswer[30] = bcc_chk(TcpCmdAnswer,30);
+                        if(*(Ptr+31)==0x01)//0x01代表断开
+                        {
+                            BuzzerControl = TRUE;
+                            tcpipConnectionSend(socContext.id,TcpCmdAnswer,31,0,0,0);
+                        }
+                        else if(*(Ptr+31)==0x00)             //0x00代表关闭
+                        {
+                            BuzzerControl = FALSE;
+                            tcpipConnectionSend(socContext.id,TcpCmdAnswer,31,0,0,0);
+                        }
+                        TcpService=0x00;
+                        
                     }
                     }
                     else
                     else
                     {
                     {

+ 4 - 7
src/UartTask.c

@@ -156,7 +156,7 @@ static void UartTask(void* arg)
 					#ifdef USING_PRINTF
 					#ifdef USING_PRINTF
                         printf("[%d]PinValue:%X,RelayControl:%x,Relaystate:%x\n",__LINE__,slpManGetWakeupPinValue()&(0x01<<2),(UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2])&0x80,(UartReadMsg.data[(0x09+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2]+1)&0x80);
                         printf("[%d]PinValue:%X,RelayControl:%x,Relaystate:%x\n",__LINE__,slpManGetWakeupPinValue()&(0x01<<2),(UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2])&0x80,(UartReadMsg.data[(0x09+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2]+1)&0x80);
                     #endif
                     #endif
-					if((slpManGetWakeupPinValue()&(0x01<<2))==0)
+					if((slpManGetWakeupPinValue()&(0x01<<2))==0)//继电器测试
 					{
 					{
 						AppDataInfo.RelayControl=TRUE;
 						AppDataInfo.RelayControl=TRUE;
 					}
 					}
@@ -164,9 +164,6 @@ static void UartTask(void* arg)
 					{
 					{
 						AppDataInfo.RelayControl=FALSE;
 						AppDataInfo.RelayControl=FALSE;
 					} 
 					} 
-					#ifdef USING_PRINTF
-                        printf("[%d]RelayControl:%x\n",__LINE__,AppDataInfo.RelayControl);
-                    #endif
                 }
                 }
 				if(UartReadMsg.Header[2]>0)
 				if(UartReadMsg.Header[2]>0)
 				{
 				{
@@ -234,11 +231,11 @@ static void UartTask(void* arg)
 					relayControlFunc(2);
 					relayControlFunc(2);
 					ret = 0x00;
 					ret = 0x00;
 				}
 				}
-				else if(AppDataInfo.RelayControl==TRUE)
+				else if(BuzzerControl==TRUE && Timer_count%20==0)
 				{
 				{
 					relayControlFunc(1);
 					relayControlFunc(1);
 				}
 				}
-				if(AppDataInfo.RelayControl==TRUE && ((UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2])&0x80)==0x00)
+				if(AppDataInfo.RelayControl==TRUE && ((UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2])&0x80)==0x00)//继电器断开
 				{
 				{
 					UartWriteData.WriteCmd = 0x03;
 					UartWriteData.WriteCmd = 0x03;
 					UartWriteData.Data[0] = 0x80;
 					UartWriteData.Data[0] = 0x80;
@@ -246,7 +243,7 @@ static void UartTask(void* arg)
 					osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,1000);
 					osMessageQueuePut(UartWriteCmdHandle,&UartWriteData,0,1000);
 					PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
 					PROC_UART_STATE_SWITCH(PROCESS_UART_STATE_READ);
 				}
 				}
-				else if(AppDataInfo.RelayControl==FALSE && ((UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2])&0x80)==0x80)
+				else if(AppDataInfo.RelayControl==FALSE && ((UartReadMsg.data[(0x1B+BATT_CELL_VOL_NUM+BATT_TEMP_NUM+BATT_OTHER_TEMP_NUM)*2])&0x80)==0x80)//继电器闭合
 				{
 				{
 					UartWriteData.WriteCmd = 0x03;
 					UartWriteData.WriteCmd = 0x03;
 					UartWriteData.Data[0] = 0x00;
 					UartWriteData.Data[0] = 0x00;