添加PingTest产测UI 1016/1
authorpenglei <1624952103@qq.com>
Wed, 25 Sep 2024 10:53:54 +0000 (18:53 +0800)
committerpenglei <1624952103@qq.com>
Wed, 25 Sep 2024 10:53:54 +0000 (18:53 +0800)
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPing.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h
code/sdk/application/wearable/fd230app/nativeui/producttest/include/testView.h
code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPing.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/producttest/src/testView.cpp
code/sdk/application/wearable/fd230app/nativeui/producttest/src/testcat1.cpp
code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c
code/sdk/open_source/openharmony/third_party/lwip/port/lwip-2.1/porting/include/lwip/api_shell.h
code/sdk/open_source/openharmony/third_party/lwip/port/lwip-2.1/porting/src/api_shell.c

index 7372ec0..610d5d5 100644 (file)
@@ -752,6 +752,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testbt.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testSEChipTest.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testModel.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/producttest/src/testPing.cpp
     
     #每日目标
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/goal/src/goalmodel.cpp
diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPing.h b/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPing.h
new file mode 100644 (file)
index 0000000..77f26ad
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * @Author: penglei 1624952103@qq.com
+ * @Date: 2024-09-18 17:17:23
+ * @LastEditors: penglei 1624952103@qq.com
+ * @LastEditTime: 2024-09-19 18:37:54
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPing.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+#ifndef TEST_PING_VIEW_H
+#define TEST_PING_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_label.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_button.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label_button_ext.h"
+
+//#include "cmsis_os.h"
+#include <iostream>
+namespace OHOS
+{
+        
+    class testPingView
+    {
+
+    public:
+       struct ButtonConfig_ext_t
+        {
+            int x;
+            int y;
+            int w;
+            int h;
+            const char *str;
+            const char *ViewId;
+            const char *ImageSrc;
+
+            //label
+            int label_x;
+            int label_y;
+            uint8_t ALIGN;
+            int  Fontsize;
+        
+        };
+ 
+        struct LabelConfig
+        {
+            int16_t left;
+            int16_t top;
+            int16_t width;
+            int16_t height;
+            int16_t fontSize;      // 字体大小
+            int16_t lineHeigh;     // 行高
+            char *text;      // 文本
+            uint8_t lineBreakMode; // 断行模式。
+        };
+
+     
+        testPingView();
+        virtual ~testPingView();
+        static testPingView *GetInstance(void);
+
+
+        UIScrollView *testPingInitIView(uint8_t);
+        void ClearAll(void);
+        void sethostname(char *data);
+        void setresult(char *data);
+    private:
+        UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &buttonconfig);//, UIView::OnTouchListener *clickListener);
+        UILabel *InitLabel(LabelConfig &labelConfig);
+        bool testPingScrollViewcrollViewinit(uint8_t);
+        UIScrollView *testPingScrollView{nullptr};
+        UILabel *label_hostname{nullptr};
+
+        UILabelButtonExt* labelButton_next = nullptr;
+        UILabel *label_result{nullptr};
+
+        bool initViewStatus{false};
+        UILabel *Title{nullptr};           // 标题
+
+    };
+}
+#endif
\ No newline at end of file
index f23c860..dbb65df 100644 (file)
@@ -1,3 +1,11 @@
+/*\r
+ * @Author: penglei 1624952103@qq.com\r
+ * @Date: 2024-08-23 10:50:37\r
+ * @LastEditors: penglei 1624952103@qq.com\r
+ * @LastEditTime: 2024-09-18 18:29:11\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/producttest/include/testPresenter.h\r
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE\r
+ */\r
 \r
 #ifndef TEST_PRESENTER_H\r
 #define TEST_PRESENTER_H\r
@@ -36,6 +44,7 @@ namespace OHOS
         GSENSON,\r
         BTTEST,\r
         SEChipTest,\r
+        PingTest,\r
         OLDTEST,\r
         DEEPSLEEP,\r
         \r
index 0c69ff9..73ac334 100644 (file)
@@ -28,6 +28,7 @@
 #include "producttest/include/testold.h"\r
 #include "producttest/include/testbt.h"\r
 #include "producttest/include/testSEChipTest.h"\r
