Jelajahi Sumber

jimbo back up

zhangbo 5 tahun lalu
induk
melakukan
6bd3a14d80

+ 1 - 0
app/goahead-5.1.0/src/action.c

@@ -57,6 +57,7 @@ static bool actionHandler(Webs *wp)
             (*((WebsProc) fn))((void*) wp, actionName, wp->query);
 #else
             (*fn)((void*) wp);
+            printf("---> actionHandler call action execute over\n");
 #endif
         }
     }

+ 82 - 82
app/goahead-5.1.0/src/libipmi/src/libipmi_uds_session.c

@@ -81,47 +81,47 @@ uint8_t UDS_ReceiveData( UDS_CHANNEL_T *UDSInfo, char *szBuffer, uint32_t* pdwSi
     IPMIUDSMsg_T *pData = (IPMIUDSMsg_T *)szBuffer;
     uint32_t nBytesRecvd = 0;
 
-    /* Wait for the socket to get ready */
-    if(timeout >= 0)
-    {
-        wait_time.tv_sec = timeout;
-        wait_time.tv_usec = 0;
-        pwait_time = &wait_time;
-    }
-    else
-        pwait_time = NULL;
-
-    FD_ZERO(&rdfs);
-    FD_SET(UDSInfo->hSocket, &rdfs);
-    nDes = UDSInfo->hSocket + 1;
+    // /* Wait for the socket to get ready */
+    // if(timeout >= 0)
+    // {
+    //     wait_time.tv_sec = timeout;
+    //     wait_time.tv_usec = 0;
+    //     pwait_time = &wait_time;
+    // }
+    // else
+    //     pwait_time = NULL;
+
+    // FD_ZERO(&rdfs);
+    // FD_SET(UDSInfo->hSocket, &rdfs);
+    // nDes = UDSInfo->hSocket + 1;
 
     while(1)
     {
         /* wait for specified amount of time */
-        ret = select (nDes, &rdfs, NULL, NULL, pwait_time);
-        /* socket error */
-        if(ret == -1)
-        {
-            if(errno == EINTR)
-            {
-                printf("select: %s. Continue...\n",strerror(errno));
-                continue;
-            }
-            else
-            {
-                printf("select failed while waiting for read pipe \n");
-                continue;
-            }
-        }
-        else if(ret == 0)
-        {
-              printf("Connection timed out\n");
-              return LIBIPMI_MEDIUM_E_TIMED_OUT;
-         }
-
-        /* socket is ready to receive data */
-        if(FD_ISSET(UDSInfo->hSocket,&rdfs))
-        {
+        // ret = select (nDes, &rdfs, NULL, NULL, pwait_time);
+        // /* socket error */
+        // if(ret == -1)
+        // {
+        //     if(errno == EINTR)
+        //     {
+        //         printf("select: %s. Continue...\n",strerror(errno));
+        //         continue;
+        //     }
+        //     else
+        //     {
+        //         printf("select failed while waiting for read pipe \n");
+        //         continue;
+        //     }
+        // }
+        // else if(ret == 0)
+        // {
+        //       printf("Connection timed out\n");
+        //       return LIBIPMI_MEDIUM_E_TIMED_OUT;
+        //  }
+
+        // /* socket is ready to receive data */
+        // if(FD_ISSET(UDSInfo->hSocket,&rdfs))
+         {
             nBytesRecvd = recv(UDSInfo->hSocket,szBuffer+totalrecvd,MAX_RESPONSE_SIZE,0);
             if(nBytesRecvd == 0)
             {
@@ -156,7 +156,7 @@ uint8_t UDS_ReceiveData( UDS_CHANNEL_T *UDSInfo, char *szBuffer, uint32_t* pdwSi
         return LIBIPMI_STATUS_SUCCESS;
        }
 
-       return LIBIPMI_MEDIUM_E_RECV_DATA_FAILURE; 
+       //return LIBIPMI_MEDIUM_E_RECV_DATA_FAILURE; 
      }
 }
 
@@ -169,49 +169,49 @@ int UDS_SendData(UDS_CHANNEL_T *UDSInfo,char *szBuffer,uint32_t dwsize,int timeo
     struct timeval wait_time, *pwait_time;
     fd_set wdfs;
     int ret;
-    int nDes;
-
-    /* Wait for the socket to get ready */
-    if(timeout >= 0)
-    {
-        wait_time.tv_sec = timeout;
-        wait_time.tv_usec = 0;
-        pwait_time = &wait_time;
-    }
-    else
-        pwait_time = NULL;
-
-    FD_ZERO(&wdfs);
-    FD_SET(UDSInfo->hSocket, &wdfs);
-    nDes = UDSInfo->hSocket + 1;
-
-TCPSendUDSDataSelect:
-    /* wait for specified amount of time */
-    ret = select (nDes, NULL, &wdfs, NULL, pwait_time);
-    /* socket error */
-    if(ret == -1)
-    {
-        if(errno == EINTR)
-        {
-            printf("select: %s. Continue...\n",strerror(errno));
-            goto TCPSendUDSDataSelect;
-        }
-        else
-        {
-            printf("Select failed while waiting for write pipe \n");
-            close(UDSInfo->hSocket);
-            return LIBIPMI_MEDIUM_E_INVALID_SOCKET;
-        }
-    }
-    /* timed out */
-    else if(ret == 0)
-    {
-        printf("Connection timedout: Write Pipe is full \n");
-        close(UDSInfo->hSocket);
-        return LIBIPMI_MEDIUM_E_TIMED_OUT_ON_SEND;
-    }
-
-    if(FD_ISSET(UDSInfo->hSocket,&wdfs))
+ //   int nDes;
+
+    // /* Wait for the socket to get ready */
+    // if(timeout >= 0)
+    // {
+    //     wait_time.tv_sec = timeout;
+    //     wait_time.tv_usec = 0;
+    //     pwait_time = &wait_time;
+    // }
+    // else
+    //     pwait_time = NULL;
+
+    // FD_ZERO(&wdfs);
+    // FD_SET(UDSInfo->hSocket, &wdfs);
+    // nDes = UDSInfo->hSocket + 1;
+
+// TCPSendUDSDataSelect:
+//     /* wait for specified amount of time */
+//     ret = select (nDes, NULL, &wdfs, NULL, pwait_time);
+//     /* socket error */
+//     if(ret == -1)
+//     {
+//         if(errno == EINTR)
+//         {
+//             printf("select: %s. Continue...\n",strerror(errno));
+//             goto TCPSendUDSDataSelect;
+//         }
+//         else
+//         {
+//             printf("Select failed while waiting for write pipe \n");
+//             close(UDSInfo->hSocket);
+//             return LIBIPMI_MEDIUM_E_INVALID_SOCKET;
+//         }
+//     }
+//     /* timed out */
+//     else if(ret == 0)
+//     {
+//         printf("Connection timedout: Write Pipe is full \n");
+//         close(UDSInfo->hSocket);
+//         return LIBIPMI_MEDIUM_E_TIMED_OUT_ON_SEND;
+//     }
+
+ //   if(FD_ISSET(UDSInfo->hSocket,&wdfs))
     {
         /* socket is ready to send data */
         nTotalBytesSent = 0;
@@ -247,6 +247,6 @@ TCPSendUDSDataSelect:
         return LIBIPMI_STATUS_SUCCESS;
 
     }
-    return LIBIPMI_MEDIUM_E_SEND_DATA_FAILURE;
+    //return LIBIPMI_MEDIUM_E_SEND_DATA_FAILURE;
  }
 

+ 27 - 15
app/goahead-5.1.0/src/web_interface/src/dashboard.c

@@ -388,7 +388,7 @@ void buy(Webs *wp)
      logmsg(2, "----------------------------11-----------------");
     logmsg(2, "name value is : %s", name );
      logmsg(2, "age value is : %s", age );
-    websSetStatus(wp, WEBS_KEEP_ALIVE);
+    websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);
    
@@ -414,31 +414,43 @@ void actionTest(Webs *wp)
 
     //Create session
     printf("actionTest!\n");
-    // LIBIPMI_CreateSession(&UDSSession, 10);
-    // IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
-    // LIBIPMI_CloseSession(&UDSSession );
+    LIBIPMI_CreateSession(&UDSSession, 10);
+    IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
+    LIBIPMI_CloseSession(&UDSSession );
 
     char *pStr;
 
-    // char *testStr;
-    // testStr = malloc(200); 
-    // sprintf(testStr, "version %d.%d, buildTime %s %s", \
-    //     DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2, __DATE__, __TIME__);
+    char *testStr;
+    testStr = malloc(500); 
+    //sprintf(testStr, "{data: {\"Version\": \"%s\", \"MAC\": \"%s\", \"IP\": \"%s\"}, \"msg\":\"\"}", FwVersion, MacAddr, IpAddr);
+
+    sprintf(testStr, "{\n\t\"data\": {\n\t\t\"buildTime\":\"%s\",\n\t\t\"fwVersion\":\"%s\",\n\t\t\"macAddr\":\"%s\",\n\t\t\"ipAddr\":\"%s\"\n\t},\n\t\"msg\":\"\",\n\t\"code\": %d\n}", \
+        BuildTime, FwVersion, MacAddr, IpAddr, 200);
+
+
+    //sprintf(testStr, "jimbo and lusa are very confused, please git me some tips, my god!");
+
+    pStr = testStr;
 
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
-    cJSON_AddItemToObject(root, "data", data);//根节点下添加
-    cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
-    cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
+    printf("log1\n");
+    //cJSON_AddItemToObject(root, "data", data);//根节点下添加
+    cJSON_AddStringToObject(root, "msg", NULL);
+    cJSON_AddNumberToObject(root, "code", 200);
     cJSON_AddStringToObject(data, "buildTime", BuildTime);
     cJSON_AddStringToObject(data, "fwVersion", FwVersion);
     cJSON_AddStringToObject(data, "macAddr", MacAddr);
     cJSON_AddStringToObject(data, "ipAddr", IpAddr);
-
-    pStr = cJSON_Print(root);     //include malloc
-    //pStr = testStr;
-
+ //   /*pStr = */cJSON_Print(root);     //include malloc
     
+    printf("%s\n", pStr);
+    int i=0;
+    while(pStr[i])
+    {
+        printf("%#x ", pStr[i++]);
+    }
+    printf("\n");
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);