[En-Nut-Discussion] HDLC in charcter mode?

Michael Müller mmueller at cs.uni-kassel.de
Tue Apr 12 11:40:04 CEST 2011

Hi Hendrik,

I had similar problems with an Ethernut 1.3 board some time ago. Maybe
it is transferable to your problem. I used these functions to do the
mode switch:

void setPPPdevRawMode(void)
	char rawmode = 1;
	_ioctl(pppcom , UART_SETRAWMODE, &rawmode ) ;
	_read(pppcom, 0, 0);

void setPPPdevHDLCMode(void)
	char rawmode = 0;
	_ioctl(pppcom , UART_SETRAWMODE, &rawmode ) ;
	_read(pppcom, 0, 0);

The other issue was that chars I wrote to the device didn´t appear at
the output of the Uart. The solution is always to flush the device manually:

_read(pppcom, 0, 0);	// flush input
_write(pppcom, send, sendLength);  //write command to modem
_write(pppcom, 0, 0);   // flush output

Because the default chat-function doesn´t work with this behaviour I
implemented my own simple chat function that also consumes less memory
and fits better to my demands.

I hope this is useful for you

Am 11.04.11 20:17, schrieb Hendrik Osenberg:
> Hello everyone,
> i have a problem with the AT91 AHDLC Driver.
> At first i want to use it as a normal uart in order to configure a bluetooth-module by sending hex-values. After receiving the correct answers, I want to start a PPP-session...
> I have a working PPP-Connection and i can send Data from my board, by the way it is an OLIMEX SAM7-EX256, via a mobile phone. But to do this i have set up the bluetooth connection with another program which makes use of the normal uart1-driver. After this was successful i have to flash the board with the Code which I use the Ahdlc1 driver. In two older threads I read about   _ioctl(pppcom, HDLC_SETIFNET, 0);, but this does not work. If I try to change in raw mode it ends up in a freezing CPU.
> Here is a part of the example:
> int pppcom;
> unsigned long baud = 9600;
> char transparent[] = {0x02,0x52,0x01,0x00,0x64,0x01,0x03};
> int lctl = 1000;
> NutRegisterDevice(&devAhdlc1, 0, 0);
> NutRegisterDevice(&devPpp, 0, 0);
> _ioctl(_fileno(stdout), UART_SETSPEED, &baud);
> pppcom= _open("ppp:uart1/user/pass",_O_RDWR | _O_BINARY);
> if (pppcom <= 0)
> {
> printf("failed\n");
> while(1);
> }
> printf("done\n");
> _ioctl(pppcom, UART_SETSPEED, &baud);
> _ioctl(pppcom, UART_SETREADTIMEOUT, &lctl);
> _ioctl(pppcom, HDLC_SETIFNET, 0);
> fputc(transparent[2],pppcom);
> Does this feature misses in this driver? But in which way is NutChat working? It is in character mode too, isn't it?
> What am I doing wrong? Are there any hints?
> Any help is welcome!
> Greetings
> Hendrik
> ___________________________________________________________
> Schon gehört? WEB.DE hat einen genialen Phishing-Filter in die
> Toolbar eingebaut! http://produkte.web.de/go/toolbar
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion

More information about the En-Nut-Discussion mailing list