Exemple #1
0
int eng_linuxcmd_gsnw(char *req, char *rsp)
{
    char address[64];
    char *ptr=NULL;
    char *endptr=NULL;
    int length;

    ENG_LOG("%s: req=%s\n",__FUNCTION__, req);

    ptr = strchr(req, '"');
    if(ptr == NULL){
        ENG_LOG("%s: req %s ERROR no start \"\n",__FUNCTION__, req);
        return -1;
    }

    ptr++;

    endptr = strchr(ptr, '"');
    if(endptr == NULL){
        ENG_LOG("%s: req %s ERROR no end \"\n",__FUNCTION__, req);
        return -1;
    }

    length = endptr - ptr + 1;

    memset(address, 0, sizeof(address));
    snprintf(address, length, "%s", ptr);

    ENG_LOG("%s: GSN is %s; length=%d\n",__FUNCTION__, address, length);

    eng_sql_string2string_set("gsn", address);
    sprintf(rsp, "%s%s", SPRDENG_OK, ENG_STREND);
    return 0;
}
Exemple #2
0
int eng_linuxcmd_getich(char *req, char *rsp)
{
    int fd, ret = 1;
    int current;
    char buffer[16];
    int len = 0;

    fd = open(ENG_CURRENT, O_RDONLY);
    if(fd < 0){
        ENG_LOG("%s: open %s fail [%s]",__FUNCTION__, ENG_BATVOL, strerror(errno));
        ret = 0;
    }

    if(ret==1) {
        memset(buffer, 0, sizeof(buffer));
        len = read(fd, buffer, sizeof(buffer));
        if(len > 0){
            current = atoi(buffer);
            ENG_LOG("%s: buffer=%s; current=%d\n",__FUNCTION__, buffer, current);
            sprintf(rsp, "%dmA%s%s%s", current, ENG_STREND, SPRDENG_OK, ENG_STREND);
        }else {
            ENG_LOG("%s: ERROR\n",__FUNCTION__);
            sprintf(rsp, "%s%s", SPRDENG_ERROR, ENG_STREND);
        }
    } else {
        ENG_LOG("%s: ERROR\n",__FUNCTION__);
        sprintf(rsp, "%s%s", SPRDENG_ERROR, ENG_STREND);
    }

    if(fd >= 0)
        close(fd);

    ENG_LOG("%s: rsp=%s\n",__FUNCTION__,rsp);
    return 0;
}
Exemple #3
0
int eng_linuxcmd_vbat(char *req, char *rsp)
{
    int fd, ret = 1, len = 0;
    int voltage;
    float vol;
    char buffer[16];

    fd = open(ENG_BATVOL, O_RDONLY);
    if(fd < 0){
        ENG_LOG("%s: open %s fail [%s]",__FUNCTION__, ENG_BATVOL, strerror(errno));
        ret = 0;
    }

    if(ret==1) {
        memset(buffer, 0, sizeof(buffer));
        len = read(fd, buffer, sizeof(buffer));
        if(len > 0){
            voltage = atoi(buffer);
            ENG_LOG("%s: buffer=%s; voltage=%d\n",__FUNCTION__, buffer, voltage);
            vol = ((float) voltage) * 0.001;
            sprintf(rsp, "%.3g%s%s%s", vol, ENG_STREND, SPRDENG_OK, ENG_STREND);
        }else {
            sprintf(rsp, "%s%s", SPRDENG_ERROR, ENG_STREND);
        }
    } else {
        sprintf(rsp, "%s%s", SPRDENG_ERROR, ENG_STREND);
    }

    if(fd >= 0)
        close(fd);

    ENG_LOG("%s: rsp=%s\n",__FUNCTION__,rsp);
    return 0;
}
Exemple #4
0
int eng_linuxcmd_stopchg(char *req, char *rsp)
{
    int fd;
    int ret = 1;
    char ok[]="1";
    fd = open(ENG_STOPCHG, O_WRONLY);

    if(fd < 0){
        ENG_LOG("%s: open %s fail [%s]",__FUNCTION__, ENG_BATVOL, strerror(errno));
        ret = 0;
    }

    if(ret == 1) {
        ret=write(fd, ok, strlen(ok));
        if (ret < 0)
            sprintf(rsp, "%s%s", SPRDENG_ERROR, ENG_STREND);
        else
            sprintf(rsp, "%s%s", SPRDENG_OK, ENG_STREND);
    } else {
        sprintf(rsp, "%s%s", SPRDENG_ERROR, ENG_STREND);
    }

    if(fd >= 0)
        close(fd);
    ENG_LOG("%s: rsp=%s\n",__FUNCTION__,rsp);
    return 0;
}
Exemple #5
0
int eng_ascii2hex(char *inputdata, unsigned char *outputdata, int inputdatasize)
{
    int i,j,tmp_len;
    unsigned char tmpData;
    char *ascii_data = inputdata;
    unsigned char *hex_data = outputdata;
    for(i = 0; i < inputdatasize; i++){
        if ((ascii_data[i] >= '0') && (ascii_data[i] <= '9')){
            tmpData = ascii_data[i] - '0';
        }
        else if ((ascii_data[i] >= 'A') && (ascii_data[i] <= 'F')){ //A....F
            tmpData = ascii_data[i] - 'A' + 10;
        }
        else if((ascii_data[i] >= 'a') && (ascii_data[i] <= 'f')){ //a....f
            tmpData = ascii_data[i] - 'a' + 10;
        }
        else{
            break;
        }
        ascii_data[i] = tmpData;
    }

    for(tmp_len = 0,j = 0; j < i; j+=2) {
        outputdata[tmp_len++] = (ascii_data[j]<<4) | ascii_data[j+1];
    }

    ENG_LOG("%s: length=%d",__FUNCTION__, tmp_len);
    for(i=0; i<tmp_len; i++)
        ENG_LOG("%s [%d]: 0x%x",__FUNCTION__, i, hex_data[i]);

    return tmp_len;
}
Exemple #6
0
int eng_linuxcmd_keypad(char *req, char *rsp)
{
    int ret = 0, fd;
    char *keycode;
    ENG_LOG("%s: req=%s\n",__FUNCTION__, req);

    keycode = strchr(req, '=');

    if(keycode == NULL) {
        sprintf(rsp, "%s%s", SPRDENG_ERROR, ENG_STREND);
        ret = -1;
    } else {
        keycode++;
        ENG_LOG("%s: keycode = %s\n",__FUNCTION__, keycode);
        fd = open(ENG_KEYPAD_PATH, O_RDWR);
        if(fd >= 0) {
            ENG_LOG("%s: send keycode to emulator\n",__FUNCTION__);
            write(fd, keycode, strlen(keycode));
        } else {
            ENG_LOG("%s: open %s fail [%s]\n",__FUNCTION__, ENG_KEYPAD_PATH, strerror(errno));
        }
        if(fd >= 0)
            close(fd);
        sprintf(rsp, "%s%s", SPRDENG_OK, ENG_STREND);
        ret = 0;
    }

    return ret;
}
Exemple #7
0
int eng_linuxcmd_infactorymode(char *req, char *rsp)
{
    char *ptr;
    int status;
    int length=strlen(req);
    ENG_LOG("%s: req=%s\n",__FUNCTION__, req);
    if((ptr=strchr(req, '?'))!= NULL){
        status = eng_sql_string2int_get(ENG_TESTMODE);
        if(status==ENG_SQLSTR2INT_ERR)
            status = 1;
        sprintf(rsp, "%d%s%s%s", status, ENG_STREND,SPRDENG_OK,ENG_STREND);
    } else if ((ptr=strchr(req, '='))!= NULL) {
        ptr++;
        if(ptr <= (req+length)) {
            status = atoi(ptr);
            ENG_LOG("%s: status=%d\n",__FUNCTION__, status);
            if(status==0||status==1) {
                eng_sql_string2int_set(ENG_TESTMODE, status);
                eng_check_factorymode(0);
                sprintf(rsp, "%s\r\n", SPRDENG_OK);
            } else {
                sprintf(rsp, "%s\r\n", SPRDENG_ERROR);
            }
        } else {
            sprintf(rsp, "%s\r\n", SPRDENG_ERROR);
        }
    } else {
        sprintf(rsp, "%s\r\n", SPRDENG_ERROR);
    }
    ENG_LOG("%s: rsp=%s\n",__FUNCTION__, rsp);

    return 0;
}
static int start_gser(char* ser_path)
{
    struct termios ser_settings;

    if (pc_fd>=0){
        ENG_LOG("%s ERROR : %s\n", __FUNCTION__, strerror(errno));
        close(pc_fd);
    }

    ENG_LOG("open serial\n");
    pc_fd = open(ser_path,O_RDWR);
    if(pc_fd < 0) {
        ENG_LOG("cannot open vendor serial\n");
        return -1;
    }

    tcgetattr(pc_fd, &ser_settings);
    cfmakeraw(&ser_settings);

    ser_settings.c_lflag |= (ECHO | ECHONL);
    ser_settings.c_lflag &= ~ECHOCTL;
    tcsetattr(pc_fd, TCSANOW, &ser_settings);

    return 0;
}
static void *eng_readmodemat_thread(void *par)
{
    int ret;
    int len;
    char engbuf[ENG_BUFFER_SIZE];
    eng_dev_info_t* dev_info = (eng_dev_info_t*)par;

    for(;;){
        ENG_LOG("%s: wait pcfd=%d\n",__func__,pc_fd);
        memset(engbuf, 0, ENG_BUFFER_SIZE);
        len = read(at_mux_fd, engbuf, ENG_BUFFER_SIZE);
        ENG_LOG("muxfd =%d buf=%s,len=%d\n",at_mux_fd,engbuf,len);
        if (len <= 0) {
            ENG_LOG("%s: read length error %s\n",__FUNCTION__,strerror(errno));
            sleep(1);
            continue;
        }else{
write_again:
            if (pc_fd>=0){
                ret = write(pc_fd,engbuf,len);
                if (ret <= 0) {
                    ENG_LOG("%s: write length error %s\n",__FUNCTION__,strerror(errno));
                    sleep(1);
                    start_gser(dev_info->host_int.dev_at);
                    goto write_again;
                }
            }else{
                sleep(1);
            }
        }
    }
    return NULL;
}
Exemple #10
0
int eng_is_send_to_usb(char *buf,int len)
{
    int i = 0;
    int ret = CMD_COMMON;
    MSG_HEAD_T *head_ptr=NULL;
    char diag_header[20];
    char* tmp = buf;

    if(*tmp == 0x7e){
	while(*(++tmp) == 0x7e) i++;
	if(i){
	    ENG_LOG("%s: before diag decode7d7e *tmp=0x%x\n",__FUNCTION__, *tmp);
	}
    }

    memcpy(diag_header, tmp, 20);
    eng_diag_decode7d7e(diag_header, 20);
    head_ptr =(MSG_HEAD_T *)(diag_header);

    ENG_LOG("%s: cmd=0x%x; subcmd=0x%x\n",__FUNCTION__, head_ptr->type, head_ptr->subtype);

     //decide the diag is armlog or dsplog
     if(( 0x98 == head_ptr->type) || ( 0x9D == head_ptr->type) || ( 0xF8 == head_ptr->type))
	return 0;

    return 1;
}
static int eng_atreq(int fd, char *buf, int length)
{
	int ret=0;
	int index=0;
	char cmd[ENG_BUFFER_SIZE];
 
	ENG_LOG("Call %s\n",__FUNCTION__);

	memset(cmd, 0, ENG_BUFFER_SIZE);

	if((index=eng_at2linux(buf)) >= 0) {
		ENG_LOG("%s: Handle %s at Linux\n",__FUNCTION__, buf);
		memcpy(cmd, buf, length);
		memset(buf, 0, length);
		eng_linuxcmd_hdlr(index, cmd, buf);
		ret = ENG_CMD4LINUX;
	} else {
		
		sprintf(cmd, "%d,%d,%s",ENG_AT_NOHANDLE_CMD, 1, buf);

		ENG_LOG("%s: cmd=%s\n",__FUNCTION__, cmd);
		ret = eng_at_write(fd, cmd, strlen(cmd));

		if(ret < 0) {
			ENG_LOG("%s: write cmd[%s] to server fail [%s]\n",__FUNCTION__, buf, strerror(errno));
			ret = -1; 
		} else {
			ENG_LOG("%s: write cmd[%s] to server success\n",__FUNCTION__, buf);
		}

		ret = ENG_CMD4MODEM;
	}
	
	return ret;
}
Exemple #12
0
int eng_linuxcmd_factoryreset(char *req, char *rsp)
{
    int ret = 1;
    char cmd[]="--wipe_data";
    int fd=-1;
    char format_cmd[1024];
    char convert_name[] = "/dev/block/platform/sprd-sdhci.3/by-name/sd";
    static char MKDOSFS_PATH[] = "/system/bin/newfs_msdos";
    mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;

    ENG_LOG("Call %s\n",__FUNCTION__);

    /*format internal sd card. code from vold*/
    sprintf(format_cmd,"%s -F 32 -O android %s",MKDOSFS_PATH,convert_name);
    system(format_cmd);
    //delete files in ENG_RECOVERYDIR
    system("rm -r /cache/recovery");

    //mkdir ENG_RECOVERYDIR
    if(mkdir(ENG_RECOVERYDIR, mode) == -1) {
        ret = 0;
        ENG_LOG("%s: mkdir %s fail [%s]\n",__FUNCTION__, ENG_RECOVERYDIR, strerror(errno));
        goto out;
    }

    //create ENG_RECOVERYCMD
    fd = open(ENG_RECOVERYCMD, O_CREAT|O_RDWR, 0666);

    if(fd < 0){
        ret = 0;
        ENG_LOG("%s: open %s fail [%s]\n",__FUNCTION__, ENG_RECOVERYCMD, strerror(errno));
        goto out;
    }
    if(write(fd, cmd, strlen(cmd)) < 0) {
        ret = 0;
        ENG_LOG("%s: write %s fail [%s]\n",__FUNCTION__, ENG_RECOVERYCMD, strerror(errno));
        goto out;
    }
    if (eng_sql_string2string_set("factoryrst", "DONE")==-1) {
        ret = 0;
        ENG_LOG("%s: set factoryrst fail\n",__FUNCTION__);
        goto out;
    }

    g_reset = 2;
    //sync();
    //__reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
    //        LINUX_REBOOT_CMD_RESTART2, "recovery");
out:
    if(ret==1)
        sprintf(rsp, "%s%s", SPRDENG_OK, ENG_STREND);
    else
        sprintf(rsp, "%s%s", SPRDENG_ERROR, ENG_STREND);

    if(fd >= 0)
        close(fd);

    return 0;
}
static int eng_modem2client(int fd, char * databuf, int length)
{
	int counter=0;

	ENG_LOG("%s",__FUNCTION__);
	counter=eng_at_read(fd, databuf, length);
	ENG_LOG("%s[%d]:%s",__FUNCTION__, counter, databuf);
	return counter;
}
Exemple #14
0
static void handle_device_event(struct uevent *uevent)
{
    if(0 == strncmp(uevent->usb_connect, "CONFIGURED", 10)) {
        // start cp log
        ENG_LOG("%s: enable arm log\n", __FUNCTION__);
        g_armlog_enable = 1;
        sem_post(&g_armlog_sem);
    }else if(0 == strncmp(uevent->usb_connect, "DISCONNECTED", 12)){
        // stop cp log
        ENG_LOG("%s: disable arm log\n", __FUNCTION__);
        g_armlog_enable = 0; 
    }
}
static void eng_atcali_thread(void)
{
	int fd, n, ret;
	fd_set readfds;

	ENG_LOG("%s",__FUNCTION__);

	while((client_server_fd = eng_at_open(0)) < 0){
		ENG_LOG("%s: open server socket failed!, error[%d][%s]\n",\
			__FUNCTION__, errno, strerror(errno));
		usleep(500*1000);
	}

	eng_atauto_thread(NULL);
}
Exemple #16
0
static int eng_simtest_checksim_euicc(int type)
{
    int fd, ret = 0;
    char simstatus;
    char cmd[32];
    char* atchannel, *atrsp;
    int len = 0;
    ENG_LOG("%s: type=%d\n",__FUNCTION__, type);

#ifndef ENG_AT_CHANNEL
    // @alvin: FIX ME: which channel should we use ?
    atchannel = eng_diag_at_channel();
    fd = eng_open_dev(atchannel, O_WRONLY);
    if(fd < 0) {
        ENG_LOG("%s: can't open at channel: %s", __FUNCTION__, atchannel);
    }

    do{
        memset(cmd, 0, sizeof(cmd));
        strcpy(cmd, "at+euicc?\r");
        len = write(fd, cmd, strlen(cmd));
        if(len <= 0){
            continue;
        }
        memset(cmd, 0, sizeof(cmd));
        len = read(fd, cmd, sizeof(cmd));
        if(len <= 0){
            continue;
        }
        ENG_LOG("%s: response=%s\n", __FUNCTION__, cmd);
    }while(strstr(cmd, "err")!=NULL);

    close(fd);
#else // use at channel: modemid=0 & simid=0 is temporary
    atrsp = sendAt(0, 0, "at_euicc?\r");
    memset(cmd, 0, sizeof(cmd));
    strcpy(cmd, atrsp);
#endif
    simstatus = cmd[0];

    if(simstatus=='2') {
        ret=0;
    } else if((simstatus=='0')||(simstatus=='1')) {
        ret = 1;
    }

    return ret;
}
static int eng_pc2client(int fd, char* databuf)
{
	char engbuf[ENG_BUFFER_SIZE];
	int i, length, ret;
	int is_continue = 1;
	int buf_len = 0;

	ENG_LOG("%s: Waitting cmd from PC fd=%d\n", __FUNCTION__, fd);
	if(fd < 0) {
		ENG_LOG("%s: Bad fd",__FUNCTION__);
		return -1;
	}

	do{
		memset(engbuf, 0, ENG_BUFFER_SIZE);
		length = read(fd, engbuf, ENG_BUFFER_SIZE);
		if (length <= 0) {
                        ENG_LOG("%s: read length error\n",__FUNCTION__);
			return -1;
		}
		else{
                        ENG_LOG("%s: length = %d\n",__FUNCTION__, length);
			for(i=0;i<length;i++){
				ENG_LOG("%s: %x %c\n",__FUNCTION__, engbuf[i],engbuf[i]);
				if ( engbuf[i] == 0xd ){ //\r
					continue;
				}
                                else if (engbuf[i] == 0xa && length ==1) { // only \n
                                        ENG_LOG("%s: only \\n,do nothing\n",__FUNCTION__);
					continue;
				}
				else if ( engbuf[i] == 0xa || engbuf[i]==0x1a ||buf_len >= ENG_BUFFER_SIZE){ //\n ^z
					is_continue = 0;
					break;
				}
				else{
					databuf[buf_len]=engbuf[i];
					buf_len ++;
				}
			}
		}
	}while(is_continue);

#if 1
	ENG_LOG("%s: buf[%d]=%s\n",__FUNCTION__, length, databuf);
	for(i=0; i<length; i++) {
		ENG_LOG("0x%x, ",databuf[i]);
	}
	ENG_LOG("\n");
#endif	

	return 0;
}
Exemple #18
0
static void parse_event(const char *msg, struct uevent *uevent)
{
    uevent->action = "";
    uevent->path = "";
    uevent->subsystem = "";
    uevent->usb_connect = "";

    while(*msg) {
        if(!strncmp(msg, "ACTION=", 7)) {
            msg += 7;
            uevent->action = msg;
        } else if(!strncmp(msg, "DEVPATH=", 8)) {
            msg += 8;
            uevent->path = msg;
        } else if(!strncmp(msg, "SUBSYSTEM=", 10)) {
            msg += 10;
            uevent->subsystem = msg;
        } else if(!strncmp(msg, "USB_STATE=", 10)) {
            msg += 10;
            uevent->usb_connect = msg;
        }

        /* advance to after the next \0 */
        while(*msg++)
            ;
    }

    ENG_LOG("%s: event { '%s', '%s', '%s', '%s' }\n", __FUNCTION__,
            uevent->action, uevent->path, uevent->subsystem, uevent->usb_connect);
}
Exemple #19
0
void* eng_uevt_thread(void *x)
{
    struct pollfd ufd;
    int sock = -1;
    int nr;

    sock = uevent_open_socket(256*1024, true);
    if(-1 == sock){
        ENG_LOG("%s: socket init failed !\n", __FUNCTION__);
        return 0;
    }
    if(eng_usb_state()) {
	g_armlog_enable = 1;
	sem_post(&g_armlog_sem);
    }
    ufd.events = POLLIN;
    ufd.fd = sock;
    while(1) {
        ufd.revents = 0;
        nr = poll(&ufd, 1, -1);
        if (nr <= 0)
            continue;
        if (ufd.revents == POLLIN)
            handle_device_fd(sock);
    }

    return 0;    
}
static void *eng_pcclient_hdlr(void *_param)
{
	char databuf[ENG_BUFFER_SIZE];
	int fd, ret;
	int status;
	
	ENG_LOG("%s: Run",__FUNCTION__);
	for( ; ; ){
		memset(databuf, 0, ENG_BUFFER_SIZE);

		//read cmd from pc to client
		if(eng_pc2client(pc_client_fd, databuf)==-1) {
			restart_gser();
			continue;
		}

		//write cmd from client to modem
		status = eng_atreq(client_server_fd, databuf, ENG_BUFFER_SIZE);
 
		//write response from client to pc
		switch(status) {
			case ENG_CMD4LINUX:
				eng_linux2pc(pc_client_fd, databuf);
				break;
			case ENG_CMD4MODEM:
				eng_modem2pc(client_server_fd, pc_client_fd, databuf, ENG_BUFFER_SIZE);
				break;
		}
	}

	return NULL;
}
Exemple #21
0
// TODO: recheck close order
void EngineApp::OnClose()
{
   m_bIsRunning = false;
	// release all the game systems in reverse order from which they were created
   ENG_LOG( "Test", "On close" );
	SAFE_DELETE( m_pEngineLogic );
   IMG_Quit();
   SDL_DestroyWindow( m_pWindow );
   SDL_Quit();
   SAFE_DELETE( m_pEventManager );
   SAFE_DELETE( m_pResCache );

   LuaStateManager::GetSingleton().ClearLuaState();
   InternalScriptExports::Destroy();
   /*
	VDestroyNetworkEventForwarder();

	SAFE_DELETE(m_pBaseSocketManager);

	SAFE_DELETE(m_pEventManager);

    BaseScriptComponent::UnregisterScriptFunctions();

	SAFE_DELETE(m_ResCache);
   */
	return;
}
Exemple #22
0
static int eng_get_device_from_path(const char *path, char *device_name)
{
    char device[256];
    char mount_path[256];
    char rest[256];
    FILE *fp;
    char line[1024];

    if (!(fp = fopen("/proc/mounts", "r"))) {
        ENG_LOG("Error opening /proc/mounts (%s)", strerror(errno));
        return 0;
    }

    while(fgets(line, sizeof(line), fp)) {
        line[strlen(line)-1] = '\0';
        sscanf(line, "%255s %255s %255s\n", device, mount_path, rest);
        if (!strcmp(mount_path, path)) {
            strcpy(device_name,device);
            fclose(fp);
            return 1;
        }

    }

    fclose(fp);
    return 0;
}
/*
** Function: eng_controller_bqb_start
**
** Description:
**	  open the ttys0 and create a thread, download bt controller code
**
** Arguments:
**	 void
**
** Returns:
**	  0
**    -1 failed
*/
int eng_controller_bqb_start(void)
{
    pthread_t thread;
    int ret = -1;

    ENG_LOG(" bqb test test eng_controller_bqb_start");

    bt_hci_init_transport(&bt_fd);
    sprd_config_init(bt_fd, NULL,NULL);

    ret = pthread_create(&thread, NULL, (void *)eng_receive_data_thread, NULL);   /*create thread*/
    if(ret== -1)  {
        ENG_LOG("bqb test create thread failed");
    }

    return ret;
}
/*
** Function: eng_receive_data_thread
**
** Description:
**	  Receive the data from controller, and send the data to the tester
**
** Arguments:
**	 void
**
** Returns:
**
*/
void  eng_receive_data_thread(void)
{
    unsigned int nRead = 0;
    char buf[1030] = {0};

    ENG_LOG("bqb test eng_receive_data_thread");

    while(1) {
       nRead = read(bt_fd, buf, 1000);

        ENG_LOG("bqb test receive data from controller: %d", nRead);

        if(nRead > 0) {
             eng_controller2tester(buf, nRead);
        }
    }
 }
