Rtems_termios_ioctl problem

Thomas Doerfler Thomas.Doerfler at embedded-brains.de
Wed May 2 13:41:13 UTC 2007


Hello,

termios buffer management is quite complicated, therefore it is
difficult for me to tell you whether your code might work or not.

I see two problems:

The line where you create rawnc is inside a block after a subroutine
call. Creating variables in C is only allowed at the beginning of a block.

The next thing is your condition "if ( rawnc < 0 )": Since we use the
buffers as ring buffers, the only condition relevant to detect an empty
buffer is (tail == head). Any other combination may indicate a non-empty
buffer.

What I am not sure about is, if a task is waiting for input, it probably
should be woken up during a flush?

wkr,
Thomas.


Arquer Stephane schrieb:
> Hi,
> 
> As I wrote in my previous email, I'm still trying to modify the file termios.c to add TCFLSH request like following:
> 
> case TCFLSH:
> 	{
> 	switch (args->buffer) {
> 		case TCIFLUSH:	/* flush input buffer */
> 			{
> 			unsigned int head;
> 			sc = rtems_semaphore_obtain (tty->rawInBuf.Semaphore,
> 									RTEMS_WAIT,
> 									RTEMS_NO_TIMEOUT);
> 								
> 			int rawnc = tty->rawInBuf.Tail - tty->rawInBuf.Head;
> 			if ( rawnc < 0 )
> 				/* buffer is not empty*/ 					
> 				head = tty->rawInBuf.Head;
> 				tty->rawInBuf.Tail = head;
> 				tty->rawInBuf.theBuf[head] = '\0';
> 					
> 			sc = rtems_semaphore_release (tty->rawInBuf.Semaphore);					
> 			}
> 			break;
> 
> I don't know if it is the correct way to flush the buffer. If someone knows how to do it,I'm interested.
> 
> Thanks for your help.
> 
> Stéphane.
> 
> 
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users


-- 
--------------------------------------------
embedded brains GmbH
Thomas Doerfler           Obere Lagerstr. 30
D-82178 Puchheim          Germany
Tel. : +49-89-18 90 80 79-2
Fax  : +49-89-18 90 80 79-9
email: Thomas.Doerfler at embedded-brains.de
PGP public key available on request




More information about the users mailing list