Kaynağa Gözat

测试版本,增加北京时区转换

CHENJIE-PC\QiXiang_CHENJIE 3 yıl önce
ebeveyn
işleme
92bb4779ba
4 değiştirilmiş dosya ile 42 ekleme ve 15 silme
  1. 11 2
      inc/hal_module_adapter.h
  2. 14 3
      src/TcpTask.c
  3. 1 1
      src/UartTask.c
  4. 16 9
      src/hal_module_adapter.c

+ 11 - 2
inc/hal_module_adapter.h

@@ -123,7 +123,15 @@ typedef struct _Can_TxMsgType
     UINT8 DLC;
     UINT8 Data[8];
 }Can_TxMsgType;
-
+typedef struct UTC8Time_Type
+{
+    UINT16 year; 
+	UINT8 month; 
+	UINT8 day; 
+	UINT8 hour; 
+	UINT8 minute; 
+	UINT8 second; 
+}UTC8TimeType;
 #ifdef BL_FILE_LOG
 typedef enum
 {
@@ -167,7 +175,8 @@ void HAL_Can_Sleep(void);
 INT32 HAL_Can_Reset(void);
 INT8 HAL_Can_Transmit(CAN_Msg_Type Can_TxMsg);
 void  HAL_Can_Receive(CAN_Msg_Type* CanRxMsgBuffer);
- #ifdef BL_FILE_LOG
+void UTCToBeijing(UTC8TimeType* UTC8Time,unsigned int UTCyear,unsigned char UTCmonth,unsigned char UTCday,unsigned int UTChour,unsigned char UTCminute,unsigned char UTCsecond);
+#ifdef BL_FILE_LOG
 void bluejoy_printf(BlLogLevel level, const UINT8 *format, ...);
 void bluejoy_read_logfile(void);
 void bluejoy_del_logfile(void);

+ 14 - 3
src/TcpTask.c

@@ -276,9 +276,6 @@ static void TcpDataInfoAssembleSend()
             GpsSendFreq = AppDataInfo.GpsChrgInfoSendFreq/5;
             break;
     }    
-    #ifdef USING_PRINTF1
-            printf("send_counter= %x,BattSendFreq= %x,GpsSendFreq= %x,UartReadMsg:%x\n",send_counter,BattSendFreq,GpsSendFreq,UartReadMsg.data[(0x03+BATT_CELL_VOL_NUM)*2+1]);
-    #endif
     if(send_counter%BattSendFreq==0)
     {
         //osStatus_t result = osMutexAcquire(UartMutex, osWaitForever);
@@ -293,6 +290,20 @@ static void TcpDataInfoAssembleSend()
         BattToTcpInfo.encryptMethod = TCP_ENCPT_DISABLE; //not encrypt
 	    BattToTcpInfo.dataLength[0] = (DataLen>>8) & 0xFF;
 	    BattToTcpInfo.dataLength[1] = DataLen & 0xFF;
+        UINT16 year;
+        UINT8 month,day,hour,minite,sec;
+        UTC8TimeType UTC8TimeTcp;
+        year=(TimeStracture.UTCtimer1&0xffff0000)>>16;
+        month=(TimeStracture.UTCtimer1&0xff00)>>8;
+        day=TimeStracture.UTCtimer1&0xff;
+        hour=(TimeStracture.UTCtimer2&0xff000000)>>24;
+        minite=(TimeStracture.UTCtimer2&0xff0000)>>16;
+        sec=(TimeStracture.UTCtimer2&0xff00)>>8;
+        UTCToBeijing((UTC8TimeType *)&UTC8TimeTcp,year,month,day,hour,minite,sec);
+        #ifdef USING_PRINTF
+            printf("year:%x\n",year);
+            printf("year:%x,month:%d,day:%d,hour:%d,minute:%d,second:%d\n",UTC8TimeTcp.year,UTC8TimeTcp.month,UTC8TimeTcp.day,UTC8TimeTcp.hour,UTC8TimeTcp.minute,UTC8TimeTcp.second);
+        #endif
         BattToTcpInfo.battInfo.sendTimeUTC[0] = ((((TimeStracture.UTCtimer1) >> 16) & 0xFFFF) - 0x07D0) & 0xFF; 	//year
         BattToTcpInfo.battInfo.sendTimeUTC[1] = ((TimeStracture.UTCtimer1) >> 8 ) & 0xFF;							//month
         BattToTcpInfo.battInfo.sendTimeUTC[2] = (TimeStracture.UTCtimer1) & 0xFF;									//day

+ 1 - 1
src/UartTask.c

@@ -531,7 +531,7 @@ UINT8 Uart_DataRecv_func(UINT8* Uart_Read_Msg,UINT8* Uart_Recv_Buffer)
             }
         } 
     }
