Hey, Guys:
I am doing a project that need to communicate with modem. I searched the 
web, found this TI's solution called "gsm0710muxd", you can clone the code 
from:

git://git.omapzoom.org/platform/hardware/ti/omap3.git


After compiling and running, everything seems perfect.  It create 4 pts 
node(/dev/pts/0-4) on ttyS0. However, when I logged on target throught ADB, 
and try to echo at+ipr? > /dev/pts/0, a read function error occurs.

gsm0710muxd will create 4 threads(named poll_thread), poll_thread will poll 
a device using select(). So, when input echo at+ipr? > /dev/pts/0, select 
function will return. Then poll_thread will call read function to get input 
from pseudo terminal, and read function returns success. Because poll_thread 
is a while(1) loop, it will soon call select again. And select function 
returns again. read function will called again. But the second time, read 
function returns fail with a EIO signal.

Anyone also faced this problem?

Code:
void* poll_thread(void *vargp)

{

LOGMUX(LOG_DEBUG,"Enter");

Poll_Thread_Arg* poll_thread_arg = (Poll_Thread_Arg*)vargp;


 if (poll_thread_arg->fd == -1) {

LOGMUX(LOG_ERR, "Serial port not initialized");

goto terminate;

}


 while (1) {

int tmp;

fd_set fdr, fdw;

FD_ZERO(&fdr);

FD_ZERO(&fdw);

FD_SET(poll_thread_arg->fd, &fdr);

if ((tmp = select((1+poll_thread_arg->fd), &fdr, &fdw, NULL, NULL)) > 0) {

LOGMUX(LOG_ERR, "fiddle --- Select returns %d, fd = %d!!!!!", tmp, 
poll_thread_arg->fd);

if (FD_ISSET(poll_thread_arg->fd, &fdr)) {

if((*(poll_thread_arg->read_function_ptr))(poll_thread_arg->read_function_arg) 
!= 0) {

LOGMUX(LOG_WARNING, "Device read function returned error");

goto terminate;

}

}

} else { //No need to evaluate retval=0 case, since no use of timeout in 
select()

switch (errno) {

case EINTR:

LOGMUX(LOG_ERR,"Interrupt signal EINTR caught");

break;

case EAGAIN:

LOGMUX(LOG_ERR,"Interrupt signal EAGAIN caught");

break;

case EBADF:

LOGMUX(LOG_ERR,"Interrupt signal EBADF caught");

break;

case EINVAL:

LOGMUX(LOG_ERR,"Interrupt signal EINVAL caught");

break;

default:

LOGMUX(LOG_ERR,"Unknown interrupt signal caught\n");

}

goto terminate;

}

}

goto terminate;


terminate:

LOGMUX(LOG_ERR, "Device polling thread terminated");

free(poll_thread_arg);  //free the memory allocated for the thread args 
before exiting thread

return NULL;

}

-- 
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting

Reply via email to