YeongKyoon Lee <yeongkyoon.lee@samsung.com>
DaiYoung Kim <daiyoung777.kim@samsung.com>
-SeokYeon Hwang <syeon.hwang@samsung.com>
Jinhyung Choi <jinhyung2.choi@samsung.com>
+SeokYeon Hwang <syeon.hwang@samsung.com>
SangJin Kim <sangjin3.kim@samsung.com>
KiTae Kim <kt920.kim@samsung.com>
JinHyung Jo <jinhyung.jo@samsung.com>
#FIND_PROGRAM(UNAME NAMES uname)
#EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
#IF("${ARCH}" STREQUAL "arm")
-# ADD_DEFINITIONS("-DTARGET -DHWREV_CHECK")
-# MESSAGE("add -DTARGET")
+# ADD_DEFINITIONS("-DTARGET -DHWREV_CHECK")
+# MESSAGE("add -DTARGET")
#ELSE("${ARCH}" STREQUAL "arm")
-# ADD_DEFINITIONS("-DSIMULATOR")
-# MESSAGE("add -DSIMULATOR")
+# ADD_DEFINITIONS("-DSIMULATOR")
+# MESSAGE("add -DSIMULATOR")
#ENDIF("${ARCH}" STREQUAL "arm")
ADD_DEFINITIONS("-DTARGET -DHWREV_CHECK")
#add_definitions(-D_ESTIMATE_PERFORMANCE)
#add_definitions(-D_DEFAULT_FONT_NAME="Vera")
-add_definitions(-Wall -O3 -omit-frame-pointer)
+add_definitions(-Werror -Wall -O3 -omit-frame-pointer)
#add_definitions(-Wall -g -D_DEBUG)
add_definitions(-Iinclude)
ADD_EXECUTABLE(${PROJECT_NAME} src/emuld.cpp src/evdi.cpp src/emuld_proc.cpp src/client.cpp src/get_status.cpp src/log.cpp)
target_link_libraries(${PROJECT_NAME} ${rpkgs_LDFLAGS} ${GLES_LDFLAGS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} "-lpthread -lvconf" )
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} "-lpthread -lvconf -lpmapi" )
install(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin)
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+++ /dev/null
-/usr/bin/emuld &
-/usr/sbin/sensord &
-/etc/emulator/sensor_setting.sh &
/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
+ * Jinhyung Choi <jinhyung2.choi@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
* YeongKyoon Lee <yeongkyoon.lee@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
#include "emuld_proc.h"
/* definition */
-#define MAX_CLIENT 10000
-#define MAX_EVENTS 10000
-#define MAX_GETCNT 10
-#define SDBD_PORT 26101
-#define DEFAULT_PORT 3577
-#define VMODEM_PORT 3578
-#define SAP_PORT 9999
-#define GPSD_PORT 3579
-#define SENSORD_PORT 3580
-#define SRV_IP "10.0.2.2"
-#define ID_SIZE 10
-#define HEADER_SIZE 4
+#define MAX_CLIENT 10000
+#define MAX_EVENTS 10000
+#define MAX_GETCNT 10
+#define SDBD_PORT 26101
+#define DEFAULT_PORT 3577
+#define VMODEM_PORT 3578
+#define SAP_PORT 9999
+#define GPSD_PORT 3579
+#define SENSORD_PORT 3580
+#define SRV_IP "10.0.2.2"
+#define ID_SIZE 10
+#define HEADER_SIZE 4
#define EMD_DEBUG
-#define POWEROFF_DURATION 2
+#define POWEROFF_DURATION 2
-
-#define SDB_PORT_FILE "/opt/home/sdb_port.txt"
+#define SDB_PORT_FILE "/opt/home/sdb_port.txt"
enum
{
extern int g_fd[fdtype_max];
-#define IJTYPE_TELEPHONY "telephony"
-#define IJTYPE_SAP "sap"
-#define IJTYPE_SDCARD "sdcard"
+#define IJTYPE_TELEPHONY "telephony"
+#define IJTYPE_SAP "sap"
+#define IJTYPE_SDCARD "sdcard"
bool epoll_ctl_add(const int fd);
void userpool_add(int cli_fd, unsigned short cli_port, const int fdtype);
void userpool_delete(int cli_fd);
-
bool epoll_init(void); /* epoll fd create */
bool epoll_ctl_add(const int fd);
-
void init_data0(void); /* initialize data. */
bool init_server0(int svr_port, int* ret_fd);
void end_server(int sig);
void* init_vm_connect(void* data);
void* init_sap_connect(void* data);
-
-
-
-
void systemcall(const char* param);
void recv_from_evdi(evdi_fd fd);
-static int log_print = 1;
-
-
int powerdown_by_force(void);
// location
void setting_location(char* databuf);
-
#define LOG(fmt, arg...) \
- do { \
- log_print_out("[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); \
- } while (0)
-
-
-
+ do { \
+ log_print_out("[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); \
+ } while (0)
#include <map>
-typedef unsigned short CliSN;
+typedef unsigned short CliSN;
struct Cli
{
- Cli(CliSN clisn, int fdtype, int fd, unsigned short port) :
- clisn(clisn), fdtype(fdtype), sockfd(fd), cli_port(port) {}
+ Cli(CliSN clisn, int fdtype, int fd, unsigned short port) :
+ clisn(clisn), fdtype(fdtype), sockfd(fd), cli_port(port) {}
- CliSN clisn;
- int fdtype;
- int sockfd; /* client socket fds */
- unsigned short cli_port; /* client connection port */
+ CliSN clisn;
+ int fdtype;
+ int sockfd; /* client socket fds */
+ unsigned short cli_port; /* client connection port */
};
typedef std::map<CliSN, Cli*> CliMap;
-
void clipool_add(int fd, unsigned short port, const int fdtype);
void clipool_delete(int fd);
void close_cli(int cli_fd);
bool is_ij_exist();
void stop_listen(void);
-
struct fd_info
{
- fd_info() : fd(-1){}
- int fd;
- int fdtype;
+ fd_info() : fd(-1){}
+ int fd;
+ int fdtype;
};
struct ijcommand
{
- enum { CMD_SIZE = 48 };
- ijcommand() : data(NULL)
- {
- memset(cmd, 0, CMD_SIZE);
- }
- ~ijcommand()
- {
- if (data)
- {
- free(data);
- data = NULL;
- }
- }
- char cmd[CMD_SIZE];
- char* data;
- fd_info fdinfo;
-
- LXT_MESSAGE msg;
+ enum { CMD_SIZE = 48 };
+ ijcommand() : data(NULL)
+ {
+ memset(cmd, 0, CMD_SIZE);
+ }
+ ~ijcommand()
+ {
+ if (data)
+ {
+ free(data);
+ data = NULL;
+ }
+ }
+ char cmd[CMD_SIZE];
+ char* data;
+ fd_info fdinfo;
+
+ LXT_MESSAGE msg;
};
void process_evdi_command(ijcommand* ijcmd);
bool msgproc_system(const int sockfd, ijcommand* ijcmd, const bool is_evdi);
bool msgproc_sdcard(const int sockfd, ijcommand* ijcmd, const bool is_evdi);
-
#endif //__emuld_h__
/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
+ * Jinhyung Choi <jinhyung2.choi@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
* YeongKyoon Lee <yeongkyoon.lee@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
// define group id
// return value to the injector
-#define STATUS 15
+#define STATUS 15
// define action id
-#define BATTERY_LEVEL 100
-#define BATTERY_CHARGER 101
-#define USB_STATUS 102
-#define EARJACK_STATUS 103
-#define RSSI_LEVEL 104
-
-#define ACCEL_VALUE 110
-#define GYRO_VALUE 111
-#define MAG_VALUE 112
-#define LIGHT_VALUE 113
-#define PROXI_VALUE 114
-#define MOTION_VALUE 115
-
-#define LOCATION_STATUS 120
-
-#define NFC_STATUS 121
-
-#define PATH_SENSOR_ACCEL_XYZ "/sys/devices/virtual/sensor/accel/xyz"
-#define PATH_SENSOR_PROXI_VO "/sys/devices/virtual/sensor/proxi/vo"
-#define PATH_SENSOR_LIGHT_ADC "/sys/devices/virtual/sensor/light/adc"
-#define PATH_SENSOR_GYRO_X_RAW "/sys/devices/virtual/sensor/gyro/gyro_x_raw"
-#define PATH_SENSOR_GYRO_Y_RAW "/sys/devices/virtual/sensor/gyro/gyro_y_raw"
-#define PATH_SENSOR_GYRO_Z_RAW "/sys/devices/virtual/sensor/gyro/gyro_z_raw"
-#define PATH_SENSOR_GEO_TESLA "/sys/devices/virtual/sensor/geo/tesla"
-#define PATH_NFC_DATA "/sys/devices/virtual/network/nfc/data"
+#define BATTERY_LEVEL 100
+#define BATTERY_CHARGER 101
+#define USB_STATUS 102
+#define EARJACK_STATUS 103
+#define RSSI_LEVEL 104
+
+#define ACCEL_VALUE 110
+#define GYRO_VALUE 111
+#define MAG_VALUE 112
+#define LIGHT_VALUE 113
+#define PROXI_VALUE 114
+#define MOTION_VALUE 115
+
+#define LOCATION_STATUS 120
+
+#define NFC_STATUS 121
+
+#define PATH_SENSOR_ACCEL_XYZ "/sys/devices/virtual/sensor/accel/xyz"
+#define PATH_SENSOR_PROXI_VO "/sys/devices/virtual/sensor/proxi/vo"
+#define PATH_SENSOR_LIGHT_ADC "/sys/devices/virtual/sensor/light/adc"
+#define PATH_SENSOR_GYRO_X_RAW "/sys/devices/virtual/sensor/gyro/gyro_x_raw"
+#define PATH_SENSOR_GYRO_Y_RAW "/sys/devices/virtual/sensor/gyro/gyro_y_raw"
+#define PATH_SENSOR_GYRO_Z_RAW "/sys/devices/virtual/sensor/gyro/gyro_z_raw"
+#define PATH_SENSOR_GEO_TESLA "/sys/devices/virtual/sensor/geo/tesla"
+#define PATH_NFC_DATA "/sys/devices/virtual/network/nfc/data"
struct LXT_MESSAGE// lxt_message
{
- unsigned short length;
- unsigned char group;
- unsigned char action;
- void *data;
+ unsigned short length;
+ unsigned char group;
+ unsigned char action;
+ void *data;
};
typedef struct LXT_MESSAGE LXT_MESSAGE;
struct _auto_mutex
{
- _auto_mutex(pthread_mutex_t* t)
- {
- _mutex = t;
- pthread_mutex_lock(_mutex);
-
- }
- ~_auto_mutex()
- {
- pthread_mutex_unlock(_mutex);
- }
-
- pthread_mutex_t* _mutex;
+ _auto_mutex(pthread_mutex_t* t)
+ {
+ _mutex = t;
+ pthread_mutex_lock(_mutex);
+
+ }
+ ~_auto_mutex()
+ {
+ pthread_mutex_unlock(_mutex);
+ }
+
+ pthread_mutex_t* _mutex;
};
#endif //
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
#ifndef __emuld_proc_h__
#define __emuld_proc_h__
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
#ifndef __evdi_h__
#define __evdi_h__
-typedef int evdi_fd;
+typedef int evdi_fd;
bool init_device(evdi_fd* ret_fd);
-/*\r
- * evdi_protocol.h\r
- *\r
- * Created on: 2013. 4. 15.\r
- * Author: dykim\r
- */\r
-\r
-#ifndef EVDI_PROTOCOL_H_\r
-#define EVDI_PROTOCOL_H_\r
-\r
-/* device protocol */\r
-\r
-#define __MAX_BUF_SIZE 1024\r
-\r
-enum\r
-{\r
- route_qemu = 0,\r
- route_control_server = 1,\r
- route_monitor = 2\r
-};\r
-\r
-typedef unsigned int CSCliSN;\r
-\r
-struct msg_info {\r
- char buf[__MAX_BUF_SIZE];\r
-\r
- uint32_t route;\r
- uint32_t use;\r
- uint16_t count;\r
- uint16_t index;\r
-\r
- CSCliSN cclisn;\r
-};\r
-\r
-/* device protocol */\r
-\r
-\r
-#endif /* EVDI_PROTOCOL_H_ */\r
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#ifndef EVDI_PROTOCOL_H_
+#define EVDI_PROTOCOL_H_
+
+/* device protocol */
+
+#define __MAX_BUF_SIZE 1024
+
+enum
+{
+ route_qemu = 0,
+ route_control_server = 1,
+ route_monitor = 2
+};
+
+typedef unsigned int CSCliSN;
+
+struct msg_info {
+ char buf[__MAX_BUF_SIZE];
+
+ uint32_t route;
+ uint32_t use;
+ uint16_t count;
+ uint16_t index;
+
+ CSCliSN cclisn;
+};
+
+/* device protocol */
+
+
+#endif /* EVDI_PROTOCOL_H_ */
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
#ifndef __log_h__
#define __log_h__
-/*\r
- * synbuf.h\r
- *\r
- * Created on: 2013. 4. 12.\r
- * Author: dykim\r
- */\r
-\r
-#ifndef SYNBUF_H_\r
-#define SYNBUF_H_\r
-\r
-#include <stdbool.h>\r
-\r
-\r
-class synbuf\r
-{\r
-public:\r
-\r
- enum\r
- {\r
- default_buf_size = 2048\r
- };\r
- synbuf()\r
- : m_buf(NULL), m_size(default_buf_size), m_use(0)\r
- {\r
- m_buf = (char*) malloc(default_buf_size);\r
- memset(m_buf, 0, default_buf_size);\r
- m_readptr = m_buf;\r
- }\r
-\r
- void reset_buf()\r
- {\r
- freebuf();\r
-\r
- m_buf = (char*) malloc(default_buf_size);\r
- memset(m_buf, 0, default_buf_size);\r
- m_readptr = m_buf;\r
-\r
- m_size = default_buf_size;\r
- m_use = 0;\r
- }\r
-\r
- int available()\r
- {\r
- return m_size - m_use;\r
- }\r
-\r
- char* get_readptr()\r
- {\r
- return m_readptr;\r
- }\r
-\r
- void set_written(const int written)\r
- {\r
- m_use += written;\r
- }\r
-\r
- void freebuf()\r
- {\r
- if (m_buf)\r
- {\r
- free(m_buf);\r
- m_buf = NULL;\r
- }\r
- }\r
-\r
- bool realloc_and_move(const int newsize, const int readed)\r
- {\r
- char* tmp = (char*) malloc(newsize);\r
- if (!tmp)\r
- return false;\r
-\r
- int left = m_use - readed;\r
- memset(tmp, 0, newsize);\r
- memcpy(tmp, m_buf + readed, left);\r
-\r
- freebuf();\r
-\r
- m_buf = tmp;\r
- m_use = left;\r
- m_size = newsize;\r
- m_readptr = m_buf;\r
-\r
- return true;\r
- }\r
-\r
- bool write(const char* buf, const int len)\r
- {\r
- if (len >= available())\r
- {\r
- if (!realloc_and_move((m_size * 2), 0))\r
- return false;\r
- }\r
-\r
- memcpy(m_buf + m_use, buf, len);\r
- m_use += len;\r
-\r
- return true;\r
- }\r
-\r
- int read(char* buf, const int len)\r
- {\r
- if (m_use < len)\r
- return 0;\r
-\r
- memcpy(buf, m_buf, len);\r
-\r
- int left = m_use - len;\r
- if (left > 0)\r
- {\r
- realloc_and_move(m_size, len);\r
- }\r
- else\r
- {\r
- // there is no more readable buffer, reset all variables\r
- memset(m_buf, 0, m_size);\r
- m_readptr = m_buf;\r
- m_use = 0;\r
- }\r
-\r
- return len;\r
- }\r
-\r
-\r
-private:\r
-\r
-\r
- char* m_buf;\r
- char* m_readptr;\r
- int m_size;\r
- int m_use;\r
-};\r
-\r
-\r
-\r
-#endif /* SYNBUF_H_ */\r
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#ifndef SYNBUF_H_
+#define SYNBUF_H_
+
+#include <stdbool.h>
+
+
+class synbuf
+{
+public:
+
+ enum
+ {
+ default_buf_size = 2048
+ };
+ synbuf()
+ : m_buf(NULL), m_size(default_buf_size), m_use(0)
+ {
+ m_buf = (char*) malloc(default_buf_size);
+ memset(m_buf, 0, default_buf_size);
+ m_readptr = m_buf;
+ }
+
+ void reset_buf()
+ {
+ freebuf();
+
+ m_buf = (char*) malloc(default_buf_size);
+ memset(m_buf, 0, default_buf_size);
+ m_readptr = m_buf;
+
+ m_size = default_buf_size;
+ m_use = 0;
+ }
+
+ int available()
+ {
+ return m_size - m_use;
+ }
+
+ char* get_readptr()
+ {
+ return m_readptr;
+ }
+
+ void set_written(const int written)
+ {
+ m_use += written;
+ }
+
+ void freebuf()
+ {
+ if (m_buf)
+ {
+ free(m_buf);
+ m_buf = NULL;
+ }
+ }
+
+ bool realloc_and_move(const int newsize, const int readed)
+ {
+ char* tmp = (char*) malloc(newsize);
+ if (!tmp)
+ return false;
+
+ int left = m_use - readed;
+ memset(tmp, 0, newsize);
+ memcpy(tmp, m_buf + readed, left);
+
+ freebuf();
+
+ m_buf = tmp;
+ m_use = left;
+ m_size = newsize;
+ m_readptr = m_buf;
+
+ return true;
+ }
+
+ bool write(const char* buf, const int len)
+ {
+ if (len >= available())
+ {
+ if (!realloc_and_move((m_size * 2), 0))
+ return false;
+ }
+
+ memcpy(m_buf + m_use, buf, len);
+ m_use += len;
+
+ return true;
+ }
+
+ int read(char* buf, const int len)
+ {
+ if (m_use < len)
+ return 0;
+
+ memcpy(buf, m_buf, len);
+
+ int left = m_use - len;
+ if (left > 0)
+ {
+ realloc_and_move(m_size, len);
+ }
+ else
+ {
+ // there is no more readable buffer, reset all variables
+ memset(m_buf, 0, m_size);
+ m_readptr = m_buf;
+ m_use = 0;
+ }
+
+ return len;
+ }
+
+
+private:
+
+
+ char* m_buf;
+ char* m_readptr;
+ int m_size;
+ int m_use;
+};
+
+
+
+#endif /* SYNBUF_H_ */
-#git:/slp/pkgs/e/emulator-daemon
Name: emuld
-Version: 0.2.30
-Release: 1
-Summary: emuld is used for communication emulator between and ide.
-License: Apache
+Version: 0.4.0
+Release: 0
+Summary: Emulator daemon
+License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
+Group: SDK/Other
Source1001: packaging/emuld.manifest
-BuildArch: i386
-ExclusiveArch: %{ix86}
BuildRequires: cmake
-BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(pmapi)
%description
+A emulator daemon is used for communication emulator between and ide.
%prep
%setup -q
%build
-export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed"
-
+export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed"
+
LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
make
%install
-rm -rf %{buildroot}
-
#for systemd
+rm -rf %{buildroot}
if [ ! -d %{buildroot}/usr/lib/systemd/system/emulator.target.wants ]; then
mkdir -p %{buildroot}/usr/lib/systemd/system/emulator.target.wants
fi
ln -s ../emuld.service %{buildroot}/usr/lib/systemd/system/emulator.target.wants/emuld.service
#for legacy init
-if [ ! -d %{buildroot}/etc/init.d ]; then
- mkdir -p %{buildroot}/etc/init.d
-fi
-cp emuld %{buildroot}/etc/init.d/.
-if [ ! -d %{buildroot}/etc/rc.d/rc3.d ]; then
- mkdir -p %{buildroot}/etc/rc.d/rc3.d
-fi
-ln -s /etc/init.d/emuld %{buildroot}/etc/rc.d/rc3.d/S04emuld
+#if [ ! -d %{buildroot}/etc/init.d ]; then
+# mkdir -p %{buildroot}/etc/init.d
+#fi
+#cp emuld %{buildroot}/etc/init.d/.
+#if [ ! -d %{buildroot}/etc/rc.d/rc3.d ]; then
+# mkdir -p %{buildroot}/etc/rc.d/rc3.d
+#fi
+#ln -s /etc/init.d/emuld %{buildroot}/etc/rc.d/rc3.d/S04emuld
+
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/%{name}
%make_install
rm -rf CMakeFiles
rm -rf cmake_install.cmake
rm -rf Makefile
-rm -rf install_manifes.txt
+rm -rf install_manifest.txt
%post
-chmod 777 /usr/bin/emuld
+chmod 770 %{_prefix}/bin/emuld
mkdir -p /opt/nfc
-
-%postun
+touch /opt/nfc/sdkMsg
%files
%defattr(-,root,root,-)
%{_prefix}/bin/emuld
+/usr/share/license/%{name}
/usr/lib/systemd/system/emuld.service
/usr/lib/systemd/system/emulator.target.wants/emuld.service
-/etc/init.d/emuld
-/etc/rc.d/rc3.d/S04emuld
+#/etc/init.d/emuld
+#/etc/rc.d/rc3.d/S04emuld
%changelog
-\r
-\r
-#include "emuld.h"\r
-#include "emuld_common.h"\r
-\r
-static pthread_mutex_t mutex_climap = PTHREAD_MUTEX_INITIALIZER;\r
-\r
-\r
-CliMap g_climap;\r
-\r
-void clipool_add(int fd, unsigned short port, const int fdtype)\r
-{\r
- _auto_mutex _(&mutex_climap);\r
-\r
- static CliSN s_id = 0;\r
-\r
- CliSN id = s_id;\r
- s_id++;\r
- Cli* cli = new Cli(id, fdtype, fd, port);\r
- if (!cli)\r
- return;\r
-\r
- if (!g_climap.insert(CliMap::value_type(fd, cli)).second)\r
- return;\r
-\r
- LOG("clipool_add fd = %d, port = %d, type = %d \n", fd, port, fdtype);\r
-}\r
-\r
-\r
-void close_cli(int cli_fd)\r
-{\r
- clipool_delete(cli_fd);\r
- close(cli_fd);\r
-}\r
-\r
-void clipool_delete(int fd)\r
-{\r
- _auto_mutex _(&mutex_climap);\r
-\r
- CliMap::iterator it = g_climap.find(fd);\r
-\r
- if (it != g_climap.end())\r
- {\r
- Cli* cli = it->second;\r
- g_climap.erase(it);\r
-\r
- if (cli)\r
- {\r
- delete cli;\r
- cli = NULL;\r
- }\r
- }\r
-\r
- LOG("clipool_delete fd = %d\n", fd);\r
-}\r
-\r
-\r
-Cli* find_cli(const int fd)\r
-{\r
- _auto_mutex _(&mutex_climap);\r
-\r
- CliMap::iterator it = g_climap.find(fd);\r
- if (it != g_climap.end())\r
- return NULL;\r
-\r
- Cli* cli = it->second;\r
- return cli;\r
-}\r
-\r
-// for thread safe\r
-bool send_to_cli(const int fd, char* data, const int len)\r
-{\r
- _auto_mutex _(&mutex_climap);\r
-\r
- CliMap::iterator it = g_climap.find(fd);\r
- if (it == g_climap.end())\r
- return false;\r
-\r
- Cli* cli = it->second;\r
-\r
- if (send(cli->sockfd, data, len, 0) == -1)\r
- return false;\r
-\r
- return true;\r
-}\r
-\r
-bool send_to_all_ij(char* data, const int len)\r
-{\r
- _auto_mutex _(&mutex_climap);\r
-\r
- bool result = false;\r
- CliMap::iterator it, itend = g_climap.end();\r
-\r
- for (it = g_climap.begin(); it != itend; it++)\r
- {\r
- Cli* cli = it->second;\r
-\r
- if (!cli)\r
- continue;\r
-\r
- int sent = send(cli->sockfd, data, len, 0);\r
- result = (sent == -1) ? false : true;\r
- if (sent == -1)\r
- {\r
- perror("failed to send to ij\n");\r
- }\r
-\r
- LOG("send_len: %d, err= %d\n", sent, errno);\r
- }\r
- return result;\r
-}\r
-\r
-bool is_ij_exist()\r
-{\r
- _auto_mutex _(&mutex_climap);\r
-\r
- bool result = (g_climap.size() > 0) ? true : false;\r
- return result;\r
-}\r
-\r
-void stop_listen(void)\r
-{\r
- pthread_mutex_destroy(&mutex_climap);;\r
-}\r
-\r
-\r
-\r
-\r
-\r
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+
+#include "emuld.h"
+#include "emuld_common.h"
+
+static pthread_mutex_t mutex_climap = PTHREAD_MUTEX_INITIALIZER;
+
+
+CliMap g_climap;
+
+void clipool_add(int fd, unsigned short port, const int fdtype)
+{
+ _auto_mutex _(&mutex_climap);
+
+ static CliSN s_id = 0;
+
+ CliSN id = s_id;
+ s_id++;
+ Cli* cli = new Cli(id, fdtype, fd, port);
+ if (!cli)
+ return;
+
+ if (!g_climap.insert(CliMap::value_type(fd, cli)).second)
+ return;
+
+ LOG("clipool_add fd = %d, port = %d, type = %d \n", fd, port, fdtype);
+}
+
+
+void close_cli(int cli_fd)
+{
+ clipool_delete(cli_fd);
+ close(cli_fd);
+}
+
+void clipool_delete(int fd)
+{
+ _auto_mutex _(&mutex_climap);
+
+ CliMap::iterator it = g_climap.find(fd);
+
+ if (it != g_climap.end())
+ {
+ Cli* cli = it->second;
+ g_climap.erase(it);
+
+ if (cli)
+ {
+ delete cli;
+ cli = NULL;
+ }
+ }
+
+ LOG("clipool_delete fd = %d\n", fd);
+}
+
+
+Cli* find_cli(const int fd)
+{
+ _auto_mutex _(&mutex_climap);
+
+ CliMap::iterator it = g_climap.find(fd);
+ if (it != g_climap.end())
+ return NULL;
+
+ Cli* cli = it->second;
+ return cli;
+}
+
+// for thread safe
+bool send_to_cli(const int fd, char* data, const int len)
+{
+ _auto_mutex _(&mutex_climap);
+
+ CliMap::iterator it = g_climap.find(fd);
+ if (it == g_climap.end())
+ return false;
+
+ Cli* cli = it->second;
+
+ if (send(cli->sockfd, data, len, 0) == -1)
+ return false;
+
+ return true;
+}
+
+bool send_to_all_ij(char* data, const int len)
+{
+ _auto_mutex _(&mutex_climap);
+
+ bool result = false;
+ CliMap::iterator it, itend = g_climap.end();
+
+ for (it = g_climap.begin(); it != itend; it++)
+ {
+ Cli* cli = it->second;
+
+ if (!cli)
+ continue;
+
+ int sent = send(cli->sockfd, data, len, 0);
+ result = (sent == -1) ? false : true;
+ if (sent == -1)
+ {
+ perror("failed to send to ij\n");
+ }
+
+ LOG("send_len: %d, err= %d\n", sent, errno);
+ }
+ return result;
+}
+
+bool is_ij_exist()
+{
+ _auto_mutex _(&mutex_climap);
+
+ bool result = (g_climap.size() > 0) ? true : false;
+ return result;
+}
+
+void stop_listen(void)
+{
+ pthread_mutex_destroy(&mutex_climap);;
+}
+
+
+
+
+
-/* -*- Mode: C; c-basic-offset: 8; indent-tabs-mode: t -*-
+/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
+ * Jinhyung Choi <jinhyung2.choi@samsnung.com>
* DaiYoung Kim <daiyoung777.kim@samsnung.com>
* SooYoung Ha <yoosah.ha@samsnung.com>
* Sungmin Ha <sungmin82.ha@samsung.com>
* YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* Contributors:
* - S-Core Co., Ltd
*
*/
-/*-----------------------------------------------------------------
-
-epoll server program by Sungmin Ha.
-Platform : Linux 2.6.x (kernel)
-compiler Gcc: 3.4.3.
-License: GNU General Public License
-
-------------------------------------------------------------------*/
#include "emuld_common.h"
#include "emuld.h"
#include "synbuf.h"
+#include "pmapi.h"
-
+#define PMAPI_RETRY_COUNT 3
#define MAX_CONNECT_TRY_COUNT (60 * 3)
#define SRV_IP "10.0.2.2"
unsigned short sap_port = SAP_PORT;
unsigned short sensord_port = SENSORD_PORT;
-int g_svr_port; /* global server port number */
+/* global server port number */
+int g_svr_port;
static int g_vm_connect_status; /* connection status between emuld and vmodem */
static int g_sap_connect_status;/* connection status between emuld and sap daemon */
-
pthread_t tid[MAX_CLIENT + 1];
-
/* udp socket */
struct sockaddr_in si_sensord_other;
-
-
int g_fd[fdtype_max];
-
typedef std::queue<msg_info*> __msg_queue;
__msg_queue g_msgqueue;
-
int g_epoll_fd;
static pthread_mutex_t mutex_vmconnect = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex_sapconnect = PTHREAD_MUTEX_INITIALIZER;
-struct epoll_event g_events[MAX_EVENTS];
+struct epoll_event g_events[MAX_EVENTS];
bool exit_flag = false;
-/*--------------------------------------------------------------*/
-/* FUNCTION PART
- *---------------------------------------------------------------*/
-
+/*----------------------------------------------------------------*/
+/* FUNCTION PART */
+/* ---------------------------------------------------------------*/
void systemcall(const char* param)
{
g_sap_connect_status = v;
}
-
-
-/*-------------------------------------------------------------
-function: init_server0
+/*-------------------------------------------------------------
+function: init_server0
io: input : integer - server port (must be positive)
output: none
desc : tcp/ip listening socket setting with input variable
}
LOG("[START] Now Server listening on port %d, EMdsockfd: %d"
,svr_port, fd);
-
+
/* notify to qemu that emuld is ready */
emuld_ready();
fail:
close(fd);
return false;
-}
+}
/*------------------------------- end of function init_server0 */
void emuld_ready()
fprintf(stderr, "send message to guest server\n");
while(sendto(s, buf, sizeof(buf), 0, (struct sockaddr*)&si_other, slen) == -1)
- {
+ {
fprintf(stderr, "sendto error! retry sendto\n");
usleep(1000);
}
fprintf(stderr, "emuld is ready.\n");
+
close(s);
}
void* init_vm_connect(void* data)
{
struct sockaddr_in vm_addr;
- int ret = -1;
- bool is_connected = false;
+ int ret = -1;
set_vm_connect_status(0);
}
/* Address Setting */
- memset( &vm_addr , 0 , sizeof(vm_addr)) ;
+ memset( &vm_addr , 0 , sizeof(vm_addr));
vm_addr.sin_family = AF_INET;
vm_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
LOG("connection failed to vmodem! try \n");
sleep(1);
}
- else
- {
- is_connected = true;
- }
}
epoll_ctl_add(g_fd[fdtype_vmodem]);
{
struct sockaddr_in sap_addr;
int ret = -1;
- bool is_connected = false;
set_sap_connect_status(0);
LOG("connection failed to sap! try \n");
sleep(1);
}
- else
- {
- is_connected = true;
- }
}
epoll_ctl_add(g_fd[fdtype_sap]);
pthread_exit((void *) 0);
}
-
bool epoll_ctl_add(const int fd)
{
struct epoll_event events;
}
LOG("vmodem data length: %d", ijcmd.msg.length);
- const int tmplen = HEADER_SIZE + ijcmd.msg.length;
+ const int tmplen = HEADER_SIZE + ijcmd.msg.length;
char* tmp = (char*) malloc(tmplen);
if (tmp)
}
}
-
void recv_from_ij(int fd)
{
printf("recv_from_ij\n");
exit(0);
}
+void set_lock_state() {
+ int i = 0;
+ // Now we blocking to enter "SLEEP".
+ while (i < PMAPI_RETRY_COUNT && pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0) == -1) {
+ ++i;
+ sleep(10);
+ }
+ if (i == PMAPI_RETRY_COUNT) {
+ fprintf(stderr, "Emulator Daemon: Failed to call pm_lock_state().\n");
+ }
+}
int main( int argc , char *argv[])
{
- int state;
+ int vm_state;
+ int sap_state;
- if(log_print == 1)
+ //if(log_print == 1)
{
// for emuld log file
systemcall("rm /var/log/emuld.log");
LOG("start");
/* entry , argument check and process */
if(argc < 3){
-
g_svr_port = DEFAULT_PORT;
-
}else {
-
- if(strcmp("-port",argv[1]) == 0 ) {
-
+ if(strcmp("-port", argv[1]) == 0 ) {
g_svr_port = atoi(argv[2]);
if(g_svr_port < 1024) {
fprintf(stderr, "[STOP] port number invalid : %d\n",g_svr_port);
close(g_epoll_fd);
exit(0);
}
-
-
udp_init();
+ set_lock_state();
+
bool is_exit = false;
while(!is_exit)
LOG("vmodem thread end %d\n", status);
}
- state = pthread_mutex_destroy(&mutex_vmconnect);
+ vm_state = pthread_mutex_destroy(&mutex_vmconnect);
+ if (vm_state != 0)
+ {
+ LOG("mutex_vmconnect is failed to destroy.");
+ }
if (!is_sap_connected())
{
LOG("sap thread end %d\n", status);
}
- state = pthread_mutex_destroy(&mutex_sapconnect);
+ sap_state = pthread_mutex_destroy(&mutex_sapconnect);
+ if (sap_state != 0)
+ {
+ LOG("mutex_vmconnect is failed to destroy.");
+ }
stop_listen();
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
/*
* emuld_proc.cpp
*
#include <stdlib.h>
#include <mntent.h>
-
char SDpath[256];
static struct timeval tv_start_poweroff;
-
struct setting_device_param
{
setting_device_param() : get_status_sockfd(-1), ActionID(0), is_evdi(false)
bool is_evdi;
};
-
-
char* get_mount_info() {
struct mntent *ent;
FILE *aFile;
//
if (ret == 0) {
- //ret = system("/usr/bin/sys_event mmcblk_add"); // sdcard is not supported
+ ret = system("/usr/bin/sys_event mmcblk_add");
}
break;
memset(SDpath, '\0', sizeof(SDpath));
sprintf(SDpath, "umounted");
- //ret = system("/usr/bin/sys_event mmcblk_remove"); // sdcard is not supported
+ ret = system("/usr/bin/sys_event mmcblk_remove");
break;
}
if (!param)
return false;
- memset(param, 0, sizeof(param));
+ memset(param, 0, sizeof(*param));
param->get_status_sockfd = sockfd;
param->ActionID = ijcmd->msg.action;
return true;
}
-
-
bool msgproc_sdcard(const int sockfd, ijcommand* ijcmd, const bool is_evdi)
{
LOG("msgproc_sdcard\n");
return true;
}
-
//sdcard event
void send_guest_server(char* databuf)
{
-/*\r
- * evdi.cpp\r
- *\r
- * Created on: 2013. 4. 15.\r
- * Author: dykim\r
- */\r
-\r
-#include "evdi.h"\r
-#include "emuld.h"\r
-\r
-#define DEVICE_NODE_PATH "/dev/evdi0"\r
-\r
-\r
-static pthread_mutex_t mutex_evdi = PTHREAD_MUTEX_INITIALIZER;\r
-\r
-\r
-evdi_fd open_device(void)\r
-{\r
- evdi_fd fd;\r
-\r
- fd = open(DEVICE_NODE_PATH, O_RDWR); //O_CREAT|O_WRONLY|O_TRUNC.\r
- printf("evdi open fd is %d", fd);\r
-\r
- if (fd <= 0) {\r
- printf("open %s fail", DEVICE_NODE_PATH);\r
- return fd;\r
- }\r
-\r
- return fd;\r
-}\r
-\r
-\r
-bool set_nonblocking(evdi_fd fd)\r
-{\r
- int opts;\r
- opts= fcntl(fd, F_GETFL);\r
- if (opts < 0)\r
- {\r
- perror("fcntl failed\n");\r
- return false;\r
- }\r
- opts = opts | O_NONBLOCK;\r
- if (fcntl(fd, F_SETFL, opts) < 0)\r
- {\r
- perror("fcntl failed\n");\r
- return false;\r
- }\r
- return true;\r
-}\r
-\r
-\r
-bool init_device(evdi_fd* ret_fd)\r
-{\r
- evdi_fd fd;\r
-\r
- *ret_fd = -1;\r
-\r
- fd = open_device();\r
- if (fd <= 0)\r
- return false;\r
-\r
- if (!set_nonblocking(fd))\r
- {\r
- close(fd);\r
- return false;\r
- }\r
-\r
- if (!epoll_ctl_add(fd))\r
- {\r
- fprintf(stderr, "Epoll control fails.\n");\r
- close(fd);\r
- return false;\r
- }\r
-\r
- *ret_fd = fd;\r
-\r
- return true;\r
-}\r
-\r
-\r
-bool send_to_evdi(evdi_fd fd, const char* data, const int len)\r
-{\r
- printf("send to evdi client, len = %d\n", len);\r
- int ret;\r
-\r
- ret = write(fd, data, len);\r
-\r
- printf("written bytes = %d\n", ret);\r
-\r
- if (ret == -1)\r
- return false;\r
- return true;\r
-}\r
-\r
-bool ijmsg_send_to_evdi(evdi_fd fd, const char* cat, const char* data, const int len)\r
-{\r
- _auto_mutex _(&mutex_evdi);\r
-\r
- LOG("ijmsg_send_to_evdi\n");\r
-\r
- if (fd == -1)\r
- return false;\r
-\r
- char tmp[ID_SIZE];\r
- memset(tmp, 0, ID_SIZE);\r
- strncpy(tmp, cat, 10);\r
-\r
- // TODO: need to make fragmented transmission\r
- if (len + ID_SIZE > __MAX_BUF_SIZE) {\r
- LOG("evdi message len is too large\n");\r
- return false;\r
- }\r
-\r
- msg_info _msg;\r
- memset(_msg.buf, 0, __MAX_BUF_SIZE);\r
- memcpy(_msg.buf, tmp, ID_SIZE);\r
- memcpy(_msg.buf + ID_SIZE, data, len);\r
-\r
- _msg.route = route_control_server;\r
- _msg.use = len + ID_SIZE;\r
- _msg.count = 1;\r
- _msg.index = 0;\r
- _msg.cclisn = 0;\r
-\r
- LOG("ijmsg_send_to_evdi - %s", _msg.buf);\r
-\r
- if (!send_to_evdi(fd, (char*) &_msg, sizeof(_msg)))\r
- return false;\r
-\r
- return true;\r
-}\r
-\r
-bool msg_send_to_evdi(evdi_fd fd, const char* data, const int len)\r
-{\r
- _auto_mutex _(&mutex_evdi);\r
-\r
- // TODO: need to make fragmented transmission\r
- if (len > __MAX_BUF_SIZE)\r
- {\r
- LOG("evdi message len is too large\n");\r
- return false;\r
- }\r
-\r
- msg_info _msg;\r
- memset(_msg.buf, 0, __MAX_BUF_SIZE);\r
- memcpy(_msg.buf, data, len);\r
-\r
- _msg.route = route_control_server;\r
- _msg.use = len;\r
- _msg.count = 1;\r
- _msg.index = 0;\r
- _msg.cclisn = 0;\r
-\r
- LOG("msg_send_to_evdi - %s", _msg.buf);\r
-\r
- if (!send_to_evdi(fd, (char*)&_msg, sizeof(_msg)))\r
- return false;\r
-\r
- return true;\r
-}\r
-\r
-\r
-\r
-\r
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#include "evdi.h"
+#include "emuld.h"
+
+#define DEVICE_NODE_PATH "/dev/evdi0"
+
+static pthread_mutex_t mutex_evdi = PTHREAD_MUTEX_INITIALIZER;
+
+evdi_fd open_device(void)
+{
+ evdi_fd fd;
+
+ fd = open(DEVICE_NODE_PATH, O_RDWR); //O_CREAT|O_WRONLY|O_TRUNC.
+ printf("evdi open fd is %d", fd);
+
+ if (fd <= 0) {
+ printf("open %s fail", DEVICE_NODE_PATH);
+ return fd;
+ }
+
+ return fd;
+}
+
+bool set_nonblocking(evdi_fd fd)
+{
+ int opts;
+ opts= fcntl(fd, F_GETFL);
+ if (opts < 0)
+ {
+ perror("fcntl failed\n");
+ return false;
+ }
+ opts = opts | O_NONBLOCK;
+ if (fcntl(fd, F_SETFL, opts) < 0)
+ {
+ perror("fcntl failed\n");
+ return false;
+ }
+ return true;
+}
+
+bool init_device(evdi_fd* ret_fd)
+{
+ evdi_fd fd;
+
+ *ret_fd = -1;
+
+ fd = open_device();
+ if (fd <= 0)
+ return false;
+
+ if (!set_nonblocking(fd))
+ {
+ close(fd);
+ return false;
+ }
+
+ if (!epoll_ctl_add(fd))
+ {
+ fprintf(stderr, "Epoll control fails.\n");
+ close(fd);
+ return false;
+ }
+
+ *ret_fd = fd;
+
+ return true;
+}
+
+bool send_to_evdi(evdi_fd fd, const char* data, const int len)
+{
+ printf("send to evdi client, len = %d\n", len);
+ int ret;
+
+ ret = write(fd, data, len);
+
+ printf("written bytes = %d\n", ret);
+
+ if (ret == -1)
+ return false;
+ return true;
+}
+
+bool ijmsg_send_to_evdi(evdi_fd fd, const char* cat, const char* data, const int len)
+{
+ _auto_mutex _(&mutex_evdi);
+
+ LOG("ijmsg_send_to_evdi\n");
+
+ if (fd == -1)
+ return false;
+
+ char tmp[ID_SIZE];
+ memset(tmp, 0, ID_SIZE);
+ strncpy(tmp, cat, 10);
+
+ // TODO: need to make fragmented transmission
+ if (len + ID_SIZE > __MAX_BUF_SIZE) {
+ LOG("evdi message len is too large\n");
+ return false;
+ }
+
+ msg_info _msg;
+ memset(_msg.buf, 0, __MAX_BUF_SIZE);
+ memcpy(_msg.buf, tmp, ID_SIZE);
+ memcpy(_msg.buf + ID_SIZE, data, len);
+
+ _msg.route = route_control_server;
+ _msg.use = len + ID_SIZE;
+ _msg.count = 1;
+ _msg.index = 0;
+ _msg.cclisn = 0;
+
+ LOG("ijmsg_send_to_evdi - %s", _msg.buf);
+
+ if (!send_to_evdi(fd, (char*) &_msg, sizeof(_msg)))
+ return false;
+
+ return true;
+}
+
+bool msg_send_to_evdi(evdi_fd fd, const char* data, const int len)
+{
+ _auto_mutex _(&mutex_evdi);
+
+ // TODO: need to make fragmented transmission
+ if (len > __MAX_BUF_SIZE)
+ {
+ LOG("evdi message len is too large\n");
+ return false;
+ }
+
+ msg_info _msg;
+ memset(_msg.buf, 0, __MAX_BUF_SIZE);
+ memcpy(_msg.buf, data, len);
+
+ _msg.route = route_control_server;
+ _msg.use = len;
+ _msg.count = 1;
+ _msg.index = 0;
+ _msg.cclisn = 0;
+
+ LOG("msg_send_to_evdi - %s", _msg.buf);
+
+ if (!send_to_evdi(fd, (char*)&_msg, sizeof(_msg)))
+ return false;
+
+ return true;
+}
+
/*
* emulator-daemon
*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* SooYoung Ha <yoosah.ha@samsnung.com>
static int inline get_message(char* message, int status, int buf_len, bool is_evdi)
{
- if (is_evdi) {
- sprintf(message, "%d", status);
- return strlen(message);
- } else {
- // int to byte
- message[3] = (char) (status & 0xff);
- message[2] = (char) (status >> 8 & 0xff);
- message[1] = (char) (status >> 16 & 0xff);
- message[0] = (char) (status >> 24 & 0xff);
- message[4] = '\0';
- }
-
- return 4;
+ if (is_evdi) {
+ sprintf(message, "%d", status);
+ return strlen(message);
+ } else {
+ // int to byte
+ message[3] = (char) (status & 0xff);
+ message[2] = (char) (status >> 8 & 0xff);
+ message[1] = (char) (status >> 16 & 0xff);
+ message[0] = (char) (status >> 24 & 0xff);
+ message[4] = '\0';
+ }
+
+ return 4;
}
static int inline get_status(const char* filename)
{
- int ret;
- int status = 0;
- FILE* fd = fopen(filename, "r");
- if(!fd)
- return -1;
-
- ret = fscanf(fd, "%d", &status);
- fclose(fd);
-
- if (ret < 0) {
- return ret;
- }
-
- return status;
+ int ret;
+ int status = 0;
+ FILE* fd = fopen(filename, "r");
+ if(!fd)
+ return -1;
+
+ ret = fscanf(fd, "%d", &status);
+ fclose(fd);
+
+ if (ret < 0) {
+ return ret;
+ }
+
+ return status;
}
static int inline get_file_status(char* msg, const char* filename, int buf_len, bool is_evdi)
{
- int status = get_status(filename);
- if (status < 0)
- return status;
- return get_message(msg, status, buf_len, is_evdi);
+ int status = get_status(filename);
+ if (status < 0)
+ return status;
+ return get_message(msg, status, buf_len, is_evdi);
}
static int inline get_vconf_status(char* msg, const char* key, int buf_len, bool is_evdi)
{
- int status;
- int ret = vconf_get_int(key, &status);
- if (ret != 0) {
- //LOG("cannot get vconf key - %s", key);
- return -1;
- }
-
- return get_message(msg, status, buf_len, is_evdi);
+ int status;
+ int ret = vconf_get_int(key, &status);
+ if (ret != 0) {
+ //LOG("cannot get vconf key - %s", key);
+ return -1;
+ }
+
+ return get_message(msg, status, buf_len, is_evdi);
}
char* __tmpalloc(const int size)
{
- char* message = (char*)malloc(sizeof(char) * size);
- memset(message, 0, sizeof(char) * size);
- return message;
+ char* message = (char*)malloc(sizeof(char) * size);
+ memset(message, 0, sizeof(char) * size);
+ return message;
}
char* get_usb_status(void* p, bool is_evdi)
{
- char* message = __tmpalloc(5);
- int length = get_file_status(message, "/sys/devices/platform/jack/usb_online", 5, is_evdi);
- if (length < 0){
- //LOG("get usb status error - %d", length);
- length = 0;
- }
-
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = length;
- packet->group = STATUS;
- packet->action = USB_STATUS;
-
- return message;
+ char* message = __tmpalloc(5);
+ int length = get_file_status(message, "/sys/devices/platform/jack/usb_online", 5, is_evdi);
+ if (length < 0){
+ //LOG("get usb status error - %d", length);
+ length = 0;
+ }
+
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = length;
+ packet->group = STATUS;
+ packet->action = USB_STATUS;
+
+ return message;
}
char* get_earjack_status(void* p, bool is_evdi)
{
- char* message = __tmpalloc(5);
- int length = get_file_status(message, "/sys/devices/platform/jack/earjack_online", 5, is_evdi);
- if (length < 0){
- return 0;
- }
-
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = length;
- packet->group = STATUS;
- packet->action = EARJACK_STATUS;
-
- return message;
+ char* message = __tmpalloc(5);
+ int length = get_file_status(message, "/sys/devices/platform/jack/earjack_online", 5, is_evdi);
+ if (length < 0){
+ return 0;
+ }
+
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = length;
+ packet->group = STATUS;
+ packet->action = EARJACK_STATUS;
+
+ return message;
}
char* get_rssi_level(void* p, bool is_evdi)
{
- char* message = __tmpalloc(5);
- int length = get_vconf_status(message, "memory/telephony/rssi", 5, is_evdi);
- if (length < 0){
- return 0;
- }
-
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = length;
- packet->group = STATUS;
- packet->action = RSSI_LEVEL;
-
- return message;
+ char* message = __tmpalloc(5);
+ int length = get_vconf_status(message, "memory/telephony/rssi", 5, is_evdi);
+ if (length < 0){
+ return 0;
+ }
+
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = length;
+ packet->group = STATUS;
+ packet->action = RSSI_LEVEL;
+
+ return message;
}
char* get_battery_level(void* p, bool is_evdi)
{
- char* message = __tmpalloc(5);
- int length = get_file_status(message, "/sys/class/power_supply/battery/capacity", 5, is_evdi);
- if (length < 0){
- return 0;
- }
-
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = length;
- packet->group = STATUS;
- packet->action = BATTERY_LEVEL;
-
- return message;
+ char* message = __tmpalloc(5);
+ int length = get_file_status(message, "/sys/class/power_supply/battery/capacity", 5, is_evdi);
+ if (length < 0){
+ return 0;
+ }
+
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = length;
+ packet->group = STATUS;
+ packet->action = BATTERY_LEVEL;
+
+ return message;
}
char* get_battery_charger(void* p, bool is_evdi)
{
- char* message = __tmpalloc(5);
- int length = get_file_status(message, "/sys/class/power_supply/battery/charge_now", 5, is_evdi);
- if (length < 0){
- return 0;
- }
-
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = length;
- packet->group = STATUS;
- packet->action = BATTERY_CHARGER;
-
- return message;
+ char* message = __tmpalloc(5);
+ int length = get_file_status(message, "/sys/class/power_supply/battery/charge_now", 5, is_evdi);
+ if (length < 0){
+ return 0;
+ }
+
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = length;
+ packet->group = STATUS;
+ packet->action = BATTERY_CHARGER;
+
+ return message;
}
char* get_proximity_status(void* p, bool is_evdi)
{
- char* message = __tmpalloc(5);
- int length = get_file_status(message, PATH_SENSOR_PROXI_VO, 5, is_evdi);
- if (length < 0){
- return 0;
- }
-
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = length;
- packet->group = STATUS;
- packet->action = PROXI_VALUE;
-
- return message;
+ char* message = __tmpalloc(5);
+ int length = get_file_status(message, PATH_SENSOR_PROXI_VO, 5, is_evdi);
+ if (length < 0){
+ return 0;
+ }
+
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = length;
+ packet->group = STATUS;
+ packet->action = PROXI_VALUE;
+
+ return message;
}
char* get_light_level(void* p, bool is_evdi)
{
- char* message = __tmpalloc(6);
- int length = get_file_status(message, PATH_SENSOR_LIGHT_ADC, 6, is_evdi);
- if (length < 0){
- return 0;
- }
-
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = length;
- packet->group = STATUS;
- packet->action = LIGHT_VALUE;
-
- return message;
+ char* message = __tmpalloc(6);
+ int length = get_file_status(message, PATH_SENSOR_LIGHT_ADC, 6, is_evdi);
+ if (length < 0){
+ return 0;
+ }
+
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = length;
+ packet->group = STATUS;
+ packet->action = LIGHT_VALUE;
+
+ return message;
}
char* get_acceleration_value(void* p, bool is_evdi)
{
- FILE* fd = fopen(PATH_SENSOR_ACCEL_XYZ, "r");
- if(!fd)
- {
- return 0;
- }
+ FILE* fd = fopen(PATH_SENSOR_ACCEL_XYZ, "r");
+ if(!fd)
+ {
+ return 0;
+ }
- char* message = __tmpalloc(128);
+ char* message = __tmpalloc(128);
- //fscanf(fd, "%d, %d, %d", message);
- if (!fgets(message, 128, fd))
- fprintf(stderr, "fgets failure");
+ //fscanf(fd, "%d, %d, %d", message);
+ if (!fgets(message, 128, fd))
+ fprintf(stderr, "fgets failure");
- fclose(fd);
+ fclose(fd);
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = strlen(message);
- packet->group = STATUS;
- packet->action = ACCEL_VALUE;
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = strlen(message);
+ packet->group = STATUS;
+ packet->action = ACCEL_VALUE;
- return message;
+ return message;
}
char* get_gyroscope_value(void* p, bool is_evdi)
{
- int x, y, z;
- int ret;
-
- FILE* fd = fopen(PATH_SENSOR_GYRO_X_RAW, "r");
- if(!fd)
- {
- return 0;
- }
- ret = fscanf(fd, "%d", &x);
- fclose(fd);
-
- fd = fopen(PATH_SENSOR_GYRO_Y_RAW, "r");
- if(!fd)
- {
- return 0;
- }
- ret = fscanf(fd, "%d", &y);
- fclose(fd);
-
- fd = fopen(PATH_SENSOR_GYRO_Z_RAW, "r");
- if(!fd)
- {
- return 0;
- }
- ret = fscanf(fd, "%d", &z);
- fclose(fd);
-
- char* message = __tmpalloc(128);
-
- ret = sprintf(message, "%d, %d, %d", x, y, z);
- if (ret < 0) {
- free(message);
- message = 0;
- return 0;
- }
-
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = strlen(message);
- packet->group = STATUS;
- packet->action = GYRO_VALUE;
-
- return message;
+ int x, y, z;
+ int ret;
+
+ FILE* fd = fopen(PATH_SENSOR_GYRO_X_RAW, "r");
+ if(!fd)
+ {
+ return 0;
+ }
+ ret = fscanf(fd, "%d", &x);
+ fclose(fd);
+
+ fd = fopen(PATH_SENSOR_GYRO_Y_RAW, "r");
+ if(!fd)
+ {
+ return 0;
+ }
+ ret = fscanf(fd, "%d", &y);
+ fclose(fd);
+
+ fd = fopen(PATH_SENSOR_GYRO_Z_RAW, "r");
+ if(!fd)
+ {
+ return 0;
+ }
+ ret = fscanf(fd, "%d", &z);
+ fclose(fd);
+
+ char* message = __tmpalloc(128);
+
+ ret = sprintf(message, "%d, %d, %d", x, y, z);
+ if (ret < 0) {
+ free(message);
+ message = 0;
+ return 0;
+ }
+
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = strlen(message);
+ packet->group = STATUS;
+ packet->action = GYRO_VALUE;
+
+ return message;
}
char* get_magnetic_value(void* p, bool is_evdi)
{
- FILE* fd = fopen(PATH_SENSOR_GEO_TESLA, "r");
- if(!fd)
- {
- return 0;
- }
-
- char* message = __tmpalloc(128);
- if (!fgets(message, 128, fd))
- {
- fprintf(stderr, "fgets failure");
- }
- fclose(fd);
-
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = strlen(message);
- packet->group = STATUS;
- packet->action = MAG_VALUE;
- return message;
+ FILE* fd = fopen(PATH_SENSOR_GEO_TESLA, "r");
+ if(!fd)
+ {
+ return 0;
+ }
+
+ char* message = __tmpalloc(128);
+ if (!fgets(message, 128, fd))
+ {
+ fprintf(stderr, "fgets failure");
+ }
+ fclose(fd);
+
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = strlen(message);
+ packet->group = STATUS;
+ packet->action = MAG_VALUE;
+ return message;
}
char* get_location_status(void* p, bool is_evdi)
{
- int mode;
- int ret = vconf_get_int("db/location/replay/ReplayMode", &mode);
- if (ret != 0) {
- return 0;
- }
-
- char* message = 0;
-
- if (mode == 0)
- { // STOP
- message = (char*)malloc(5);
- memset(message, 0, 5);
-
- ret = sprintf(message, "%d", mode);
- if (ret < 0) {
- free(message);
- message = 0;
- return 0;
- }
- }
- else if (mode == 1)
- { // NMEA MODE(LOG MODE)
- char* temp = 0;
- temp = (char*) vconf_get_str("db/location/replay/FileName");
- if (temp == 0) {
- //free(temp);
- return 0;
- }
-
- message = (char*)malloc(256);
- memset(message, 0, 256);
- ret = sprintf(message, "%d,%s", mode, temp);
- if (ret < 0) {
- free(message);
- message = 0;
- return 0;
- }
- } else if (mode == 2) { // MANUAL MODE
- double latitude;
- double logitude;
- ret = vconf_get_dbl("db/location/replay/ManualLatitude", &latitude);
- if (ret != 0) {
- return 0;
- }
- ret = vconf_get_dbl("db/location/replay/ManualLongitude", &logitude);
- if (ret != 0) {
- return 0;
- }
- message = (char*)malloc(128);
- memset(message, 0, 128);
- ret = sprintf(message, "%d,%f,%f", mode, latitude, logitude);
- if (ret < 0) {
- free(message);
- message = 0;
- return 0;
- }
- }
-
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = strlen(message);
- packet->group = STATUS;
- packet->action = LOCATION_STATUS;
-
- return message;
+ int mode;
+ int ret = vconf_get_int("db/location/replay/ReplayMode", &mode);
+ if (ret != 0) {
+ return 0;
+ }
+
+ char* message = 0;
+
+ if (mode == 0)
+ { // STOP
+ message = (char*)malloc(5);
+ memset(message, 0, 5);
+
+ ret = sprintf(message, "%d", mode);
+ if (ret < 0) {
+ free(message);
+ message = 0;
+ return 0;
+ }
+ }
+ else if (mode == 1)
+ { // NMEA MODE(LOG MODE)
+ char* temp = 0;
+ temp = (char*) vconf_get_str("db/location/replay/FileName");
+ if (temp == 0) {
+ //free(temp);
+ return 0;
+ }
+
+ message = (char*)malloc(256);
+ memset(message, 0, 256);
+ ret = sprintf(message, "%d,%s", mode, temp);
+ if (ret < 0) {
+ free(message);
+ message = 0;
+ return 0;
+ }
+ } else if (mode == 2) { // MANUAL MODE
+ double latitude;
+ double logitude;
+ ret = vconf_get_dbl("db/location/replay/ManualLatitude", &latitude);
+ if (ret != 0) {
+ return 0;
+ }
+ ret = vconf_get_dbl("db/location/replay/ManualLongitude", &logitude);
+ if (ret != 0) {
+ return 0;
+ }
+ message = (char*)malloc(128);
+ memset(message, 0, 128);
+ ret = sprintf(message, "%d,%f,%f", mode, latitude, logitude);
+ if (ret < 0) {
+ free(message);
+ message = 0;
+ return 0;
+ }
+ }
+
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = strlen(message);
+ packet->group = STATUS;
+ packet->action = LOCATION_STATUS;
+
+ return message;
}
char* get_nfc_status(void* p, bool is_evdi)
{
- int ret;
- FILE* fd = fopen(PATH_NFC_DATA, "r");
- if(!fd)
- {
- return 0;
- }
-
- char* message = __tmpalloc(5000);
- ret = fscanf(fd, "%s\n", message);
- fclose(fd);
-
- LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
- memset(packet, 0, sizeof(LXT_MESSAGE));
- packet->length = strlen(message);
- packet->group = STATUS;
- packet->action = NFC_STATUS;
-
- return message;
+ int ret;
+ FILE* fd = fopen(PATH_NFC_DATA, "r");
+ if(!fd)
+ {
+ return 0;
+ }
+
+ char* message = __tmpalloc(5000);
+ ret = fscanf(fd, "%s\n", message);
+ if (ret < 0)
+ {
+ return 0;
+ }
+ fclose(fd);
+
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = strlen(message);
+ packet->group = STATUS;
+ packet->action = NFC_STATUS;
+
+ return message;
}
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Jinhyung Choi <jinhyung2.choi@samsnung.com>
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * Daiyoung Kim <daiyoung777.kim@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
#include <stdio.h>
#include <stdlib.h>
struct emuld_log
{
- emuld_log()
- {
- m_isLogout = false;
-
- char* buf = getenv("EMULD_LOG");
- if (buf != NULL) {
- fprintf(stdout, "env EMULD_LOG is set => print logs \n");
- m_isLogout = true;
- }
- }
-
- void out_v(const char *fmt, ...)
- {
- if (m_isLogout)
- {
- char buf[4096];
- va_list ap;
-
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
-
- fprintf(stdout, "%s", buf);
- FILE* log_fd = fopen("/var/log/emuld.log", "a");
- fprintf(log_fd, "%s", buf);
- fclose(log_fd);
- }
- }
-
- void out(const char* outbuf)
- {
- if (!m_isLogout)
- return;
-
- char timestr[512];
- make_timestamp(timestr);
- fprintf(stdout, "%s - %s", timestr, outbuf);
- FILE* log_fd = fopen("/var/log/emuld.log", "a");
- fprintf(log_fd, "%s - %s", timestr, outbuf);
- fclose(log_fd);
- }
-
- bool m_isLogout;
+ emuld_log()
+ {
+ m_isLogout = false;
+
+ char* buf = getenv("EMULD_LOG");
+ if (buf != NULL) {
+ fprintf(stdout, "env EMULD_LOG is set => print logs \n");
+ m_isLogout = true;
+ }
+ }
+
+ void out_v(const char *fmt, ...)
+ {
+ if (m_isLogout)
+ {
+ char buf[4096];
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+
+ fprintf(stdout, "%s", buf);
+ FILE* log_fd = fopen("/var/log/emuld.log", "a");
+ fprintf(log_fd, "%s", buf);
+ fclose(log_fd);
+ }
+ }
+
+ void out(const char* outbuf)
+ {
+ if (!m_isLogout)
+ return;
+
+ char timestr[512];
+ make_timestamp(timestr);
+ fprintf(stdout, "%s - %s", timestr, outbuf);
+ FILE* log_fd = fopen("/var/log/emuld.log", "a");
+ fprintf(log_fd, "%s - %s", timestr, outbuf);
+ fclose(log_fd);
+ }
+
+ bool m_isLogout;
};
#ifdef EMD_DEBUG
- char buf[4096];
- va_list ap;
+ char buf[4096];
+ va_list ap;
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
- g_log.out(buf);
+ g_log.out(buf);
#endif
- return;
+ return;
}
void make_timestamp(char* ret)