Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
k-sdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈伟灿
k-sdk
Commits
a8988572
Commit
a8988572
authored
Aug 02, 2021
by
chen.weican
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改内容】打印处理
【提交人】陈伟灿
parent
86e4b066
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
46 deletions
+88
-46
common/api/com_api.c
common/api/com_api.c
+2
-3
common/api/kk_log.h
common/api/kk_log.h
+55
-17
common/hal/HAL_OS_linux.c
common/hal/HAL_OS_linux.c
+25
-21
common/hal/kk_hal.h
common/hal/kk_hal.h
+5
-0
common/hal/kk_product.h
common/hal/kk_product.h
+1
-5
No files found.
common/api/com_api.c
View file @
a8988572
...
@@ -81,10 +81,10 @@ static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents)
...
@@ -81,10 +81,10 @@ static void watcher_cb (struct ev_loop *loop ,struct ev_io *w, int revents)
//ERROR_PRINT("nn_recv failed with error code %d, %s \n", nn_errno(), nn_strerror(nn_errno ()));
//ERROR_PRINT("nn_recv failed with error code %d, %s \n", nn_errno(), nn_strerror(nn_errno ()));
return
;
return
;
}
}
//INFO_PRINT("watcher_cb:-------------------------\n");
dat_bak
=
malloc
(
bytes
+
1
);
dat_bak
=
malloc
(
bytes
+
1
);
if
(
dat_bak
!=
NULL
){
if
(
dat_bak
!=
NULL
){
memset
(
dat_bak
,
0x0
,
bytes
);
memset
(
dat_bak
,
0x0
,
bytes
+
1
);
memcpy
(
dat_bak
,
dat
,
bytes
);
memcpy
(
dat_bak
,
dat
,
bytes
);
cJSON_Minify
((
char
*
)
dat_bak
);
cJSON_Minify
((
char
*
)
dat_bak
);
INFO_PRINT
(
"watcher_cb:%s
\n
"
,
(
char
*
)
dat_bak
);
INFO_PRINT
(
"watcher_cb:%s
\n
"
,
(
char
*
)
dat_bak
);
...
@@ -125,7 +125,6 @@ void __loop_init(Bloop_ctrl_t *loop_ctrl, struct ev_loop* loop)
...
@@ -125,7 +125,6 @@ void __loop_init(Bloop_ctrl_t *loop_ctrl, struct ev_loop* loop)
loop_ctrl
->
watcher
.
data
=
loop_ctrl
;
loop_ctrl
->
watcher
.
data
=
loop_ctrl
;
if
(
loop_ctrl
->
type
==
IPC_PLAT2MID
||
loop_ctrl
->
type
==
IPC_APP2MID
){
if
(
loop_ctrl
->
type
==
IPC_PLAT2MID
||
loop_ctrl
->
type
==
IPC_APP2MID
){
printf
(
"[%s][%d]
\n
"
,
__FUNCTION__
,
__LINE__
);
ev_io_init
(
&
(
loop_ctrl
->
watcher
),
watcher_cb
,
loop_ctrl
->
ab
.
s
,
EV_READ
);
ev_io_init
(
&
(
loop_ctrl
->
watcher
),
watcher_cb
,
loop_ctrl
->
ab
.
s
,
EV_READ
);
}
else
{
}
else
{
ev_io_init
(
&
(
loop_ctrl
->
watcher
),
watcher_cb
,
loop_ctrl
->
ba
.
s
,
EV_READ
);
ev_io_init
(
&
(
loop_ctrl
->
watcher
),
watcher_cb
,
loop_ctrl
->
ba
.
s
,
EV_READ
);
...
...
common/api/kk_log.h
View file @
a8988572
#ifndef _LOGDEF_H_
#ifndef _LOGDEF_H_
#define _LOGDEF_H_
#define _LOGDEF_H_
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <memory.h>
#include <syslog.h>
#include <syslog.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/prctl.h>
#include <sys/time.h>
#include <semaphore.h>
#include <errno.h>
#include <assert.h>
#include <net/if.h> // struct ifreq
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <sys/reboot.h>
#include <sys/time.h>
#include <time.h>
#include <signal.h>
static
int
g_enable_printf
=
1
;
#define LOG_STRING(level) ((level == LOG_EMERG) ? "EMERG " : \
(level == LOG_ALERT) ? "ALERT " : \
(level == LOG_CRIT) ? "CRIT " : \
(level == LOG_ERR) ? "ERR " : \
(level == LOG_WARNING) ? "WARNING " : \
(level == LOG_NOTICE) ? "NOTICE " : \
(level == LOG_INFO) ? "INFO " : \
(level == LOG_DEBUG) ? "DEBUG " : "NONE ")
#define KK_LOG(level,fmt,args...) do {\
time_t t; \
t = time(NULL); \
struct tm ptm; \
memset(&ptm, 0, sizeof(ptm)); \
localtime_r(&t, &ptm); \
syslog(level,"%s %4d-%02d-%02d %02d:%02d:%02d [%s:%d]:" fmt ,LOG_STRING(level), \
ptm.tm_year + 1900, ptm.tm_mon + 1, ptm.tm_mday, ptm.tm_hour,ptm.tm_min, ptm.tm_sec,\
__FILE__,__LINE__,##args);\
if(g_enable_printf == 1){\
printf("%s %4d-%02d-%02d %02d:%02d:%02d [%s:%d]:" fmt ,LOG_STRING(level), \
ptm.tm_year + 1900, ptm.tm_mon + 1, ptm.tm_mday, ptm.tm_hour,ptm.tm_min, \
ptm.tm_sec,__FILE__,__LINE__,##args);\
}}while(0)
#define DEBUG_PRINT(info,args...) do { \
#define DEBUG_PRINT(fmt, args...) KK_LOG(LOG_DEBUG, fmt, ##args)
syslog(LOG_DEBUG, "[%s][%d]"info,__FUNCTION__,__LINE__ ,##args); \
#define INFO_PRINT(fmt, args...) KK_LOG(LOG_INFO, fmt, ##args)
printf("\n["__FILE__":%d] "info,__LINE__, ##args); \
#define ERROR_PRINT(fmt, args...) KK_LOG(LOG_ERR, fmt, ##args)
}while(0)
#define WARNING_PRINT(fmt, args...) KK_LOG(LOG_WARNING, fmt, ##args)
#define INFO_PRINT(info,args...) do { \
syslog(LOG_INFO, "[%s][%d]"info,__FUNCTION__,__LINE__ , ##args); \
printf("\n["__FILE__":%d] "info,__LINE__, ##args); \
}while(0)
#define ERROR_PRINT(info,args...) do { \
syslog(LOG_ERR, "[%s][%d]"info,__FUNCTION__,__LINE__ , ##args); \
printf("\n["__FILE__":%d] "info,__LINE__, ##args); \
}while(0)
#define WARNING_PRINT(info,args...) do { \
syslog(LOG_WARNING, "[%s][%d]"info,__FUNCTION__,__LINE__ , ##args); \
printf("\n["__FILE__":%d] "info,__LINE__, ##args); \
}while(0)
#ifdef __cplusplus
}
#endif
#endif
#endif
common/hal/HAL_OS_linux.c
View file @
a8988572
...
@@ -32,10 +32,30 @@
...
@@ -32,10 +32,30 @@
#include "com_api.h"
#include "com_api.h"
char
g_product_type
[
PRODUCT_TYPE_LEN
]
=
{
0
};
char
g_product_type
[
PRODUCT_TYPE_LEN
]
=
{
0
};
char
g_product_code
[
PRODUCT_CODE_LEN
]
=
{
0
};
char
g_product_code
[
PRODUCT_CODE_LEN
]
=
{
0
};
char
g_device_code
[
DEVICE_CODE_LEN
]
=
{
0
};
#define PLATFORM_WAIT_INFINITE (~0)
#define PLATFORM_WAIT_INFINITE (~0)
int
HAL_Execel_cmd
(
char
*
cmd
,
char
*
buf
,
int
buf_len
,
int
*
ret_len
)
{
if
(
cmd
==
NULL
||
buf
==
NULL
||
buf_len
==
0
)
{
printf
(
"arg error
\n
"
);
return
-
1
;
}
memset
(
buf
,
0
,
buf_len
);
FILE
*
fp
=
NULL
;
fp
=
popen
(
cmd
,
"r"
);
while
(
fgets
(
buf
,
buf_len
,
fp
)
!=
NULL
){
printf
(
"%s return %s"
,
cmd
,
buf
);
}
pclose
(
fp
);
*
ret_len
=
strlen
(
buf
);
return
0
;
}
void
*
HAL_Malloc
(
_IN_
uint32_t
size
)
void
*
HAL_Malloc
(
_IN_
uint32_t
size
)
{
{
return
malloc
(
size
);
return
malloc
(
size
);
...
@@ -255,20 +275,6 @@ int HAL_SetProduct_Code(_IN_ char *product_code)
...
@@ -255,20 +275,6 @@ int HAL_SetProduct_Code(_IN_ char *product_code)
}
}
int
HAL_SetDevice_Code
(
_IN_
char
*
device_code
)
{
int
len
=
strlen
(
device_code
);
if
(
len
>
DEVICE_CODE_LEN
)
{
return
-
1
;
}
memset
(
g_device_code
,
0x0
,
DEVICE_CODE_LEN
);
strncpy
(
g_device_code
,
device_code
,
len
);
return
len
;
}
int
HAL_GetProduct_Code
(
_OU_
char
*
product_code
)
int
HAL_GetProduct_Code
(
_OU_
char
*
product_code
)
{
{
strncpy
(
product_code
,
KK_CCU_PRODUCTID
,
strlen
(
KK_CCU_PRODUCTID
));
strncpy
(
product_code
,
KK_CCU_PRODUCTID
,
strlen
(
KK_CCU_PRODUCTID
));
...
@@ -276,12 +282,8 @@ int HAL_GetProduct_Code(_OU_ char *product_code)
...
@@ -276,12 +282,8 @@ int HAL_GetProduct_Code(_OU_ char *product_code)
return
strlen
(
KK_CCU_PRODUCTID
);
return
strlen
(
KK_CCU_PRODUCTID
);
}
}
int
HAL_GetDevice_Code
(
_OU_
char
*
device_code
)
{
strncpy
(
device_code
,
KK_CCU_ID
,
strlen
(
KK_CCU_ID
));
device_code
[
strlen
(
KK_CCU_ID
)]
=
'\0'
;
return
strlen
(
KK_CCU_ID
);
}
int
HAL_GetVersion
(
_OU_
char
*
version
)
int
HAL_GetVersion
(
_OU_
char
*
version
)
{
{
strncpy
(
version
,
KK_CCU_VERSION
,
strlen
(
KK_CCU_VERSION
));
strncpy
(
version
,
KK_CCU_VERSION
,
strlen
(
KK_CCU_VERSION
));
...
@@ -747,6 +749,8 @@ uint32_t HAL_Get_IP(char ip_str[NETWORK_ADDR_LEN], const char *ifname)
...
@@ -747,6 +749,8 @@ uint32_t HAL_Get_IP(char ip_str[NETWORK_ADDR_LEN], const char *ifname)
return
((
struct
sockaddr_in
*
)
&
ifreq
.
ifr_addr
)
->
sin_addr
.
s_addr
;
return
((
struct
sockaddr_in
*
)
&
ifreq
.
ifr_addr
)
->
sin_addr
.
s_addr
;
}
}
#if 0
#if 0
static kv_file_t *kvfile = NULL;
static kv_file_t *kvfile = NULL;
...
...
common/hal/kk_hal.h
View file @
a8988572
...
@@ -37,4 +37,9 @@ void HAL_MutexDestroy(_IN_ void *mutex);
...
@@ -37,4 +37,9 @@ void HAL_MutexDestroy(_IN_ void *mutex);
int
HAL_GetVersion
(
_OU_
char
*
version
);
int
HAL_GetVersion
(
_OU_
char
*
version
);
int
HAL_Get_mac
(
char
*
mac
);
int
HAL_Get_mac
(
char
*
mac
);
int
HAL_Get_SN
(
char
sn
[
SN_ADDR_LEN
]);
int
HAL_Get_SN
(
char
sn
[
SN_ADDR_LEN
]);
int
HAL_Execel_cmd
(
char
*
cmd
,
char
*
buf
,
int
buf_len
,
int
*
ret_len
);
int
HAL_SetProduct_Type
(
_IN_
char
*
product_type
);
int
HAL_SetProduct_Code
(
_IN_
char
*
product_code
);
int
HAL_GetProduct_Code
(
_OU_
char
*
product_code
);
#endif
#endif
common/hal/kk_product.h
View file @
a8988572
...
@@ -37,17 +37,13 @@
...
@@ -37,17 +37,13 @@
#define KK_CCU_RANDOM "0000000000"
#define KK_CCU_RANDOM "0000000000"
#define KK_CCU_NAME "NEW_CCU"
#define KK_CCU_NAME "NEW_CCU"
#define KK_DEVICE_MAP_FILE_PATH "/usr/kk/map/device_%s.json"
#define KK_DEVICE_MAP_FILE_PATH "/usr/kk/map/device_%s.json"
#define GET_CCUID_CMD "/usr/sbin/fw_printenv uuid -n"
enum
{
enum
{
DEVICE_OFFLINE
=
0
,
DEVICE_OFFLINE
=
0
,
DEVICE_ONLINE
,
DEVICE_ONLINE
,
DEVICE_UNKNOW
,
DEVICE_UNKNOW
,
};
};
int
HAL_SetProduct_Type
(
_IN_
char
*
product_type
);
int
HAL_SetProduct_Code
(
_IN_
char
*
product_code
);
int
HAL_SetDevice_Code
(
_IN_
char
*
device_code
);
int
HAL_GetProduct_Code
(
_OU_
char
*
product_code
);
int
HAL_GetDevice_Code
(
_OU_
char
*
device_code
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment