From ca1143ad5a804499f151ff05a010fb7a2aca2dfd Mon Sep 17 00:00:00 2001 From: Ko Hayoon Date: Thu, 6 Sep 2012 00:58:16 +0900 Subject: [PATCH] nonblocking modem-plugin initialization logic added Change-Id: I23a5cf2eabb99314d47f624441c3754d9bb56c82 --- packaging/tel-plugin-imcmodem.spec | 2 +- src/desc-imcmodem.c | 17 +++++++++++++++-- src/vnet.c | 25 +++++++------------------ 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/packaging/tel-plugin-imcmodem.spec b/packaging/tel-plugin-imcmodem.spec index e47a066..008db59 100755 --- a/packaging/tel-plugin-imcmodem.spec +++ b/packaging/tel-plugin-imcmodem.spec @@ -1,7 +1,7 @@ #sbs-git:slp/pkgs/t/tel-plugin-imcmodem Name: tel-plugin-imcmodem Summary: telephony plugin library for AT communication with IMC modem -Version: 0.1.1 +Version: 0.1.2 Release: 1 Group: System/Libraries License: Apache diff --git a/src/desc-imcmodem.c b/src/desc-imcmodem.c index 7a60133..48f6961 100755 --- a/src/desc-imcmodem.c +++ b/src/desc-imcmodem.c @@ -229,17 +229,28 @@ static gboolean _power_on( gpointer data ) struct custom_data *user_data = 0; TcoreHal *h = (TcoreHal*)data; gboolean ret = 0; + static int count = 0; user_data = tcore_hal_ref_user_data(h); if (!user_data) { dbg("[ error ] tcore_hal_ref_user_data()"); - return FALSE; + return TRUE; } + count++; + ret = _ipc0_init( h, &user_data->ipc0, on_recv_ipc_message ); - if ( !ret ) + if ( !ret ) { dbg("[ error ] _ipc0_init()"); + if ( count > 20 ) { + dbg("[ error ] _ipc0_init() timeout"); + return FALSE; + } + + return TRUE; + } + tcore_hal_set_power_state(h, TRUE); return FALSE; @@ -379,6 +390,8 @@ static gboolean on_init(TcorePlugin *p) * HAL init */ h = tcore_hal_new(p, "6262", &hops, TCORE_HAL_MODE_AT); + + tcore_hal_set_power_state(h, FALSE); tcore_hal_link_user_data(h, data); return TRUE; diff --git a/src/vnet.c b/src/vnet.c index 4255131..5178b90 100755 --- a/src/vnet.c +++ b/src/vnet.c @@ -125,26 +125,15 @@ int vnet_ipc0_open() return -1; } - while ( 1 ) { - - state = vnet_get_cp_state( fd ); - - if ( (enum vnet_cp_state)state != VNET_CP_STATE_ONLINE ) { - usleep(500000); - - } else { - fd = open ( VNET_CH_PATH_IPC0, O_RDWR ); - if ( fd < 0 ) { - dbg("error : open [ %s ] [ %s ]", VNET_CH_PATH_IPC0, strerror(errno)); + state = vnet_get_cp_state( fd ); + if ( (enum vnet_cp_state)state != VNET_CP_STATE_ONLINE ) { + return -1; + } else { + fd = open ( VNET_CH_PATH_IPC0, O_RDWR ); + if ( fd < 0 ) { + dbg("error : open [ %s ] [ %s ]", VNET_CH_PATH_IPC0, strerror(errno)); return -1; - } - - break ; } - - if ( ++cnt > 20 ) - return -1; } - return fd; } -- 2.7.4