Rtems_termios_ioctl problem

Eric Norum norume at aps.anl.gov
Wed May 2 13:59:43 UTC 2007


1) Why place the NUL into the buffer?
2) The raw input buffer is a ring buffer, so I don't think that your  
rawnc calculation is right.
3) The semaphore is being used for process synchronization, not for  
mutual exclusion, so obtaining and releasing it like this is incorrect.


It seems to me that all that's necessary is to:
         rtems_interrupt_disable (level);
	tty->rawInBuf.Head = tty->rawInBuf.Tail;
	rtems_interrupt_enable (level);


This will flush the 'raw' input buffer.  Should something happen to  
the 'cooked' buffer as well?


On May 2, 2007, at 7:28 AM, Arquer Stephane wrote.  The comment at  
the top of rtems_termios_enqueue_raw_characters

> 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

-- 
Eric Norum <norume at aps.anl.gov>
Advanced Photon Source
Argonne National Laboratory
(630) 252-4793






More information about the users mailing list