-     #ifdef USING_PRINTF
+     #ifdef USING_PRINTF1
          printf("Uart_Rece_buffer1: ");
          for(int i=0;i<Data_Len;i++)
          {

+ 16 - 9
src/hal_module_adapter.c

@@ -198,12 +198,7 @@ led_pin_config_t gLedCfg[LED_INX_MAX]={{LED_PORT_0,LED_GPIO_PIN_1,LED_PAD_INDEX1
 									 {LED_PORT_0,LED_GPIO_PIN_4,LED_PAD_INDEX4, PAD_MuxAlt0},\
 								       {LED_PORT_1,LED_GPIO_PIN_5,LED_PAD_INDEX5, PAD_MuxAlt0}};
 
-#ifdef BL_FILE_LOG
-#include <stdarg.h>
-static UINT8 blLogFileNux=0;
-
-//UTCת»»Îª±±¾©Ê±¼ä  º¯Êý¿ÉÖ±½Óµ÷ÓÃ
-static void UTCToBeijing(unsigned char * bjttbuf,unsigned int UTCyear,unsigned char UTCmonth,unsigned char UTCday,unsigned int UTChour,unsigned char UTCminute,unsigned char UTCsecond)
+void UTCToBeijing(UTC8TimeType* UTC8Time,unsigned int UTCyear,unsigned char UTCmonth,unsigned char UTCday,unsigned int UTChour,unsigned char UTCminute,unsigned char UTCsecond)
 {
 	int year=0,month=0,day=0,hour=0;
     int lastday = 0;// ÔµÄ×îºóÒ»ÌìÈÕÆÚ
@@ -258,10 +253,20 @@ static void UTCToBeijing(unsigned char * bjttbuf,unsigned int UTCyear,unsigned c
 				}
 		}
 		
-		sprintf((char *)bjttbuf,"%04d-%02d-%02d %02d:%02d:%02d ",
-							year,month,day,hour,UTCminute,UTCsecond);	//UTCÈÕÆÚʱ·ÖÃëת»»³É±±¾©Ê±¼ä
+	UTC8Time->year = year;
+	UTC8Time->month = month;
+	UTC8Time->day = day;
+	UTC8Time->hour = hour;
+	UTC8Time->minute = UTCminute;
+	UTC8Time->second = UTCsecond;
 }
 
+#ifdef BL_FILE_LOG
+#include <stdarg.h>
+static UINT8 blLogFileNux=0;
+
+//UTCת»»Îª±±¾©Ê±¼ä  º¯Êý¿ÉÖ±½Óµ÷ÓÃ
+
 static void bluejoy_write_logfile(UINT8 * buf)
 {
 	int32_t err;
@@ -371,7 +376,9 @@ void bluejoy_printf(BlLogLevel level, const UINT8 *format, ...)
 	minite=(timeUtc.UTCtimer2&0xff0000)>>16;
 	sec=(timeUtc.UTCtimer2&0xff00)>>8;
 	memset(buf,0,128+1);
-	UTCToBeijing(buf,year,month,day,hour,minite,sec);
+	UTC8TimeType UTC8TimeStruct;
+	UTCToBeijing(UTC8TimeStruct,year,month,day,hour,minite,sec);
+	sprintf((char *)buf,"%04d-%02d-%02d %02d:%02d:%02d ",UTC8TimeStruct.year,UTC8TimeStruct.month,UTC8TimeStruct.day,UTC8TimeStruct.hour,UTC8TimeStruct.minute,UTC8TimeStruct.second);
 	va_start(args, format);
 	vsnprintf(buf+strlen(buf), 128-strlen(buf), format, args);
 	va_end(args);