[En-Nut-Discussion] PPP/AHDLC logic problems...

Brett Abbott Brett.Abbott at digital-telemetry.com
Sun Apr 17 01:31:57 CEST 2005


re: Closing PPP in a managed way....

 >> There seems to be same fix for exiting loop. But other problems 
remains there that I was talking about. I am little worried about the 
fact that sometimes if I do HDLC_SETIFNET with value 0, it will reboot 
whole system.

I have not found this to occur anymore (but only once I worked out why I 
kept rebooting).  Take care you havent issued the _close function if you 
intend to use the uart as _close (ppp) also closes the uart.  If you 
then send anything to the device (pointer=0), you will reboot.  This is 
a nasty in nutos, fprintf to a null pointer or closed file will bounce 
the baby.

If you issue ClosePPP you cant write AT commands (or anyhting to the device) without causing a reboot!  (writing to closed uart device)

Additionally: The openPPP opens both the uart and the device driver as a single step - perhaps they should be separated?

Please see code snippets below showing steps I use to shutdown and then restart, any feedback appreciated.

Cheers
Brett


void StopPPP(char StreamNum)
{
	if(pppcom!=-1)
	{
        _ioctl(pppcom, HDLC_SETIFNET, 0);
        NutSleep(2000);
    }
}

void ClosePPP(char StreamNum)
{

	if(pppcom!=-1)
	{

	 	_close(pppcom);
				   NutSleep(2000);
		pppcom=-1;
    	myStream_fd=-1; // We have closed the stream - special case for ppp
        //AvrUsartSetDTR1(1); //or the function you use to hang up the modem
	}
	
}

void OpenMyPPP(char StreamNum)
{
 	int uart_fileno;
    u_long long_ctl;

	
pppcom = _open(myDeviceOpenString, _O_RDWR | _O_BINARY);

    uart_fileno=pppcom;
    myStream_fd=uart_fileno;

long_ctl = mq_StreamConfig[StreamNum].RXTimeout;
	_ioctl(uart_fileno, UART_SETREADTIMEOUT, &long_ctl);

	long_ctl = mq_StreamConfig[StreamNum].Speed;
	_ioctl(uart_fileno, UART_SETSPEED, &long_ctl);

	long_ctl = mq_StreamConfig[StreamNum].WordLength;
	_ioctl(uart_fileno, UART_SETDATABITS, &long_ctl);
    NutSleep(200);

}
		


.... Using PPP then decide to stop./...

// Ensure the stream did disconnect before retrying
StopPPP(StreamNum); // Stops PPP but does not close the uart
DisconnectStream(StreamNum); // This uses chat to issue +++ (1 second pause) then ATH<cr>
ClosePPP(StreamNum);

...

OpenMyPPP()
....



-----------------------------------------------------------------
Brett Abbott, Managing Director, Digital Telemetry Limited
Email: Brett.Abbott at digital-telemetry.com
PO Box 24 036 Manners Street, Wellington, New Zealand
Phone +64 (4) 5666-860  Mobile +64 (21) 656-144
------------------- Commercial in confidence --------------------






More information about the En-Nut-Discussion mailing list