/*
** Function: eng_send_data
**
** Description:
**	  Recieve the data from tester and send the data to controller
**
** Arguments:
**	 data  from the tester
**   the data length
**
** Returns:
**	  0  success
**    -1 failed
*/
void eng_send_data(char * data, int data_len)
{
    int nWritten = 0;
    int count = data_len;
    char * data_ptr = data;

    ENG_LOG("bqb test eng_send_data, fd=%d, len=%d", bt_fd, count);

    while(count)
    {
        nWritten = write(bt_fd, data, data_len);
        count -= nWritten;
        data_ptr  += nWritten;

    }
    ENG_LOG("bqb test eng_send_data nWritten %d ", nWritten);
}
Exemple #26
0
int eng_linuxcmd_hdlr(int cmd, char *req, char* rsp)
{
    if(cmd >= (int)NUM_ELEMS(eng_linuxcmd)) {
        ENG_LOG("%s: no handler for cmd%d",__FUNCTION__, cmd);
        return -1;
    }
    return eng_linuxcmd[cmd].cmd_hdlr(req, rsp);
}
Exemple #27
0
int eng_linuxcmd_getfactoryreset(char *req, char *rsp)
{
    sprintf(rsp, "%s%s%s%s", eng_sql_string2string_get("factoryrst"), \
            ENG_STREND, SPRDENG_OK, ENG_STREND);
    ENG_LOG("%s: rsp=%s\n",__FUNCTION__, rsp);

    return 0;
}
static int eng_modem2pc(int client_server_fd, int pc_client_fd, char *databuf, int length)
{
	int len;
	

	memset(databuf, 0, length);
	ENG_LOG("%s: Waitting AT response from Server\n", __FUNCTION__);

	len = eng_modem2client(client_server_fd, databuf, length);

	ENG_LOG("%s: eng_rspbuf[%d]=%s\n",__FUNCTION__, \
		len, \
		databuf);

	write(pc_client_fd, databuf, len);

	return 0;
}
Exemple #29
0
int restart_gser(int* fd, char* dev_path)
{
    struct termios ser_settings;

    if(*fd > 0) {
        ENG_LOG("%s: eng_vlog close usb serial:%d\n", __FUNCTION__, *fd);
        close(*fd);
    }

    *fd = eng_open_dev(dev_path, O_WRONLY);
    if(*fd < 0) {
        ENG_LOG("%s: eng_vlog cannot open general serial\n", __FUNCTION__);
        return -1;
    }

    ENG_LOG("%s: eng_vlog reopen usb serial:%d\n", __FUNCTION__, *fd);
    return 0;
}
int eng_controller2tester(char * controller_buf, unsigned int data_len)
{
    int len;

    len = write(pc_fd,controller_buf,data_len);

    ENG_LOG("bqb test eng_controller2tester %d", len);
    return len;
}