+#include "producttest/include/testPing.h"\r
 #ifdef SUPPORT_A5133_SERVICE\r
 #include "producttest/include/testA5133.h"\r
 #endif\r
@@ -94,6 +95,7 @@ namespace OHOS
         bool ChangeoldTESTView(int16_t thisView);\r
         bool ChangeBTTESTView(int16_t thisView);\r
         bool ChangeSEChipTESTView(int16_t thisView);\r
+        bool ChangePingTESTView(int16_t thisView);\r
     #ifdef SUPPORT_A5133_SERVICE\r
         bool ChangeA5133TESTView(int16_t thisView);\r
     #endif\r
@@ -132,6 +134,8 @@ namespace OHOS
         testBTView *test_BT_view{nullptr};\r
 \r
         testSEChipView *test_SEChip_view{nullptr};\r
+        testPingView *test_Ping_view{nullptr};\r
+        \r
     #ifdef SUPPORT_A5133_SERVICE\r
         testA5133View  *test_A5133_view{nullptr};\r
     #endif\r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPing.cpp b/code/sdk/application/wearable/fd230app/nativeui/producttest/src/testPing.cpp
new file mode 100644 (file)
index 0000000..79ba844
--- /dev/null
@@ -0,0 +1,244 @@
+#include "wearable_log.h"
+#include "custom_utils.h"
+#include "producttest/include/testPresenter.h"
+#include "producttest/include/testPing.h" 
+#include "AlarmClockModel.h"
+#include "cmsis_os2.h"
+#include "cat1_server.h"
+#include "cat1_ctl.h"
+#include "cat1_server_hal.h"
+#include "custom_runtime.h"
+#include "producttest/include/testView.h"
+
+#ifdef SUPPORT_TCPIP
+#include "lwip/api_shell.h"
+#endif
+
+namespace OHOS
+{
+
+    static testPingView *g_pSystemAboutTheWatchView{nullptr};
+    static osTimerId_t  g_ping_timer=NULL;
+
+    testPingView::testPingView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchView");
+        g_pSystemAboutTheWatchView = this;
+    }
+
+    testPingView::~testPingView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "testPingView::~testPingView");
+        ClearAll();
+        //g_pSystemAboutTheWatchView = nullptr;
+    }
+
+    testPingView *testPingView::GetInstance()
+    {
+
+        return g_pSystemAboutTheWatchView;
+    }
+
+    void testPingView::ClearAll()
+    {
+        if(testPingScrollView)
+        {
+            testPingScrollView->RemoveAll();
+
+            if (g_ping_timer != NULL) 
+            {
+                osTimerStop(g_ping_timer);
+                osTimerDelete(g_ping_timer);
+                g_ping_timer = NULL;
+            }
+
+            // if(button)
+            // {
+            //     delete button;
+            //     button=nullptr;
+            // }
+            if(labelButton_next)
+            {
+                delete labelButton_next;
+                labelButton_next=nullptr;
+            }
+            if(label_hostname)
+            {
+                delete label_hostname;
+                label_hostname=nullptr;
+            }
+
+            if(label_result)
+            {
+                delete label_result;
+                label_result=nullptr;
+            }
+            if(Title)
+            {
+                delete Title;
+                Title=nullptr;
+            }
+          
+
+
+            delete testPingScrollView;
+            testPingScrollView=nullptr;
+       }
+    }
+
+    UILabelButtonExt *testPingView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig)
+    {
+        UILabelButtonExt *button = new UILabelButtonExt();
+        if (button == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new  fail!");
+            return nullptr;
+        }
+        button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);
+        button->SetViewId(buttonconfig.ViewId);
+        button->SetStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full);
+        //button->SetStyle(STYLE_BORDER_RADIUS,0);
+        button->SetStyleForState(STYLE_BACKGROUND_COLOR, Color::Black().full, UIButton::PRESSED);
+        //button->SetStyleForState(STYLE_BORDER_RADIUS,0, UIButton::PRESSED);
+        button->SetTouchable(true);
+        button->SetStyle(STYLE_BACKGROUND_OPA, 0x80);
+        button->SetText(buttonconfig.str);
+        button->SetAlign(TEXT_ALIGNMENT_LEFT);
+        button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y );
+        button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize);
+        UIView:: OnClickListener *touchListener = static_cast<UIView::OnClickListener *>(testPresenter::GetInstance());
+        button->SetOnClickListener(touchListener);
+
+        // UIView::OnDragListener *drgListener = static_cast<UIView::OnDragListener *>(testPresenter::GetInstance());
+        // button->SetOnDragListener(drgListener);
+
+        // button->SetDraggable(false);
+        return button;
+    }
+
+     UILabel *testPingView::InitLabel(LabelConfig &labelConfig)
+    {
+        UILabel *label = new UILabel();
+        if (label == nullptr)
+        {
+            return nullptr;
+        }
+        label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小
+        label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize);                                       // 字体大小
+        label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh);                                    // 字体行高
+        label->SetText(labelConfig.text);                                                             // 内容
+        label->SetLineBreakMode(labelConfig.lineBreakMode);                                           // 断行模式。
+        label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP);
+        label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize);
+       // label->SetAlign(TEXT_ALIGNMENT_LEFT);
+        return label;
+    }
+
+    void testPingView::sethostname(char *data)
+    {
+        if(label_hostname != NULL)
+            label_hostname->SetText(data);
+    }
+    void testPingView::setresult(char *data)
+    {
+        if(label_result != NULL)
+            label_result->SetText(data);
+    }
+
+    static void msgupdateTimerCallBack(int data)
+    {
+        char hostname[20] = {0};
+        char result[256] = {0};
+        get_ping_hostname(hostname,sizeof(hostname));
+        get_ping_result(result,sizeof(result));
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "result : %s ",result);
+        OHOS::testPingView *pview = OHOS::testPingView::GetInstance();
+        pview->sethostname(hostname);
+        pview->setresult(result);
+    }
+
+    bool testPingView::testPingScrollViewcrollViewinit(uint8_t id)
+    {
+
+        testPingScrollView = new UIScrollView();
+        if (testPingScrollView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::testPingScrollView new fail!");
+            return false;
+        }
+        testPingScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+        testPingScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+        testPingScrollView->SetStyle(STYLE_BORDER_RADIUS, 0);
+        testPingScrollView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
+        testPingScrollView->SetStyle(STYLE_BORDER_COLOR, Color::Yellow().blue);
+
+        LabelConfig Config = {
+            .left = 0,
+            .top = 100,
+            .width = 466,
+            .height = 40,
+            .fontSize = 30,
+            .lineHeigh = 35,
+            .text = "www.****.com",
+            .lineBreakMode = UILabel::LINE_BREAK_MARQUEE,
+        };
+        label_hostname= InitLabel(Config);
+        if (label_hostname == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!");
+            return false;
+        }
+        testPingScrollView->Add(label_hostname);
+
+        Config = {
+            .left = 70,
+            .top = 200,
+            .width = 350,
+            .height = 35,
+            .fontSize = 40,
+            .lineHeigh = 35,
+            .text = "connecting ...",
+            .lineBreakMode = UILabel::LINE_BREAK_WRAP,
+        };
+        label_result= InitLabel(Config);
+        if (label_result == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!");
+            return false;
+        }
+        testPingScrollView->Add(label_result);
+ 
+
+        labelButton_next= testAboutView::GetInstance()->init_button_next(267,278,Test_ViewMapper_t[id].viewid_str_next);
+        testPingScrollView->Add(labelButton_next);
+        
+        Title= testAboutView::GetInstance()->init_title(165,45,"Ping_TEST");
+        testPingScrollView->Add(Title);
+
+        testPingScrollView->SetTouchable(true);
+        testPingScrollView->SetDraggable(true);
+
+        g_ping_timer = osTimerNew((osTimerFunc_t)msgupdateTimerCallBack, osTimerPeriodic, NULL, NULL);
+
+        osStatus_t ret = osTimerStart(g_ping_timer, 1000);
+        if (ret != osOK && g_ping_timer != NULL) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", ret);
+            osTimerDelete(g_ping_timer);
+            g_ping_timer = NULL;
+            return false;
+        }
+
+        return true;
+    }
+
+    UIScrollView *testPingView::testPingInitIView(uint8_t id)
+    {
+        if (!testPingScrollViewcrollViewinit(id))
+        {
+            return nullptr;
+        }
+        return testPingScrollView;
+    }
+
+
+}
\ No newline at end of file
index bf9f6e8..aa1ae38 100644 (file)
@@ -30,6 +30,7 @@ namespace OHOS
         {GSENSON,"gsensonbutton","gsensor","gsensonbutton_next" ,&testView::ChangeGTESTView,true},\r
         {BTTEST,"BTbutton","BT" ,"BTbutton_next",&testView::ChangeBTTESTView,true},\r
         {SEChipTest,"SEChipTestbutton","SEChipTest","SEChipTestbutton_next" ,&testView::ChangeSEChipTESTView,true},\r
