Hi all,
I am trying to integrate my gsm modem to android, basically the at
command available in reference-ril should work.
Below is a snippet of what i have changed, my goal is just to hard
code the device connection and get it to send the data to my com port
0, but before i do anything the open function already failed at the
comment "/*fail here*/". It will return -1. Have anyone faced the same
problem as me? Is there anything i need to change at the make file?
regards,
Adrian
static void *
mainLoop(void *param)
{
int fd;
int ret;
struct termios tty;
struct termios oldtty;
AT_DUMP("== ", "entering mainLoop()", -1 );
at_set_on_reader_closed(onATReaderClosed);
at_set_on_timeout(onATTimeout);
for (;;) {
/* start open fd */
fd=-1;
while (fd < 0) {
LOGI ("xp-debug mainLoop\n");
// signal(SIGIO, SIG_IGN); // the important one.
fd = open("/dev/ttyUSB0", O_RDWR);// | O_NOCTTY | O_NONBLOCK
if (fd < 0) {
LOGI ("fd < 0 fd:%d\n",fd); /*fail here*/
//return 0;
}
tcgetattr(fd, &oldtty); // save current port settings
//bzero(&tty, sizeof(tty)); // Initialize the port settings
structure to all zero
memset(&tty,0,sizeof(tty));
LOGI("before tty config \n");
tty.c_cflag = B9600 | CS8 | CREAD ; // 8N1 | CLOCAL |
CRTSCTS
tty.c_iflag = 0;
tty.c_oflag = 0;
tty.c_lflag = 0;
tty.c_cc[VMIN] = 0; // 0 means use-vtime
tty.c_cc[VTIME] = 100; // time to wait until exiting read
(tenths of a second)
LOGI("after tty config\n");
tcflush(fd, TCIFLUSH); // flush old data
tcsetattr(fd, TCSANOW, &tty); // apply new settings
fcntl(fd, F_SETOWN, getpid()); // enable our PID to receive
serial interrupts
fcntl(fd, F_SETFL, FASYNC);
if (fd < 0) {
perror ("opening AT interface. retrying...");
sleep(10);
/* never returns */
}
}
/* end of open socket*/
s_closed = 0;
ret = at_open(fd, onUnsolicited);
if (ret < 0) {
LOGE ("AT error %d on at_open\n", ret);
return 0;
}
RIL_requestTimedCallback(initializeCallback, NULL,
&TIMEVAL_0);
// Give initializeCallback a chance to dispatched, since
// we don't presently have a cancellation mechanism
sleep(1);
waitForClose();
LOGI("Re-opening after close");
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---