From 6b145817e4a4262b054d2587379c8180842dd445 Mon Sep 17 00:00:00 2001 From: haken kim Date: Thu, 10 Apr 2014 19:32:51 +0900 Subject: [PATCH] ecs : ecs log change to emulator log Change-Id: I9bc28ff56764037a5045e3e6b1b6d55ad5a38332 Signed-off-by: haken kim --- tizen/src/ecs/ecs.c | 156 ++++++++---------------------- tizen/src/ecs/ecs_mon.c | 217 ++---------------------------------------- tizen/src/ecs/ecs_msg.c | 145 +++++++++++----------------- tizen/src/ecs/ecs_tethering.c | 26 ++--- 4 files changed, 115 insertions(+), 429 deletions(-) diff --git a/tizen/src/ecs/ecs.c b/tizen/src/ecs/ecs.c index e721511..163c4cd 100644 --- a/tizen/src/ecs/ecs.c +++ b/tizen/src/ecs/ecs.c @@ -53,6 +53,9 @@ #include "genmsg/ecs.pb-c.h" +#include "debug_ch.h" +MULTI_DEBUG_CHANNEL(qemu, ecs); + #define DEBUG #ifndef min @@ -67,7 +70,6 @@ static ECS_State *current_ecs; static void* keepalive_buf; static int payloadsize; -static int log_fd = -1; static int g_client_id = 1; static pthread_mutex_t mutex_clilist = PTHREAD_MUTEX_INITIALIZER; @@ -84,88 +86,8 @@ int ecs_get_suspend_state(void) return suspend_state; } -static char* get_emulator_ecs_log_path(void) -{ - gchar *emulator_ecs_log_path = NULL; - gchar *tizen_sdk_data = NULL; -#ifndef CONFIG_WIN32 - char emulator_ecs[] = "/emulator/vms/"; - char ecs_prop[] = "/logs/ecs.log"; -#else - char emulator_ecs[] = "\\emulator\\vms\\"; - char ecs_prop[] = "\\logs\\ecs.log"; -#endif - - char* emul_name = get_emul_vm_name(); - - tizen_sdk_data = get_tizen_sdk_data_path(); - if (!tizen_sdk_data) { - LOG("failed to get tizen-sdk-data path.\n"); - return NULL; - } - - emulator_ecs_log_path = - g_malloc(strlen(tizen_sdk_data) + sizeof(emulator_ecs) + strlen(emul_name) + sizeof(ecs_prop) + 1); - if (!emulator_ecs_log_path) { - LOG("failed to allocate memory.\n"); - return NULL; - } - - g_snprintf(emulator_ecs_log_path, strlen(tizen_sdk_data) + sizeof(emulator_ecs) + strlen(emul_name) + sizeof(ecs_prop), - "%s%s%s%s", tizen_sdk_data, emulator_ecs, emul_name, ecs_prop); - - g_free(tizen_sdk_data); - - LOG("ecs log path: %s\n", emulator_ecs_log_path); - return emulator_ecs_log_path; -} - -static inline void start_logging(void) { - char* path = get_emulator_ecs_log_path(); - if (!path) - return; - -#ifdef _WIN32 - FILE* fnul; - FILE* flog; - - fnul = fopen("NUL", "rt"); - if (fnul != NULL) - stdin[0] = fnul[0]; - - flog = fopen(path, "wt+"); - if (flog == NULL) - flog = fnul; - - setvbuf(flog, NULL, _IONBF, 0); - - stdout[0] = flog[0]; - stderr[0] = flog[0]; -#else - log_fd = creat(path, 0640); - if (log_fd < 0) { - log_fd = open("/dev/null", O_WRONLY); - } - if (log_fd < 0) { - return; - } - dup2(log_fd, 1); - dup2(log_fd, 2); -#endif -} - -static inline void stop_logging(void) { - int ret = -1; - if (log_fd >= 0) { - ret = close(log_fd); - if (ret != 0) { - LOG("failed to close log fd."); - } - } -} - int ecs_write(int fd, const uint8_t *buf, int len) { - LOG("write buflen : %d, buf : %s", len, (char*)buf); + TRACE("write buflen : %d, buf : %s", len, (char*)buf); if (fd < 0) { return -1; } @@ -180,7 +102,7 @@ void ecs_client_close(ECS_Client* clii) { pthread_mutex_lock(&mutex_clilist); if (clii->client_fd > 0) { - LOG("ecs client closed with fd: %d", clii->client_fd); + INFO("ecs client closed with fd: %d", clii->client_fd); closesocket(clii->client_fd); #ifndef CONFIG_LINUX FD_CLR(clii->client_fd, &clii->cs->reads); @@ -197,7 +119,7 @@ void ecs_client_close(ECS_Client* clii) { } bool send_to_all_client(const char* data, const int len) { - LOG("data len: %d, data: %s", len, data); + TRACE("data len: %d, data: %s", len, data); pthread_mutex_lock(&mutex_clilist); ECS_Client *clii; @@ -267,7 +189,7 @@ static Monitor *monitor_create(void) { mon = g_malloc0(sizeof(*mon)); if (NULL == mon) { - LOG("monitor allocation failed."); + ERR("monitor allocation failed."); return NULL; } @@ -276,13 +198,13 @@ static Monitor *monitor_create(void) { static void ecs_close(ECS_State *cs) { ECS_Client *clii; - LOG("### Good bye! ECS ###"); + INFO("### Good bye! ECS ###"); if (cs == NULL) return; if (0 <= cs->listen_fd) { - LOG("close listen_fd: %d", cs->listen_fd); + INFO("close listen_fd: %d", cs->listen_fd); closesocket(cs->listen_fd); cs->listen_fd = -1; } @@ -309,8 +231,6 @@ static void ecs_close(ECS_State *cs) { g_free(cs); cs = NULL; current_ecs = NULL; - - stop_logging(); } #ifndef _WIN32 @@ -359,27 +279,27 @@ static void ecs_read(ECS_Client *cli) { if (cli == NULL) { - LOG("client is null."); + ERR("client is null."); return; } #ifndef __WIN32 if (ioctl(cli->client_fd, FIONREAD, &to_read_bytes) < 0) { - LOG("ioctl failed"); + ERR("ioctl failed"); return; } #else unsigned long to_read_bytes_long = 0; if (ioctlsocket(cli->client_fd, FIONREAD, &to_read_bytes_long) < 0) { - LOG("ioctl failed"); + ERR("ioctl failed"); return; } to_read_bytes = (int)to_read_bytes_long; #endif if (to_read_bytes == 0) { - LOG("ioctl FIONREAD: 0\n"); + ERR("ioctl FIONREAD: 0\n"); goto fail; } @@ -396,7 +316,7 @@ static void ecs_read(ECS_Client *cli) { if (read < 4) { - LOG("insufficient header size"); + ERR("insufficient header size"); goto fail; } @@ -404,7 +324,7 @@ static void ecs_read(ECS_Client *cli) { cli->sbuf._netlen = payloadsize; - LOG("payload size: %ld\n", payloadsize); + TRACE("payload size: %ld\n", payloadsize); to_read_bytes -= 4; } @@ -443,7 +363,7 @@ static void epoll_cli_add(ECS_State *cs, int fd) { events.data.fd = fd; if (epoll_ctl(cs->epoll_fd, EPOLL_CTL_ADD, fd, &events) < 0) { - LOG("Epoll control fails.in epoll_cli_add."); + ERR("Epoll control fails.in epoll_cli_add."); } } #endif @@ -474,7 +394,7 @@ static int ecs_add_client(ECS_State *cs, int fd) { ECS_Client *clii = g_malloc0(sizeof(ECS_Client)); if (NULL == clii) { - LOG("ECS_Client allocation failed."); + ERR("ECS_Client allocation failed."); return -1; } @@ -498,7 +418,7 @@ static int ecs_add_client(ECS_State *cs, int fd) { QTAILQ_INSERT_TAIL(&clients, clii, next); - LOG("Add an ecs client. fd: %d", fd); + INFO("Add an ecs client. fd: %d", fd); pthread_mutex_unlock(&mutex_clilist); @@ -535,7 +455,7 @@ static void ecs_accept(ECS_State *cs) { } } if (0 > ecs_add_client(cs, fd)) { - LOG("failed to add client."); + ERR("failed to add client."); } } @@ -581,7 +501,7 @@ static void make_keep_alive_msg(void) { keepalive_buf = g_malloc(len_pack + 4); if (!keepalive_buf) { - LOG("keep alive message creation is failed."); + ERR("keep alive message creation is failed."); return; } @@ -602,17 +522,17 @@ static void alive_checker(void *opaque) { QTAILQ_FOREACH(clii, &clients, next) { if (1 == clii->keep_alive) { - LOG("get client fd %d - keep alive fail", clii->client_fd); + INFO("get client fd %d - keep alive fail", clii->client_fd); ecs_client_close(clii); continue; } - LOG("set client fd %d - keep alive 1", clii->client_fd); + TRACE("set client fd %d - keep alive 1", clii->client_fd); clii->keep_alive = 1; send_keep_alive_msg(clii); } if (current_ecs == NULL) { - LOG("alive checking is failed because current ecs is null."); + ERR("alive checking is failed because current ecs is null."); return; } @@ -632,7 +552,7 @@ static int socket_initialize(ECS_State *cs, QemuOpts *opts) { return -1; } - LOG("Listen fd is %d", fd); + INFO("Listen fd is %d", fd); qemu_set_nonblock(fd); @@ -692,7 +612,7 @@ static int ecs_loop(ECS_State *cs) timeout.tv_usec = 0; if (select(0, &temps, 0, 0, &timeout) < 0) { - LOG("select error."); + ERR("select error."); return -1; } @@ -724,7 +644,7 @@ static int ecs_loop(ECS_State *cs) timeout.tv_usec = 0; if ((res = select(MAX_FD_NUM + 1, &temps, NULL, NULL, &timeout)) < 0) { - LOG("select failed.."); + ERR("select failed.."); return -1; } @@ -752,8 +672,8 @@ static void* ecs_initialize(void* args) { Monitor* mon = NULL; char host_port[16]; int port = 0; - start_logging(); - LOG("ecs starts initializing."); + + INFO("ecs starts initializing."); opts = qemu_opts_create(qemu_find_opts(ECS_OPTS_NAME), ECS_OPTS_NAME, 1, &local_err); if (error_is_set(&local_err)) { @@ -766,24 +686,24 @@ static void* ecs_initialize(void* args) { cs = g_malloc0(sizeof(ECS_State)); if (NULL == cs) { - LOG("ECS_State allocation failed."); + ERR("ECS_State allocation failed."); return NULL; } port = get_emul_ecs_port(); - LOG("ecs port: %d", port); + INFO("ecs port: %d", port); sprintf(host_port, "%d", port); qemu_opt_set(opts, "port", host_port); ret = socket_initialize(cs, opts); if (ret < 0) { - LOG("Socket initialization is failed."); + ERR("Socket initialization is failed."); ecs_close(cs); return NULL; } mon = monitor_create(); if (NULL == mon) { - LOG("monitor initialization failed."); + ERR("monitor initialization failed."); ecs_close(cs); return NULL; } @@ -792,7 +712,7 @@ static void* ecs_initialize(void* args) { current_ecs = cs; cs->ecs_running = 1; - LOG("ecs_loop entered."); + TRACE("ecs_loop entered."); while (cs->ecs_running) { ret = ecs_loop(cs); if (0 > ret) { @@ -800,13 +720,13 @@ static void* ecs_initialize(void* args) { break; } } - LOG("ecs_loop exited."); + TRACE("ecs_loop exited."); return NULL; } int stop_ecs(void) { - LOG("ecs is closing."); + INFO("ecs is closing."); if (NULL != current_ecs) { current_ecs->ecs_running = 0; ecs_close(current_ecs); @@ -821,7 +741,7 @@ int start_ecs(void) { pthread_t thread_id; if (0 != pthread_create(&thread_id, NULL, ecs_initialize, NULL)) { - LOG("pthread creation failed."); + ERR("pthread creation failed."); return -1; } return 0; @@ -883,7 +803,7 @@ bool handle_protobuf_msg(ECS_Client* cli, char* data, int len) QTAILQ_INSERT_TAIL(&clients, cli, next); } else { - LOG("unsupported category is found: %s", msg->category); + ERR("unsupported category is found: %s", msg->category); pthread_mutex_unlock(&mutex_clilist); goto fail; } @@ -919,7 +839,7 @@ bool handle_protobuf_msg(ECS_Client* cli, char* data, int len) ecs__master__free_unpacked(master, NULL); return true; fail: - LOG("invalid message type"); + ERR("invalid message type : %d", master->type); ecs__master__free_unpacked(master, NULL); return false; } diff --git a/tizen/src/ecs/ecs_mon.c b/tizen/src/ecs/ecs_mon.c index 1979453..3f93536 100644 --- a/tizen/src/ecs/ecs_mon.c +++ b/tizen/src/ecs/ecs_mon.c @@ -43,6 +43,9 @@ #include "hw/maru_virtio_sensor.h" #include "hw/maru_virtio_nfc.h" +#include "debug_ch.h" +MULTI_DEBUG_CHANNEL(qemu, ecs); + typedef struct mon_fd_t mon_fd_t; struct mon_fd_t { char *name; @@ -77,7 +80,7 @@ void send_to_client(int fd, const char* data, const int len) for (;;) { c = *data++; if (outbuf_index >= OUT_BUF_SIZE - 1) { - LOG("string is too long: overflow buffer."); + INFO("string is too long: overflow buffer."); return; } #ifndef _WIN32 @@ -101,7 +104,7 @@ bool send_monitor_ntf(const char* data, int size) ECS__Master master = ECS__MASTER__INIT; ECS__MonitorNtf ntf = ECS__MONITOR_NTF__INIT; - LOG("data size : %d, data : %s", size, data); + TRACE("data size : %d, data : %s", size, data); ntf.command = (char*) g_malloc(size + 1); memcpy(ntf.command, data, size); @@ -181,7 +184,7 @@ static void ecs_protocol_emitter(ECS_Client *clii, const char* type, QDict *qmp; QObject *obj; - LOG("ecs_protocol_emitter called."); + TRACE("ecs_protocol_emitter called."); //trace_monitor_protocol_emitter(clii->cs->mon); if (!monitor_has_error(clii->cs->mon)) { @@ -569,216 +572,10 @@ out: QDECREF(input); QDECREF(args); } -#if 0 -static int check_key(QObject *input_obj, const char *key) { - const QDictEntry *ent; - QDict *input_dict; - - if (qobject_type(input_obj) != QTYPE_QDICT) { - qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "object"); - return -1; - } - - input_dict = qobject_to_qdict(input_obj); - - for (ent = qdict_first(input_dict); ent; - ent = qdict_next(input_dict, ent)) { - const char *arg_name = qdict_entry_key(ent); - if (!strcmp(arg_name, key)) { - return 1; - } - } - - return 0; -} - -static QObject* get_data_object(QObject *input_obj) { - const QDictEntry *ent; - QDict *input_dict; - - if (qobject_type(input_obj) != QTYPE_QDICT) { - qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "object"); - return NULL; - } - - input_dict = qobject_to_qdict(input_obj); - - for (ent = qdict_first(input_dict); ent; - ent = qdict_next(input_dict, ent)) { - const char *arg_name = qdict_entry_key(ent); - QObject *arg_obj = qdict_entry_value(ent); - if (!strcmp(arg_name, COMMANDS_DATA)) { - return arg_obj; - } - } - - return NULL; -} - -static int ijcount = 0; - -static bool injector_command_proc(ECS_Client *clii, QObject *obj) { - QDict* header = qdict_get_qdict(qobject_to_qdict(obj), "header"); - - char cmd[10]; - memset(cmd, 0, 10); - strcpy(cmd, qdict_get_str(header, "cat")); - type_length length = (type_length) qdict_get_int(header, "length"); - type_group group = (type_action) (qdict_get_int(header, "group") & 0xff); - type_action action = (type_group) (qdict_get_int(header, "action") & 0xff); - - // get data - const char* data = qdict_get_str(qobject_to_qdict(obj), COMMANDS_DATA); - LOG(">> count= %d", ++ijcount); - LOG(">> print len = %zu, data\" %s\"", strlen(data), data); - LOG(">> header = cmd = %s, length = %d, action=%d, group=%d", cmd, length, - action, group); - - int datalen = strlen(data); - int sndlen = datalen + 14; - char* sndbuf = (char*) malloc(sndlen + 1); - if (!sndbuf) { - return false; - } - - memset(sndbuf, 0, sndlen + 1); - - // set data - memcpy(sndbuf, cmd, 10); - memcpy(sndbuf + 10, &length, 2); - memcpy(sndbuf + 12, &group, 1); - memcpy(sndbuf + 13, &action, 1); - memcpy(sndbuf + 14, data, datalen); - send_to_evdi(route_ij, sndbuf, sndlen); - - free(sndbuf); - - return true; -} - -static bool device_command_proc(ECS_Client *clii, QObject *obj) { - QDict* header = qdict_get_qdict(qobject_to_qdict(obj), "header"); - - char cmd[10]; - memset(cmd, 0, 10); - strcpy(cmd, qdict_get_str(header, "cat")); - type_length length = (type_length) qdict_get_int(header, "length"); - type_group group = (type_action) (qdict_get_int(header, "group") & 0xff); - type_action action = (type_group) (qdict_get_int(header, "action") & 0xff); - - // get data - const char* data = qdict_get_str(qobject_to_qdict(obj), COMMANDS_DATA); - LOG(">> count= %d", ++ijcount); - LOG(">> print len = %zu, data\" %s\"", strlen(data), data); - LOG(">> header = cmd = %s, length = %d, action=%d, group=%d", cmd, length, - action, group); - - if (!strncmp(cmd, MSG_TYPE_SENSOR, 6)) { - if (group == MSG_GROUP_STATUS) { - if (action ==MSG_ACTION_ACCEL) { - get_sensor_accel(); - } else if (action == MSG_ACTION_GYRO) { - get_sensor_gyro(); - } else if (action == MSG_ACTION_MAG) { - get_sensor_mag(); - } else if (action == MSG_ACTION_LIGHT) { - get_sensor_light(); - } else if (action == MSG_ACTION_PROXI) { - get_sensor_proxi(); - } - } else { - set_sensor_data(length, data); - } - } - /* - else if (!strncmp(cmd, MSG_TYPE_NFC, 3)) { - if (group == MSG_GROUP_STATUS) { - send_to_nfc(request_nfc_get, data, length); - } - else - { - send_to_nfc(request_nfc_set, data, length); - } - } - */ - - return true; -} -void handle_ecs_command(JSONMessageParser *parser, QList *tokens, - void *opaque) { - const char *type_name; - int def_target = 0; -// int def_data = 0; - QObject *obj; - ECS_Client *clii = opaque; - - if (NULL == clii) { - LOG("ClientInfo is null."); - return; - } - -#ifdef DEBUG - LOG("Handle ecs command."); -#endif - - obj = json_parser_parse(tokens, NULL); - if (!obj) { - qerror_report(QERR_JSON_PARSING); - ecs_protocol_emitter(clii, NULL, NULL); - return; - } - - def_target = check_key(obj, COMMANDS_TYPE); -#ifdef DEBUG - LOG("check_key(COMMAND_TYPE): %d", def_target); -#endif - if (0 > def_target) { - LOG("def_target failed."); - return; - } else if (0 == def_target) { -#ifdef DEBUG - LOG("call handle_qmp_command"); -#endif - //handle_qmp_command(clii, NULL, obj); - return; - } - - type_name = qdict_get_str(qobject_to_qdict(obj), COMMANDS_TYPE); - - /* - def_data = check_key(obj, COMMANDS_DATA); - if (0 > def_data) { - LOG("json format error: data."); - return; - } else if (0 == def_data) { - LOG("data key is not found."); - return; - } - */ - - if (!strcmp(type_name, TYPE_DATA_SELF)) { - LOG("set client fd %d keep alive 0", clii->client_fd); - clii->keep_alive = 0; - return; - } else if (!strcmp(type_name, COMMAND_TYPE_INJECTOR)) { - injector_command_proc(clii, obj); - } else if (!strcmp(type_name, COMMAND_TYPE_CONTROL)) { - //control_command_proc(clii, obj); - } else if (!strcmp(type_name, COMMAND_TYPE_MONITOR)) { - // handle_qmp_command(clii, type_name, get_data_object(obj)); - } else if (!strcmp(type_name, COMMAND_TYPE_DEVICE)) { - device_command_proc(clii, obj); - } else if (!strcmp(type_name, ECS_MSG_STARTINFO_REQ)) { - //ecs_startinfo_req(clii); - } else { - LOG("handler not found"); - } -} -#endif bool msgproc_monitor_req(ECS_Client *ccli, ECS__MonitorReq* msg) { - LOG(">> monitor req: data = %s", msg->command); + TRACE(">> monitor req: data = %s", msg->command); ecs_json_message_parser_feed(&(ccli->parser), (const char *) msg->command, strlen(msg->command)); return true; } diff --git a/tizen/src/ecs/ecs_msg.c b/tizen/src/ecs/ecs_msg.c index 9386bf7..d0c09f0 100644 --- a/tizen/src/ecs/ecs_msg.c +++ b/tizen/src/ecs/ecs_msg.c @@ -70,6 +70,10 @@ #include "skin/maruskin_server.h" #include "emulator.h" +#include "debug_ch.h" +MULTI_DEBUG_CHANNEL(qemu, ecs); + + #define MAX_BUF_SIZE 255 // utility functions @@ -82,7 +86,7 @@ static void* build_master(ECS__Master* master, int* payloadsize) { int len_pack = ecs__master__get_packed_size(master); *payloadsize = len_pack + 4; - LOG("pack size=%d", len_pack); + TRACE("pack size=%d", len_pack); void* buf = g_malloc(len_pack + 4); if (!buf) return NULL; @@ -101,7 +105,7 @@ static bool send_single_msg(ECS__Master* master, ECS_Client *clii) void* buf = build_master(master, &payloadsize); if (!buf) { - LOG("invalid buf"); + ERR("invalid buf"); return false; } @@ -120,7 +124,7 @@ bool send_to_ecp(ECS__Master* master) void* buf = build_master(master, &payloadsize); if (!buf) { - LOG("invalid buf"); + ERR("invalid buf"); return false; } @@ -140,7 +144,7 @@ static bool send_to_single_client(ECS__Master* master, ECS_Client *ccli) void* buf = build_master(master, &payloadsize); if (!buf) { - LOG("invalid buf"); + ERR("invalid buf"); return false; } @@ -196,7 +200,7 @@ static void msgproc_injector_ans(ECS_Client* ccli, const char* category, bool su ECS__Master master = ECS__MASTER__INIT; ECS__InjectorAns ans = ECS__INJECTOR_ANS__INIT; - LOG("injector ans - category : %s, succed : %d", category, succeed); + TRACE("injector ans - category : %s, succed : %d", category, succeed); catlen = strlen(category); ans.category = (char*) g_malloc0(catlen + 1); @@ -221,7 +225,7 @@ static void msgproc_device_ans(ECS_Client* ccli, const char* category, bool succ ECS__Master master = ECS__MASTER__INIT; ECS__DeviceAns ans = ECS__DEVICE_ANS__INIT; - LOG("device ans - category : %s, succed : %d", category, succeed); + TRACE("device ans - category : %s, succed : %d", category, succeed); catlen = strlen(category); ans.category = (char*) g_malloc0(catlen + 1); @@ -258,17 +262,17 @@ bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg) } //LOG(">> count= %d", ++ijcount); - LOG(">> header = cmd = %s, length = %d, action=%d, group=%d", cmd, length, + TRACE(">> header = cmd = %s, length = %d, action=%d, group=%d", cmd, length, action, group); /*SD CARD msg process*/ if (!strncmp(cmd, MSG_TYPE_SDCARD, strlen(MSG_TYPE_SDCARD))) { if (msg->has_data) { - LOG("msg(%zu) : %s", msg->data.len, msg->data.data); + TRACE("msg(%zu) : %s", msg->data.len, msg->data.data); handle_sdcard((char*) msg->data.data, msg->data.len); } else { - LOG("has no msg"); + ERR("has no msg"); } } else if (!strncmp(cmd, MSG_TYPE_SENSOR, sizeof(MSG_TYPE_SENSOR))) { @@ -281,7 +285,7 @@ bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg) } else { goto injector_send; } - LOG("status : %s", data); + TRACE("status : %s", data); send_status_injector_ntf(MSG_TYPE_SENSOR, 6, action, data); ret = true; goto injector_req_success; @@ -314,7 +318,7 @@ injector_send: { const char* data = (const char*)msg->data.data; memcpy(sndbuf + 14, data, datalen); - LOG(">> print len = %zd, data\" %s\"", strlen(data), data); + TRACE(">> print len = %zd, data\" %s\"", strlen(data), data); } } @@ -351,42 +355,7 @@ void ecs_suspend_lock_state(int state) msgproc_injector_req(NULL, &msg); } -#if 0 -void msgproc_checkversion_req(ECS_Client* ccli, ECS__CheckVersionReq* msg) -{ - int datalen = 0; - if (msg->has_data) - { - datalen = msg->data.len; - if (msg->data.data && msg->data.len > 0) - { - const char* data = (const char*)msg->data.data; - memcpy(sndbuf + 14, data, datalen); - LOG(">> print len = %zd, data\" %s\"", strlen(data), data); - } - } -} - -void send_ecs_version_check(ECS_Client *ccli) -{ - int len_pack = 0; - int payloadsize = 0; - const char* ecs_version = ECS_VERSION; - - ECS__Master master = ECS__MASTER__INIT; - ECS__CheckVersionReq req = ECS__CHECK_VERSION_REQ__INIT; - - req.version_str = (char*) g_malloc(10); - - strncpy(req.version_str, ecs_version, strlen(ecs_version)); - LOG("ecs version: %s", req.version_str); - master.type = ECS__MASTER__TYPE__CHECKVERSION_REQ; - master.checkversion_req = &req; - - send_to_single_client(master, ccli); -} -#endif void msgproc_keepalive_ans (ECS_Client* ccli, ECS__KeepAliveAns* msg) { ccli->keep_alive = 0; @@ -436,7 +405,7 @@ void send_target_image_information(ECS_Client* ccli) { ans.data.len = length; memcpy(ans.data.data, tizen_target_img_path, length); - LOG("data = %s, length = %hu", tizen_target_img_path, length); + TRACE("data = %s, length = %hu", tizen_target_img_path, length); } master.type = ECS__MASTER__TYPE__DEVICE_ANS; @@ -470,7 +439,7 @@ bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg) memcpy(data, msg->data.data, msg->data.len); } - LOG(">> header = cmd = %s, length = %d, action=%d, group=%d", cmd, length, + TRACE(">> header = cmd = %s, length = %d, action=%d, group=%d", cmd, length, action, group); if (!strncmp(cmd, MSG_TYPE_SENSOR, 6)) { @@ -490,27 +459,27 @@ bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg) if (data != NULL) { set_injector_data(data); } else { - LOG("sensor set data is null"); + ERR("sensor set data is null"); } } msgproc_device_ans(ccli, cmd, true); } else if (!strncmp(cmd, "Network", 7)) { if (data != NULL) { - LOG(">>> Network msg: '%s'", data); + TRACE(">>> Network msg: '%s'", data); if(net_slirp_redir(data) < 0) { - LOG( "redirect [%s] fail", data); + ERR( "redirect [%s] fail", data); } else { - LOG("redirect [%s] success", data); + TRACE("redirect [%s] success", data); } } else { - LOG("Network redirection data is null."); + ERR("Network redirection data is null."); } } else if (!strncmp(cmd, "HKeyboard", 8)) { if (group == MSG_GROUP_STATUS) { send_host_keyboard_ntf(mloop_evcmd_get_hostkbd_status()); } else { if (data == NULL) { - LOG("HKeyboard data is NULL"); + ERR("HKeyboard data is NULL"); return false; } @@ -531,11 +500,11 @@ bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg) #endif if (data == NULL) { - LOG("gesture data is NULL"); + ERR("gesture data is NULL"); return false; } - LOG("%s\n", data); + TRACE("%s\n", data); char token[] = "#"; @@ -564,7 +533,7 @@ bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg) } } else if (!strncmp(cmd, "info", 4)) { // check to emulator target image path - LOG("receive info message %s", tizen_target_img_path); + TRACE("receive info message %s", tizen_target_img_path); send_target_image_information(ccli); } @@ -580,7 +549,7 @@ bool msgproc_nfc_req(ECS_Client* ccli, ECS__NfcReq* msg) int datalen = msg->data.len; void* data = (void*)g_malloc(datalen); if(!data) { - LOG("g_malloc failed!"); + ERR("g_malloc failed!"); return false; } @@ -589,7 +558,7 @@ bool msgproc_nfc_req(ECS_Client* ccli, ECS__NfcReq* msg) if (msg->has_data && msg->data.len > 0) { - LOG("recv from nfc injector: "); + TRACE("recv from nfc injector: %s, %z", msg->has_data, msg->data.len); print_binary(data, datalen); } @@ -616,7 +585,7 @@ bool ntf_to_injector(const char* data, const int len) { const char* ijdata = (data + catsize + 2 + 1 + 1); const char *encoded_ijdata = ""; - LOG("<< header cat = %s, length = %d, action=%d, group=%d", cat, length, + TRACE("<< header cat = %s, length = %d, action=%d, group=%d", cat, length, action, group); QDict* obj_header = qdict_new(); @@ -648,7 +617,7 @@ bool ntf_to_injector(const char* data, const int len) { qstring_append_chr(json, '\n'); const char* snddata = qstring_get_str(json); - LOG("<< json str = %s", snddata); + TRACE("<< json str = %s", snddata); send_to_all_client(snddata, strlen(snddata)); @@ -697,7 +666,7 @@ bool send_injector_ntf(const char* data, const int len) const char* ijdata = (data + catsize + 2 + 1 + 1); - LOG("<< header cat = %s, length = %d, action=%d, group=%d", cat, length,action, group); + TRACE("<< header cat = %s, length = %d, action=%d, group=%d", cat, length,action, group); ECS__Master master = ECS__MASTER__INIT; ECS__InjectorNtf ntf = ECS__INJECTOR_NTF__INIT; @@ -750,7 +719,7 @@ bool send_device_ntf(const char* data, const int len) const char* ijdata = (data + catsize + 2 + 1 + 1); - LOG("<< header cat = %s, length = %d, action=%d, group=%d", cat, length,action, group); + TRACE("<< header cat = %s, length = %d, action=%d, group=%d", cat, length,action, group); ECS__Master master = ECS__MASTER__INIT; ECS__DeviceNtf ntf = ECS__DEVICE_NTF__INIT; @@ -771,7 +740,7 @@ bool send_device_ntf(const char* data, const int len) ntf.data.len = length; memcpy(ntf.data.data, ijdata, length); - LOG("data = %s, length = %hu", ijdata, length); + TRACE("data = %s, length = %hu", ijdata, length); } master.type = ECS__MASTER__TYPE__DEVICE_NTF; @@ -798,7 +767,7 @@ bool send_nfc_ntf(struct nfc_msg_info* msg) memset(cat, 0, catsize + 1); print_binary((char*)msg->buf, msg->use); - LOG("id: %02x, type: %02x, use: %d", msg->client_id, msg->client_type, msg->use); + TRACE("id: %02x, type: %02x, use: %d", msg->client_id, msg->client_type, msg->use); clii = find_client(msg->client_id, msg->client_type); if (clii) { if(clii->client_type == TYPE_SIMUL_NFC) { @@ -806,12 +775,12 @@ bool send_nfc_ntf(struct nfc_msg_info* msg) } else if (clii->client_type == TYPE_ECP) { strncpy(cat, MSG_TYPE_SIMUL_NFC, 9); }else { - LOG("cannot find type!"); + ERR("cannot find type! : %d", clii->client_type); } - LOG("header category = %s", cat); + TRACE("header category = %s", cat); } else { - LOG("cannot find client!"); + ERR("cannot find client!"); } ECS__Master master = ECS__MASTER__INIT; @@ -874,7 +843,7 @@ static void handle_sdcard(char* dataBuf, size_t dataLen) } g_strlcat(sdcard_img_path, sdcard_img_name, sizeof(sdcard_img_path)); - LOG("sdcard path: [%s]\n", sdcard_img_path); + TRACE("sdcard path: [%s]\n", sdcard_img_path); //mloop_evcmd_usbdisk(sdcard_img_path); mloop_evcmd_sdcard(sdcard_img_path); @@ -888,16 +857,16 @@ static void handle_sdcard(char* dataBuf, size_t dataLen) g_free(sdcard_path); } else { - LOG("failed to get sdcard path!!\n"); + ERR("failed to get sdcard path!!\n"); } } else if(ret == '2'){ - LOG("sdcard status 2 bypass" ); + TRACE("sdcard status 2 bypass" ); }else { - LOG("!!! unknown command : %c\n", ret); + ERR("!!! unknown command : %c\n", ret); } }else{ - LOG("!!! unknown data : %c\n", ret); + ERR("!!! unknown data : %c\n", ret); } } @@ -912,18 +881,18 @@ static char* get_emulator_sdcard_path(void) char emulator_sdcard[] = "\\emulator\\sdcard\\"; #endif - LOG("emulator_sdcard: %s, %zu\n", emulator_sdcard, sizeof(emulator_sdcard)); + TRACE("emulator_sdcard: %s, %zu\n", emulator_sdcard, sizeof(emulator_sdcard)); tizen_sdk_data = get_tizen_sdk_data_path(); if (!tizen_sdk_data) { - LOG("failed to get tizen-sdk-data path.\n"); + ERR("failed to get tizen-sdk-data path.\n"); return NULL; } emulator_sdcard_path = g_malloc(strlen(tizen_sdk_data) + sizeof(emulator_sdcard) + 1); if (!emulator_sdcard_path) { - LOG("failed to allocate memory.\n"); + ERR("failed to allocate memory.\n"); return NULL; } @@ -932,7 +901,7 @@ static char* get_emulator_sdcard_path(void) g_free(tizen_sdk_data); - LOG("sdcard path: %s\n", emulator_sdcard_path); + TRACE("sdcard path: %s\n", emulator_sdcard_path); return emulator_sdcard_path; } @@ -954,30 +923,30 @@ char *get_tizen_sdk_data_path(void) FILE *sdk_info_fp = NULL; int sdk_info_path_len = 0; - LOG("%s\n", __func__); + TRACE("%s\n", __func__); emul_bin_path = get_bin_path(); if (!emul_bin_path) { - LOG("failed to get emulator path.\n"); + ERR("failed to get emulator path.\n"); return NULL; } sdk_info_path_len = strlen(emul_bin_path) + strlen(sdk_info) + 1; sdk_info_file_path = g_malloc(sdk_info_path_len); if (!sdk_info_file_path) { - LOG("failed to allocate sdk-data buffer.\n"); + ERR("failed to allocate sdk-data buffer.\n"); return NULL; } g_snprintf(sdk_info_file_path, sdk_info_path_len, "%s%s", emul_bin_path, sdk_info); - LOG("sdk.info path: %s\n", sdk_info_file_path); + INFO("sdk.info path: %s\n", sdk_info_file_path); sdk_info_fp = fopen(sdk_info_file_path, "r"); g_free(sdk_info_file_path); if (sdk_info_fp) { - LOG("Succeeded to open [sdk.info].\n"); + TRACE("Succeeded to open [sdk.info].\n"); char tmp[256] = { '\0', }; char *tmpline = NULL; @@ -999,7 +968,7 @@ char *get_tizen_sdk_data_path(void) tizen_sdk_data_path = g_malloc(strlen(tmpline) + 1); g_strlcpy(tizen_sdk_data_path, tmpline, strlen(tmpline) + 1); - LOG("tizen-sdk-data path: %s\n", tizen_sdk_data_path); + INFO("tizen-sdk-data path: %s\n", tizen_sdk_data_path); fclose(sdk_info_fp); return tizen_sdk_data_path; @@ -1009,7 +978,7 @@ char *get_tizen_sdk_data_path(void) } // legacy mode - LOG("Failed to open [sdk.info].\n"); + ERR("Failed to open [sdk.info].\n"); return get_old_tizen_sdk_data_path(); } @@ -1018,7 +987,7 @@ static char *get_old_tizen_sdk_data_path(void) { char *tizen_sdk_data_path = NULL; - LOG("try to search tizen-sdk-data path in another way.\n"); + INFO("try to search tizen-sdk-data path in another way.\n"); #ifndef CONFIG_WIN32 char tizen_sdk_data[] = "/tizen-sdk-data"; @@ -1033,7 +1002,7 @@ static char *get_old_tizen_sdk_data_path(void) tizen_sdk_data_len = strlen(home_dir) + sizeof(tizen_sdk_data) + 1; tizen_sdk_data_path = g_malloc(tizen_sdk_data_len); if (!tizen_sdk_data_path) { - LOG("failed to allocate memory.\n"); + ERR("failed to allocate memory.\n"); return NULL; } g_strlcpy(tizen_sdk_data_path, home_dir, tizen_sdk_data_len); @@ -1057,7 +1026,7 @@ static char *get_old_tizen_sdk_data_path(void) tizen_sdk_data_len = strlen(strLocalAppDataPath) + sizeof(tizen_sdk_data) + 1; tizen_sdk_data_path = g_malloc(tizen_sdk_data_len); if (!tizen_sdk_data_path) { - LOG("failed to allocate memory.\n"); + ERR("failed to allocate memory.\n"); return NULL; } @@ -1065,7 +1034,7 @@ static char *get_old_tizen_sdk_data_path(void) g_strlcat(tizen_sdk_data_path, tizen_sdk_data, tizen_sdk_data_len); #endif - LOG("tizen-sdk-data path: %s\n", tizen_sdk_data_path); + INFO("tizen-sdk-data path: %s\n", tizen_sdk_data_path); return tizen_sdk_data_path; } diff --git a/tizen/src/ecs/ecs_tethering.c b/tizen/src/ecs/ecs_tethering.c index 9315da8..4e98aa9 100644 --- a/tizen/src/ecs/ecs_tethering.c +++ b/tizen/src/ecs/ecs_tethering.c @@ -63,7 +63,7 @@ static int tethering_port = 0; void send_tethering_sensor_status_ecp(void) { - LOG(">> send tethering_event_status to ecp"); + INFO(">> send tethering_event_status to ecp"); send_tethering_status_ntf(ECS_TETHERING_MSG_GROUP_ECP, ECS_TETHERING_MSG_ACTION_SENSOR_STATUS); } @@ -76,7 +76,7 @@ void send_tethering_touch_status_ecp(void) void send_tethering_connection_status_ecp(void) { - LOG(">> send tethering_connection_status to ecp"); + INFO(">> send tethering_connection_status to ecp"); send_tethering_status_ntf(ECS_TETHERING_MSG_GROUP_ECP, ECS_TETHERING_MSG_ACTION_CONNECTION_STATUS); } @@ -94,7 +94,7 @@ static void send_tethering_port_ecp(void) return; } - LOG(">> send port_num: %d", tethering_port); + TRACE(">> send port_num: %d", tethering_port); g_snprintf(data, sizeof(data) - 1, "%d", tethering_port); length = strlen(data); @@ -105,7 +105,7 @@ static void send_tethering_port_ecp(void) memcpy(msg + 13, &action, sizeof(unsigned char)); memcpy(msg + 14, data, length); - LOG(">> send tethering_ntf to ecp. action=%d, group=%d, data=%s", + TRACE(">> send tethering_ntf to ecp. action=%d, group=%d, data=%s", action, group, data); // send_tethering_ntf((const char *)msg, MSG_BUF_SIZE); @@ -153,7 +153,7 @@ static void send_tethering_status_ntf(type_group group, type_action action) memcpy(msg + 13, &action, sizeof(unsigned char)); memcpy(msg + 14, data, 1); - LOG(">> send tethering_ntf to ecp. action=%d, group=%d, data=%s", + TRACE(">> send tethering_ntf to ecp. action=%d, group=%d, data=%s", action, group, data); // send_tethering_ntf((const char *)msg, MSG_BUF_SIZE); @@ -182,7 +182,7 @@ static bool send_tethering_ntf(const char *data) const char* ijdata = (data + catsize + 2 + 1 + 1); - LOG("<< header cat = %s, length = %d, action=%d, group=%d", cat, length,action, group); + TRACE("<< header cat = %s, length = %d, action=%d, group=%d", cat, length,action, group); ECS__Master master = ECS__MASTER__INIT; ECS__TetheringNtf ntf = ECS__TETHERING_NTF__INIT; @@ -201,7 +201,7 @@ static bool send_tethering_ntf(const char *data) ntf.data.len = length; memcpy(ntf.data.data, ijdata, length); - LOG("data = %s, length = %hu", ijdata, length); + TRACE("data = %s, length = %hu", ijdata, length); } master.type = ECS__MASTER__TYPE__TETHERING_NTF; @@ -240,7 +240,7 @@ bool msgproc_tethering_req(ECS_Client* ccli, ECS__TetheringReq* msg) type_group group = (type_group) (msg->group & 0xff); type_action action = (type_action) (msg->action & 0xff); - LOG(">> header = cmd = %s, length = %d, action=%d, group=%d", + TRACE(">> header = cmd = %s, length = %d, action=%d, group=%d", cmd, length, action, group); if (group == ECS_TETHERING_MSG_GROUP_ECP) { @@ -253,25 +253,25 @@ bool msgproc_tethering_req(ECS_Client* ccli, ECS__TetheringReq* msg) port = g_ascii_strtoull(data, NULL, 10); - LOG(">> MSG_ACTION_CONNECT"); - LOG(">> len = %zd, data\" %s\"", strlen(data), data); + TRACE(">> MSG_ACTION_CONNECT"); + TRACE(">> len = %zd, data\" %s\"", strlen(data), data); connect_tethering_app(port); tethering_port = port; - LOG(">> port_num: %d, %d", port, tethering_port); + TRACE(">> port_num: %d, %d", port, tethering_port); } } break; case ECS_TETHERING_MSG_ACTION_DISCONNECT: - LOG(">> MSG_ACTION_DISCONNECT"); + INFO(">> MSG_ACTION_DISCONNECT"); disconnect_tethering_app(); tethering_port = 0; break; case ECS_TETHERING_MSG_ACTION_CONNECTION_STATUS: case ECS_TETHERING_MSG_ACTION_SENSOR_STATUS: case ECS_TETHERING_MSG_ACTION_TOUCH_STATUS: - LOG(">> get_status_action"); + TRACE(">> get_status_action"); send_tethering_status_ntf(group, action); break; default: -- 2.7.4