+        {PingTest,"PingTestbutton","PingTest","PingTestbutton_next" ,&testView::ChangePingTESTView,true},\r
         {OLDTEST,"oldtestbutton","aging" ,"oldtestexit",&testView::ChangeoldTESTView,true},\r
         {DEEPSLEEP,"deepsleep","DeepSleepCurrent","xxxxxxxxx" ,&testView::ChangeoldTESTView,true},\r
         {shutdown,"shutdown","shutdown", "xxxxxxxxx",&testView::ChangeoldTESTView,true},\r
@@ -587,6 +588,24 @@ namespace OHOS
         }\r
         return true;\r
     }\r
+\r
+    bool testView::ChangePingTESTView(int16_t thisView)\r
+    {\r
+        if (SystemScrollView[thisView] == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeSEChipTESTView");\r
+            test_Ping_view = new testPingView();\r
+            if (test_Ping_view == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView);\r
+                return false;\r
+            }\r
+            SystemScrollView[thisView] = test_Ping_view->testPingInitIView(thisView);\r
+            RootView::GetInstance()->Add(SystemScrollView[thisView]);\r
+        }\r
+        return true;\r
+    }\r
+\r
 #ifdef SUPPORT_A5133_SERVICE\r
     bool testView::ChangeA5133TESTView(int16_t thisView)\r
     {\r
@@ -750,6 +769,12 @@ namespace OHOS
                 test_SEChip_view = nullptr;\r
                 SystemScrollView[hideView]=nullptr;\r
                 break;\r
+            case PingTest:\r
+                RootView::GetInstance()->Remove(SystemScrollView[hideView]);\r
+                delete test_Ping_view;  \r
+                test_Ping_view = nullptr;\r
+                SystemScrollView[hideView]=nullptr;\r
+                break; \r
 #ifdef SUPPORT_A5133_SERVICE\r
             case RF5133:\r
                 RootView::GetInstance()->Remove(SystemScrollView[hideView]);\r
index beea8b8..ecab799 100644 (file)
@@ -43,7 +43,7 @@ namespace OHOS
                 osTimerStop(Gsenson_TEST_timer);
                 osTimerDelete(Gsenson_TEST_timer);
                 Gsenson_TEST_timer = NULL;
-                return ;
+                //return ;
             }
             // if(button)
             // {
