4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
7 * Sooyoung Ha <yoosah.ha@samsung.com>
8 * Sungmin Ha <sungmin82.ha@samsung.com>
9 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
11 * This library is free software; you can redistribute it and/or modify it under
12 * the terms of the GNU Lesser General Public License as published by the
13 * Free Software Foundation; either version 2.1 of the License, or (at your option)
16 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
17 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19 * License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this library; if not, write to the Free Software Foundation, Inc., 51
23 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 // ++++++++++++++++++++++++++++++++++++++++++++++include about standard library
36 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++include user define
38 #include "linuxtapi.h"
43 #include "libvgsm_debug.h"
44 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++define area
46 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++global variable area
48 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++define public function
51 int lxt_util_readRawBytes(int fd, void *data, int size)
56 if ( (data == 0) || (fd < 0) )
58 #ifndef _NO_ESPRESSO_DEBUG_
59 LIBVGSM_DEBUG("Source Invalid \n");
60 #endif // _NO_ESPRESSO_DEBUG_
65 rc = read(fd, data, size);
69 #ifndef _NO_ESPRESSO_DEBUG_
70 fprintf(stderr,"File read error:%s\n",strerror(errno));
71 LIBVGSM_DEBUG("Read Fail and size=%d, rc=%d\n",size,rc);
72 #endif // _NO_ESPRESSO_DEBUG_
77 #ifndef _NO_ESPRESSO_DEBUG_
85 int lxt_util_writeRawBytes(int fd, const void *data, int size)
89 LIBVGSM_DEBUG("%s\n", __FUNCTION__);
92 if ( (data == 0) || (fd < 0) )
94 #ifndef _NO_ESPRESSO_DEBUG_
95 LIBVGSM_DEBUG("Source Invalid\n");
96 #endif // _NO_ESPRESSO_DEBUG_
101 rc = write(fd, data, size);
105 #ifndef _NO_ESPRESSO_DEBUG_
106 LIBVGSM_DEBUG("Write Failed\n");
107 #endif // _NO_ESPRESSO_DEBUG_
112 #ifndef _NO_ESPRESSO_DEBUG_
120 void lxt_util_rawdataPrint(void *rawdata, int rawdatasize, const char *title)
126 LIBVGSM_DEBUG("%s\n", __FUNCTION__);
128 if ( (rawdatasize > 0) && (rawdata == NULL) )
136 p = (unsigned char *)rawdata;
141 for (i = 0; i < len; i++)
145 printf("%02x ", p[i]);
151 // tx data to phone server
152 int lxt_msg_send_to_server(int fd, const void *data, int size)
156 LIBVGSM_DEBUG("%s\n", __FUNCTION__);
159 if ( (data == 0) || (fd < 0) )
162 // tx to phone server
163 rc = lxt_util_writeRawBytes(fd, data, size);
168 // tx lxt messge to server
169 int lxt_msg_send_message(int fd, unsigned char g, unsigned char a, unsigned int len, const void *data)
174 LIBVGSM_DEBUG("lxt_msg_send_message : fd=%d, total size = 4+%d \n",fd, len);
185 // tx to phone server
186 rc = lxt_msg_send_to_server(fd, &packet, 4);
189 printf("[ %s ] [WARNING] write fail : rc = %d \n", __FUNCTION__, rc);
193 // tx to phone server if exists data
194 rc = lxt_msg_send_to_server(fd, data, len);
196 printf("[ %s ] [WARNING] write fail : rc = %d \n", __FUNCTION__, rc);