+* 1.5.102
+- supports qmp handling for ecs.
+- added keep alive checking routine for ecs.
+== Jinhyung Choi <jinhyung2.choi@samsung.com> 2013-10-10
+* 1.5.101
+- fixed sync problem when closing avcodec context.
+== Kitae Kim <kt920.kim@samsung.com> 2013-09-30
* 1.5.97
- YAGL module is excluded from the build on MacOS in temparary.
== Jinhyung Jo <jinhyung.jo@samsung.com> 2013-09-27
-Version: 1.5.97
+Version: 1.5.102
Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
Source: emulator
#include "sdb.h"
#include "ecs.h"
+#include "guest_server.h"
#include "genmsg/ecs.pb-c.h"
static ECS_State *current_ecs;
+static void* keepalive_buf;
+static int payloadsize;
+
static int port;
static int port_setting = -1;
static pthread_mutex_t mutex_clilist = PTHREAD_MUTEX_INITIALIZER;
-static inline void start_logging(void) {
- char path[256];
- char* home;
+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/ecs.log";
+#else
+ char emulator_ecs[] = "\\emulator\\vms\\ecs.log";
+#endif
+
+ 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) + 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),
+ "%s%s", tizen_sdk_data, emulator_ecs);
- home = getenv(LOG_HOME);
- sprintf(path, "%s%s", home, LOG_PATH);
+ 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;
int fd = open("/dev/null", O_RDONLY);
dup2(fd, 0);
- fd = open(path, O_WRONLY | O_CREAT | O_APPEND, 0640);
+ fd = creat(path, 0640);
if (fd < 0) {
fd = open("/dev/null", O_WRONLY);
}
}
int ecs_write(int fd, const uint8_t *buf, int len) {
- LOG("write buflen : %d, buf : %s", len, buf);
+ LOG("write buflen : %d, buf : %s", len, (char*)buf);
if (fd < 0) {
return -1;
}
}
bool send_to_all_client(const char* data, const int len) {
+ LOG("data len: %d, data: %s", len, data);
pthread_mutex_lock(&mutex_clilist);
ECS_Client *clii;
cs->mon = NULL;
}
+ if (keepalive_buf) {
+ g_free(keepalive_buf);
+ }
+
if (NULL != cs->alive_timer) {
qemu_del_timer(cs->alive_timer);
cs->alive_timer = NULL;
pthread_mutex_unlock(&mutex_clilist);
+// send_ecs_version_check(clii);
+
return 0;
}
}
#endif
+static void send_keep_alive_msg(ECS_Client *clii) {
+ send_to_client(clii->client_fd, keepalive_buf, payloadsize);
+}
+
+static void make_keep_alive_msg(void) {
+ int len_pack = 0;
+ char msg [5] = {'s','e','l','f'};
+
+ ECS__Master master = ECS__MASTER__INIT;
+ ECS__KeepAliveReq req = ECS__KEEP_ALIVE_REQ__INIT;
+
+ req.time_str = (char*) g_malloc(5);
+
+ strncpy(req.time_str, msg, 4);
+
+ master.type = ECS__MASTER__TYPE__KEEPALIVE_REQ;
+ master.keepalive_req = &req;
+
+ len_pack = ecs__master__get_packed_size(&master);
+ payloadsize = len_pack + 4;
+
+ keepalive_buf = g_malloc(len_pack + 4);
+ if (!keepalive_buf) {
+ LOG("keep alive message creation is failed.");
+ return;
+ }
+
+ ecs__master__pack(&master, keepalive_buf + 4);
+
+ len_pack = htonl(len_pack);
+ memcpy(keepalive_buf, &len_pack, 4);
+}
+
static void alive_checker(void *opaque) {
- /*
- ECS_State *cs = opaque;
- ECS_Client *clii;
- QObject *obj;
- obj = qobject_from_jsonf("{\"type\":\"self\"}");
+ ECS_Client *clii;
if (NULL != current_ecs && !current_ecs->ecs_running) {
return;
{
if (1 == clii->keep_alive) {
LOG("get client fd %d - keep alive fail", clii->client_fd);
- //ecs_client_close(clii);
+ ecs_client_close(clii);
continue;
}
LOG("set client fd %d - keep alive 1", clii->client_fd);
clii->keep_alive = 1;
- ecs_json_emitter(clii, obj);
+ send_keep_alive_msg(clii);
}
- qemu_mod_timer(cs->alive_timer,
+ qemu_mod_timer(current_ecs->alive_timer,
qemu_get_clock_ns(vm_clock) + get_ticks_per_sec() * TIMER_ALIVE_S);
- */
+
}
static int socket_initialize(ECS_State *cs, QemuOpts *opts) {
FD_SET(fd, &cs->reads);
#endif
+ make_keep_alive_msg();
+
cs->alive_timer = qemu_new_timer_ns(vm_clock, alive_checker, cs);
qemu_mod_timer(cs->alive_timer,
if (!msg)
goto fail;
msgproc_nfc_req(cli, msg);
+ }
+#if 0
+ else if (master->type == ECS__MASTER__TYPE__CHECKVERSION_REQ)
+ {
+ ECS__CheckVersionReq* msg = master->checkversion_req;
+ if (!msg)
+ goto fail;
+ msgproc_checkversion_req(cli, msg);
+ }
+#endif
+ else if (master->type == ECS__MASTER__TYPE__KEEPALIVE_ANS)
+ {
+ ECS__KeepAliveAns* msg = master->keepalive_ans;
+ if (!msg)
+ goto fail;
+ msgproc_keepalive_ans(cli, msg);
}
ecs__master__free_unpacked(master, NULL);
#include "genmsg/ecs.pb-c.h"
#include "genmsg/ecs_ids.pb-c.h"
+#define ECS_VERSION "1.0"
+
#define ECS_DEBUG 1
#ifdef ECS_DEBUG
bool msgproc_monitor_req(ECS_Client *ccli, ECS__MonitorReq* msg);
bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg);
bool msgproc_nfc_req(ECS_Client* ccli, ECS__NfcReq* msg);
+void msgproc_checkversion_req(ECS_Client* ccli, ECS__CheckVersionReq* msg);
+void msgproc_keepalive_ans(ECS_Client* ccli, ECS__KeepAliveAns* msg);
+
+/* version check */
+//void send_ecs_version_check(ECS_Client* ccli);
/* request */
int accel_min_max(double value);
#include "hw/qdev.h"
#include "net/net.h"
+#include "net/slirp.h"
#include "ui/console.h"
#include "migration/migration.h"
#include "qapi/qmp/qint.h"
}
return true;
}
-
-
-// message handlers
-
#if 0
-bool msgproc_start_req(ECS_Client* ccli, ECS__StartReq* msg)
+static bool send_to_single_client(ECS__Master* master, ECS_Client *ccli)
{
- LOG("ecs_startinfo_req");
-
- int hostkbd_status = mloop_evcmd_get_hostkbd_status();
-
- LOG("hostkbd_status = %d", hostkbd_status);
+ int payloadsize = 0;
+ void* buf = build_master(master, &payloadsize);
+ if (!buf)
+ {
+ LOG("invalid buf");
+ return false;
+ }
- send_start_ans(hostkbd_status);
+ if (!send_to_client(ccli->client_fd, buf, payloadsize))
+ return false;
+ if (buf)
+ {
+ g_free(buf);
+ }
return true;
}
#endif
return true;
}
#if 0
-bool msgproc_control_msg(ECS_Client *cli, ECS__ControlMsg* msg)
+void msgproc_checkversion_req(ECS_Client* ccli, ECS__CheckVersionReq* msg)
{
- if (msg->type == ECS__CONTROL_MSG__CONTROL_TYPE__HOSTKEYBOARD_REQ)
+ int datalen = 0;
+ if (msg->has_data)
{
- ECS__HostKeyboardReq* hkr = msg->hostkeyboard_req;
- if (!hkr)
- return false;
- msgproc_control_hostkeyboard_req(cli, hkr);
+ 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);
+ }
}
+}
- return true;
+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;
+}
+
+static void send_host_keyboard_ntf (void)
+{
+ type_length length = (unsigned short)1;
+ type_group group = GROUP_STATUS;
+ type_action action = 122;
+ int is_on = mloop_evcmd_get_hostkbd_status();
+
+ char* keyboard_msg = (char*) malloc(15);
+ if(!keyboard_msg)
+ return;
+
+ memcpy(keyboard_msg, "HKeyboard", 10);
+ memcpy(keyboard_msg + 10, &length, sizeof(unsigned short));
+ memcpy(keyboard_msg + 12, &group, sizeof(unsigned char));
+ memcpy(keyboard_msg + 13, &action, sizeof(unsigned char));
+ memcpy(keyboard_msg + 14, (is_on?"1":"0"), 1);
+
+ send_device_ntf(keyboard_msg, 15);
+
+ if (keyboard_msg)
+ free(keyboard_msg);
+}
bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg)
{
+ int is_on = 0;
char cmd[10];
char* data = NULL;
memset(cmd, 0, 10);
if (msg->has_data && msg->data.len > 0)
{
- data = (char*)msg->data.data;
+ data = (char*) g_malloc0(msg->data.len + 1);
+ memcpy(data, msg->data.data, msg->data.len);
}
LOG(">> header = cmd = %s, length = %d, action=%d, group=%d", cmd, length,
} else {
set_sensor_data(length, data);
}
+ } else if (!strncmp(cmd, "Network", 7)) {
+ LOG(">>> Network msg: '%s'", data);
+ if(net_slirp_redir(data) < 0) {
+ LOG( "redirect [%s] fail \n", data);
+ } else {
+ LOG("redirect [%s] success\n", data);
+ }
+ } else if (!strncmp(cmd, "HKeyboard", 8)) {
+ if (group == MSG_GROUP_STATUS) {
+ send_host_keyboard_ntf();
+ } else {
+ if (!strncmp(data, "1", 1)) {
+ is_on = 1;
+ }
+ onoff_host_kbd(is_on);
+ }
+ } 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);
+ }
}
+ if (data)
+ g_free(data);
+
return true;
}
-
bool msgproc_nfc_req(ECS_Client* ccli, ECS__NfcReq* msg)
{
char cmd[10];
return true;
}
-#if 0
-bool msgproc_screen_dump_req(ECS_Client *ccli, ECS__ScreenDumpReq* msg)
-{
-
- return true;
-}
-
-
-// begin control command
-
-void msgproc_control_hostkeyboard_req(ECS_Client *clii, ECS__HostKeyboardReq* req)
-{
- int64_t is_on = req->ison;
- onoff_host_kbd(is_on);
-}
-#endif
-// end control command
-
-
-//
-
bool ntf_to_injector(const char* data, const int len) {
type_length length = 0;
type_group group = 0;
return true;
}
-#if 0
-bool send_start_ans(int host_keyboard_onff)
-{
- ECS__Master master = ECS__MASTER__INIT;
- ECS__StartAns ans = ECS__START_ANS__INIT;
-
- ans.has_host_keyboard_onoff = 1;
- ans.host_keyboard_onoff = host_keyboard_onff;
- ans.has_camera_onoff = 1;
- ans.camera_onoff = 1;
-
- ans.has_earjack_onoff = 1;
- ans.earjack_onoff = 1;
-
- master.type = ECS__MASTER__TYPE__START_ANS;
- master.start_ans = &ans;
-
- return send_to_ecp(&master);
-}
-#endif
bool send_injector_ntf(const char* data, const int len)
{
type_length length = 0;
return true;
}
-#if 0
-bool send_hostkeyboard_ntf(int is_on)
-{
- ECS__Master master = ECS__MASTER__INIT;
- ECS__ControlMsg ctl = ECS__CONTROL_MSG__INIT;
-
- ECS__HostKeyboardNtf ntf = ECS__HOST_KEYBOARD_NTF__INIT;
-
- ntf.has_ison = 1;
- ntf.ison = is_on;
-
- ctl.type = ECS__CONTROL_MSG__CONTROL_TYPE__HOSTKEYBOARD_NTF;
- ctl.hostkeyboard_ntf = &ntf;
-
- master.type = ECS__MASTER__TYPE__CONTROL_MSG;
- master.control_msg = &ctl;
-
- return send_to_ecp(&master);
-}
-#endif
-
bool send_device_ntf(const char* data, const int len)
{
type_length length = 0;
read_val_char(data + catsize + 2, &group);
read_val_char(data + catsize + 2 + 1, &action);
-
const char* ijdata = (data + catsize + 2 + 1 + 1);
LOG("<< header cat = %s, length = %d, action=%d, group=%d", cat, length,action, group);
message KeepAliveReq {
optional string time_str = 1;
-
}
message KeepAliveAns {
/*
* get tizen-sdk-data path from sdk.info.
*/
-static gchar *get_tizen_sdk_data_path(void)
+gchar *get_tizen_sdk_data_path(void)
{
gchar *emul_bin_path = NULL;
gchar *sdk_info_file_path = NULL;
pthread_t start_guest_server( int server_port );
void shutdown_guest_server( void );
+gchar *get_tizen_sdk_data_path(void);
+
#define STATE_RESUME 0
#define STATE_SUSPEND 1