Hello,

I use the virtual channel daemon and the multiplex mode to create 2
channels to connect to GSM modem. One is for AT command and the other
one is for gprs connection.
The moment the APN is set, it will try to switch to data mode on the
GPRS channel by sending some related AT commands and start the PPP
daemon with it. Then the ppp net device is created and i am able to
send and receive data by java socket over this device.

But when I try to disconnect the gprs connection by changing APN, I
got a problem that I can't send any at command to GPRS channel and
always get writing error code 11 (EAGAIN).

Actually most of my code is based on freerunner froyo.

My GSM modem is SIM900A.

The gprs channel is opened by


                fd_gprs = open ("/dev/pts/1", O_RDWR | O_NONBLOCK);
                if ( fd_gprs >= 0 ) {
                    struct termios  ios;
                    tcgetattr(fd_gprs, &ios);
                    ios.c_lflag = 0;
                    cfsetispeed(&ios, B115200);
                    cfsetospeed(&ios, B115200);
                    tcsetattr(fd_gprs, TCSANOW, &ios );
                }

The pppd is started with the options:

/dev/pts/1
user
password
unit 1
noauth
nodetach
default-asyncmap
ipcp-accept-local
ipcp-accept-remote
usepeerdns
defaultroute



The disconnecting AT command I sent is


int at_deactivate_modem(struct ATChannels *ATch)
{
    ...
    ioctl(ATch->s_fd, TIOCSBRK, 0);
    ioctl(ATch->s_fd, TIOCSBRK, 0);
    ioctl(ATch->s_fd, TIOCSBRK, 0);

    err = at_send_command_full_nolock (ATch, "+++AT", NO_RESULT,
                                       NULL, NULL, CLOSE_TIMEOUT_MSEC,
                                       NULL);

    /* some stacks start with verbose off */
    err = at_send_command_full_nolock (ATch, "ATH", NO_RESULT,
                                       NULL, NULL, CLOSE_TIMEOUT_MSEC,
                                       NULL);

    err = at_send_command_full_nolock (ATch, "AT+CGACT=0", NO_RESULT,
                                       NULL, NULL, CLOSE_TIMEOUT_MSEC,
                                       NULL);

    err = at_send_command_full_nolock (ATch, "AT+CGATT=0", NO_RESULT,
                                       NULL, NULL, CLOSE_TIMEOUT_MSEC,
                                       NULL);
    ...
}

The err is always -1 and the errno is set to 11 accordingly.

Could anyone has any ideas on this issue?



Thanks,

Jack

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

Reply via email to