index b8ec7c0..8a63baf 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com\r
  * @Date: 2024-06-17 14:31:08\r
  * @LastEditors: penglei 1624952103@qq.com\r
- * @LastEditTime: 2024-09-12 20:31:12\r
+ * @LastEditTime: 2024-09-18 20:10:26\r
  * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c\r
  * @Description: \r
  * \r
@@ -1641,6 +1641,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 sprintf(hostname,"www.%s.com",str);\r
                 PRINT("hostname : %s\n",hostname);\r
                 send_data = OsShellPing(1,hostname);\r
+                free(hostname);\r
                 free(str);\r
 #endif\r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
index ff7bfaf..31e01f6 100644 (file)
@@ -42,6 +42,9 @@ extern "C" {
 u32_t lwip_ifconfig(int argc, const char **argv);
 u32_t OsShellPing(int argc, const char *argv);
 
+void get_ping_hostname(char *databuf,uint8_t len);
+void get_ping_result(char *databuf,uint16_t len);
+
 #ifndef LWIP_TESTBED
 static
 #endif
index b313127..53aae4e 100644 (file)
@@ -87,6 +87,49 @@ struct ifconfig_option {
     unsigned int print_len;
 };
 
+static char result_data[256] = {0};
+static char hostname[20] = {0};
+
+void get_ping_hostname(char *databuf,uint8_t len)
+{
+    memcpy_s(databuf,len,hostname,strlen(hostname));
+}
+
+void get_ping_result(char *databuf,uint16_t len)
+{
+    if (databuf == NULL || len <= 0) 
+    {
+        PRINTK("Invalid input for get_ping_result. len : %d\n",len);
+        return;
+    }
+    size_t resultLen = strlen(result_data);
+    if (resultLen >= len) 
+    {
+        PRINTK("Insufficient buffer size for databuf.\n");
+        len = resultLen + 1;
+    }
+    memcpy(databuf, result_data, resultLen);
+    databuf[resultLen] = '\0';
+    // PRINTK("result_data : %s\n", result_data);
+    // PRINTK("databuf : %s\n", databuf);
+    // memset(result_data,0,sizeof(result_data));
+}
+
+static void get_log(char* str, int arrSize) 
+{
+    if (str == NULL || arrSize <= 0) {
+        PRINTK("Invalid input for get_log.\n");
+        return;
+    }
+    if (arrSize >= sizeof(result_data)) {
+        PRINTK("Input size too large for result_data.\n");
+        arrSize = sizeof(result_data) - 1;
+    }
+    memcpy(result_data, str, arrSize);
+    result_data[arrSize] = '\0';
+    // PRINTK("result_data : %s\n", result_data);
+}
+
 #ifndef LWIP_TESTBED
 LWIP_STATIC
 #endif
@@ -333,22 +376,25 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
     u32_t cnt = parg[1];
     u32_t interval = parg[2];
     u32_t data_len = parg[3];
-
+    char str[128] = {0};
     iecho_len = sizeof(struct icmp_echo_hdr) + data_len;
     sfd = lwip_socket(PF_INET, SOCK_RAW, IPPROTO_ICMP);
     if (sfd < 0) {
         PRINTK("Ping socket\n");
+        get_log("Ping socket",strlen("Ping socket\n"));
         return -1;
     }
     pbuf_resp = pbuf_alloc(PBUF_RAW, IP_HLEN + sizeof(struct icmp_echo_hdr), PBUF_RAM);
     if (pbuf_resp == NULL) {
         PRINTK("Ping: pbuf_resp malloc failed\n");
+        get_log("Ping: pbuf_resp malloc failed\n",strlen("Ping: pbuf_resp malloc failed\n"));
         ret = -1;
         goto FAILURE;
     }
     iecho = (struct icmp_echo_hdr *)mem_malloc(iecho_len);
     if (iecho == NULL) {
         PRINTK("Ping: echo request malloc failed\n");
+        get_log("Ping: echo request malloc failed\n",strlen("Ping: echo request malloc failed\n"));
         ret = -1;
         goto FAILURE;
     }
@@ -380,6 +426,7 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
         ret = sendto(sfd, iecho, iecho_len, 0, (struct sockaddr *)&to, (socklen_t)sizeof(to));
         if (ret < 0) {
             perror("Ping: sending ICMP echo request failed\n");
+            get_log("Ping: sending ICMP echo request failed\n",strlen("Ping: sending ICMP echo request failed\n"));
             goto FAILURE;
         }
 
@@ -406,6 +453,7 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
             ret = recv(sfd, pbuf_resp->payload, pbuf_resp->len, MSG_DONTWAIT);
             if (ret < 0) {
                 perror("Ping: recv echo reply failed\n");
+                get_log("Ping: recv echo reply failed\n",strlen("Ping: recv echo reply failed\n"));
                 goto FAILURE;
             }
 
@@ -416,6 +464,7 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
             if (pbuf_header(pbuf_resp, -ip_hlen)) {
                 /* this failure will never happen, but failure handle is written just to be in safe side */
                 PRINTK("Ping : memory management failure\n");
+                get_log("Ping : memory management failure",strlen("Ping : memory management failure"));
                 goto FAILURE;
             }
             iecho_resp = (struct icmp_echo_hdr *)pbuf_resp->payload;
@@ -423,6 +472,7 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
             if (pbuf_header(pbuf_resp, ip_hlen)) {
                 /* this failure will never happen, but failure handle is written just to be in safe side */
                 PRINTK("ping : memory management failure\n");
+                get_log("ping : memory management failure",strlen("ping : memory management failure"));
                 goto FAILURE;
             }
 
@@ -444,6 +494,7 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
             failed_cnt++;
             i++;
             PRINTK("\nPing: destination unreachable ...");
+            get_log("Ping: destination unreachable ...",strlen("Ping: destination unreachable ..."));
             continue;
         }
         /* capture the end time to calculate round trip time */
