zte's code,first commit

Change-Id: I9a04da59e459a9bc0d67f101f700d9d7dc8d681b
diff --git a/ap/app/zte_log_agent/cp_log.c b/ap/app/zte_log_agent/cp_log.c
new file mode 100644
index 0000000..2187689
--- /dev/null
+++ b/ap/app/zte_log_agent/cp_log.c
@@ -0,0 +1,89 @@
+/**

+ * 

+ * @file      cp_log.c

+ * @brief     

+ *            This file is part of ZCAT.

+ *            zcatÓ¦Óòãlog_agent´¦ÀícplogÉ豸

+ *            

+ * @details   

+ * @author    Tools Team.

+ * @email     

+ * @copyright Copyright (C) 2013 Sanechips Technology Co., Ltd.

+ * @warning   

+ * @date      2019/02/02

+ * @version   1.2

+ * @pre       

+ * @post      

+ *            

+ * @par       

+ * Change History :

+ * ---------------------------------------------------------------------------

+ * date        version  author         description

+ * ---------------------------------------------------------------------------

+ * 2017/07/17  1.0      hou.bing       Create file

+ * 2019/01/24  1.1      jiang.fenglin  1.Ìí¼Óusblog¶ÁÐ´Ëø

+ *                                     2.Ìí¼ÓÏß³ÌÃû³Æ

+ * 2019/02/02  1.2      jiang.fenglin  ÐÞ¸Ä×¢ÊÍ·½Ê½Îªdoxygen

+ * ---------------------------------------------------------------------------

+ * 

+ * 

+ */

+

+#include <string.h>

+#include <time.h>

+#include <pthread.h>

+#include <sys/prctl.h>

+#include "log_agent.h"

+

+#define MAX_PACKET_LEN       (0x10000)

+#define MAX_CP_PACKET_LEN    (MAX_PACKET_LEN * 2)

+

+const char* cplog_dev = "/dev/cplog";     // É豸·¾¶

+static unsigned char g_cp_read_buffer[MAX_CP_PACKET_LEN] = {0}; // Êý¾Ý»º´æ

+pthread_t read_cplog_thread = 0;

+int cplog_fd = -1;

+

+extern void send_log_out(unsigned char* buf, int len);

+

+/**

+ * @brief ¶ÁÈ¡cplogÏ̺߳¯Êý£¬\n

+ *        ´¦Àí´ÓcplogÉ豸ÖеÄlogÊý¾Ý£¬²¢×ª·¢³öÈ¥.

+ * @param[in] args Ï̺߳¯Êý²ÎÊý

+ * @return void

+ * @note

+ * @see 

+ */

+void *read_cplog(void* args)

+{

+    const struct timespec notimer_interval = {0, 20000000};//20ms

+    int read_Len = -1;

+    int nosleep_ret = -1;

+

+    prctl(PR_SET_NAME, "read_cplog");

+    

+    while(1)

+    {   

+        read_Len = read(cplog_fd, g_cp_read_buffer, MAX_CP_PACKET_LEN);

+        

+        if(read_Len > 0)

+        {           

+            //printf("zcat: read_cplog read_Len %d\n", read_Len);

+            send_log_out(g_cp_read_buffer, read_Len);   

+            memset(g_cp_read_buffer, 0, MAX_CP_PACKET_LEN);

+        }

+        else if(read_Len == 0)

+        {

+            nosleep_ret = nanosleep(&notimer_interval, NULL);

+            if(nosleep_ret < 0)

+            {

+                sleep(1);

+            }

+        }

+        else

+        {

+            sleep(1);

+        }

+        

+    }

+}

+