--- c:\Nburn - Copy\system\ppp.cpp Mon Oct 15 13:09:56 2007 +++ ppp.cpp Sun Jul 27 19:30:49 2008 @@ -363,6 +363,7 @@ #define MODEM_CMD_NO_CARRIER (3) #define MODEM_CMD_CONNECT (4) #define MODEM_CMD_TIMEOUT (5) +#define MODEM_CMD_READERR (6) void EnterCommandMode( int fd ); int WaitForCmd( int fd, int delay ); @@ -462,7 +463,8 @@ { //connect while int rv; - int pause = 0; + int pause = CMD_PAUSE*5; + PPPDBPRINT("Waiting for command \r\n"); rv = WaitForCmd( fdserial, pause ); switch ( rv ) @@ -496,18 +498,22 @@ WaitForCmd( fdserial, TICKS_PER_SECOND ); break; - case MODEM_CMD_TIMEOUT: case MODEM_CMD_NO_CARRIER: cur_State = eClosing; PPPDBPRINT( "connect failed \r\n" ); break; + case MODEM_CMD_TIMEOUT: + PPPDBPRINT( "READ timeout \r\n"); + //Simply wait for command, and monitor cur_State and abort_ppp + break; + case MODEM_CMD_READERR: + //May need to restart serial port in this case + break; } - } - while ( ( cur_State != eClosing ) && ( ( abort_ppp & ABORT_CLOSE_PPP ) == 0 ) ); + } while ( ( cur_State != eClosing ) && ( ( abort_ppp & ABORT_CLOSE_PPP ) == 0 ) ); - PPPDBPRINT( "Closed(2) \r\n" ); - } - while ( ( abort_ppp & ABORT_CLOSE_PPP ) == 0 ); + PPPDBPRINT( "Closed(2) \r\n" ); + } while ( ( abort_ppp & ABORT_CLOSE_PPP ) == 0 ); PPPDBPRINT( "Exiting PPP Dameon\r\n" ); cur_State = eClosed; }//PPP Deamon @@ -523,8 +529,6 @@ return 0; } - DWORD end_time = TimeTick + delay; - do { rv = ReadWithTimeout( fd, buffer + nr, 80 - nr, delay ); @@ -565,20 +569,16 @@ } } nr += rv; + } else if(rv==0) { + //CMD Timeout + return MODEM_CMD_TIMEOUT; + } else if(rv<0) { + //select returned error for the fd + return MODEM_CMD_READERR; } - buffer[nr] = 0; + } while ( ( nr < 80 ) && ( !abort_ppp ) ); - if ( delay != 0 ) - { - if ( ( TimeTick > end_time ) && ( TimeTick < end_time + 1000 ) ) - { - PPPDBPRINT( "Wait time out\r\n" ); - return MODEM_CMD_TIMEOUT; - } - } - } - while ( ( nr < 80 ) && ( !abort_ppp ) ) ; return MODEM_CMD_TIMEOUT; }