@@ -457,8 +508,13 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
                     PRINTK("\n[%u]Reply from %s: ", i, inet_ntop(AF_INET, &to.sin_addr, buf, sizeof(buf)));
                     if (rtt > 0) {
                         PRINTK("time=%ims ", rtt);
+                        memset(str,0,sizeof(str));
+                        sprintf(str,"[%u]Reply from %s: time=%ims ",i, inet_ntop(AF_INET, &to.sin_addr, buf, sizeof(buf)),rtt);
+                        get_log(str,strlen(str));
                     } else {
                         PRINTK("time<1ms ");
+                        sprintf(str,"[%u]Reply from %s: time<1ms ",i, inet_ntop(AF_INET, &to.sin_addr, buf, sizeof(buf)));
+                        get_log(str,strlen(str));
                     }
                     PRINTK("TTL=%u", iphdr_resp->_ttl);
 
@@ -479,30 +535,41 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
                     break;
                 case ICMP_DUR:
                     PRINTK("\nPing: destination host unreachable ...");
+                    get_log("Ping: destination host unreachable ...",strlen("Ping: destination host unreachable ..."));
                     break;
                 case ICMP_SQ:
                     PRINTK("\nPing: source quench ...");
+                    get_log("Ping: source quench ...",strlen("Ping: source quench ..."));
                     break;
                 case ICMP_RD:
                     PRINTK("\nPing: redirect ...");
