Browse Source

网络OTA,硬件V2版本测试

CHENJIE-PC\QiXiang_CHENJIE 4 years ago
parent
commit
c30d14deb1
3 changed files with 15 additions and 4 deletions
  1. 1 1
      inc/hal_module_adapter.h
  2. 13 2
      src/app.c
  3. 1 1
      src/bsp_custom.c

+ 1 - 1
inc/hal_module_adapter.h

@@ -7,7 +7,7 @@ extern "C" {
 #include "commontypedef.h"
 #include "sensor.h"
 #include "can.h"
-//#define USING_PRINTF 
+#define USING_PRINTF 
 #define GPS_DATA_RECV_BUFFER_SIZE     						(1024)
 
 #define I2C_INT1_REQ_BITMAP    								 (0x1)

+ 13 - 2
src/app.c

@@ -351,8 +351,8 @@ static void Main_Task(void* arg)
                     if(!slpManDeepSlpTimerIsRunning(deepslpTimerID))
                     {
                         slpManDeepSlpTimerDel(deepslpTimerID);
-                        slpManDeepSlpTimerStart(deepslpTimerID, Sleep_Time);
                     }
+                    slpManDeepSlpTimerStart(deepslpTimerID, Sleep_Time);
                     osDelay(60000/portTICK_PERIOD_MS);
                 }
                 break;
@@ -1140,11 +1140,12 @@ void Tcp_Gps_Data_Assemble(void)
 static void Tcp_Task(void* arg)
 {
     
-    CHAR SN[] = "GYTEST00000000001";//SN应写到osfile里面
+    CHAR SN[] = "GYTEST00000000002";//SN应写到osfile里面
     CHAR   serverip[] = "47.97.127.222";
     CHAR  serverport[] = "8712";
     struct addrinfo hints, *server_res;
     int TcpsendID = -1;
+    int TcprecvID = -1;
     memset( &hints, 0, sizeof( hints ) );
     hints.ai_socktype = SOCK_STREAM;
     hints.ai_protocol = IPPROTO_TCP;
@@ -1154,6 +1155,7 @@ static void Tcp_Task(void* arg)
     PROC_TCP_STATE_SWITCH(PROCESS_TCP_STATE_IDLE);
     uint8_t Tcp_Index = 0;
     uint8_t* TcpSendBuffer=NULL;
+    uint8_t* TcpRecvBuffer=NULL;
     volatile bool Tcp_Flag=false;
     eventCallbackMessage_t *queueItem = NULL;
     uint8_t pmode;
@@ -1289,6 +1291,7 @@ static void Tcp_Task(void* arg)
                         {
                             NB_send_len=59+Batt_Cell_Num_2+Batt_Temp_Num;//电池数据长度
                             TcpSendBuffer = (uint8_t *)malloc(NB_send_len);
+                            TcpRecvBuffer = (uint8_t *)malloc(NB_send_len);
                             data_index = 0;
                             memset(TcpSendBuffer,0x00,NB_send_len);
                             *(TcpSendBuffer+0) = 0x23;
@@ -1311,6 +1314,7 @@ static void Tcp_Task(void* arg)
                                 printf("\n");
                             #endif
                             TcpsendID = send(sockfd, TcpSendBuffer, NB_send_len, 0 );
+                            TcprecvID = recv(sockfd, TcpRecvBuffer, NB_send_len, 0);
                             //发送失败
                             #ifdef USING_PRINTF
                                 printf("ConnectID:%d,TcpSend:%d,data length:%d,Data:  ",sockfd,TcpsendID,NB_send_len);
@@ -1319,8 +1323,15 @@ static void Tcp_Task(void* arg)
                                     printf("%x ",*(TcpSendBuffer+i));
                                 }
                                 printf("\n");
+                                printf("ConnectID:%d,TcpRecv:%d,data length:%d,Data:  ",sockfd,TcprecvID,NB_send_len);
+                                for (int i = 0; i < NB_send_len; i++)
+                                {
+                                    printf("%x ",*(TcpRecvBuffer+i));
+                                }
+                                printf("\n");
                             #endif
                             free(TcpSendBuffer);
+                            free(TcpRecvBuffer);
                             if (TcpsendID<0)
                             {
                                 closesocket(sockfd);

+ 1 - 1
src/bsp_custom.c

@@ -139,7 +139,7 @@ void BSP_CustomInit(void)
     BSP_LoadPlatConfigFromRawFlash();
     rawFlashPlatConfig = BSP_GetRawFlashPlatConfig();
 #ifdef USING_PRINTF
-	SetPrintUart(PORT_USART_0);
+	SetPrintUart(PORT_USART_1);
 #else
     if(rawFlashPlatConfig && (rawFlashPlatConfig->logControl != 0 ))
     {