+                    get_log("Ping: redirect ...",strlen("Ping: redirect ..."));
                     break;
                 case ICMP_TE:
                     PRINTK("\nPing: time exceeded ...");
+                    get_log("Ping: time exceeded ...",strlen("Ping: time exceeded ..."));
                     break;
                 case ICMP_PP:
                     PRINTK("\nPing: parameter problem ...");
+                    get_log("Ping: parameter problem ...",strlen("Ping: parameter problem ..."));
                     break;
                 default:
                     PRINTK("\nPing: unknown error ...");
+                    get_log("Ping: unknown error ...",strlen("Ping: unknown error ..."));
                     break;
             }
             i++;
         }
     }
-
+    
     PRINTK("\n--- %s ping statistics ---\n", inet_ntop(AF_INET, &to.sin_addr, buf, sizeof(buf)));
+    memset(str,0,sizeof(str));
+    sprintf(str,"%s ping statistics ---\n",inet_ntop(AF_INET, &to.sin_addr, buf, sizeof(buf)));
+    get_log(str,strlen(str));
     PRINTK("%u packets transmitted, %u received, %u loss\n", i, succ_cnt, failed_cnt);
-
+    memset(str,0,sizeof(str));
+    sprintf(str,"%u packets transmitted, %u received, %u loss\n", i, succ_cnt, failed_cnt);
+    get_log(str,strlen(str));
 FAILURE:
     ping_kill = 0;
     (void)lwip_close(sfd);
@@ -554,7 +621,8 @@ u32_t OsShellPing(int argc, const char *argv)
     }
     // printf("%s %d\n",__func__,__LINE__);
     printf("%s %d name %s\n",__func__,__LINE__,argv);
-
+    memset(hostname,0,sizeof(hostname));
+    memcpy_s(hostname,20,argv,strlen(argv));
 #if LWIP_DNS
     dst_ipaddr.addr = get_hostip(argv);
     printf("%s %d dst_ip 0x%X\n",__func__,__LINE__,dst_ipaddr.addr);
@@ -562,6 +630,7 @@ u32_t OsShellPing(int argc, const char *argv)
 
     if (dst_ipaddr.addr == IPADDR_NONE || dst_ipaddr.addr == IPADDR_ANY) {
         PRINTK("Invalid dest ipaddr: NONE or ANY\n");
+        get_log("Invalid dest ipaddr: NONE or ANY",strlen("Invalid dest ipaddr: NONE or ANY"));
         return LOS_NOK;
     }