[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rtems_termios_ioctl problem



Hi,

Thanks for your answers, I've modified the file with your advices

case TCFLSH:
	{
	switch (args->buffer) {
		case TCIFLUSH:	/* flush input buffer */
			{												
			if ( tty->rawInBuf.Tail != tty->rawInBuf.Head ) /* buffer is not empty*/
				rtems_interrupt_disable (level);
				tty->rawInBuf.Head = tty->rawInBuf.Tail;
				rtems_interrupt_enable (level);
			}
			break;			
		case TCOFLUSH:	/* flush output buffer*/
			{
			if ( tty->rawOutBuf.Tail != tty->rawOutBuf.Head )/* buffer is not empty*/
				rtems_interrupt_disable (level);
				tty->rawOutBuf.Head = tty->rawOutBuf.Tail;
				rtems_interrupt_enable (level);			
			}
			break;
				
		case TCIOFLUSH:	/* flush input & output buffer*/
			{
			if ( tty->rawInBuf.Tail != tty->rawInBuf.Head )
				rtems_interrupt_disable (level);
				tty->rawInBuf.Head = tty->rawInBuf.Tail;
				rtems_interrupt_enable (level);
						
			if ( tty->rawOutBuf.Tail != tty->rawOutBuf.Head )
				rtems_interrupt_disable (level);
				tty->rawOutBuf.Head = tty->rawOutBuf.Tail;
				rtems_interrupt_enable (level);	
			}
			break;
		}				
	}
	break;

	
	
I call ioctl function with tcflush()

int tcflush (int fd, int queue)
{
	switch (queue){
		case TCIFLUSH:			
		case TCOFLUSH:
		case TCIOFLUSH:
			return ioctl(fd,TCFLSH,queue);
			break;
		default: return -1
		} //switch
}

And I am not sure that I'm using the handler ( args->buffer )in the case TCFLSH correctly 

Another problem is for the TCSBRK case.
Can you explain to me how can I send the break signal ?

case TCSBRK:
	{
		??
	}
	break;	


Thanks for your help.

Stephane



> -----Message d'origine-----
> De : Eric Norum [mailto:norume at aps.anl.gov] 
> Envoy? : mercredi 2 mai 2007 16:00
> ? : Arquer Stephane
> Cc : rtems-users at rtems.org
> Objet : Re: Rtems_termios_ioctl problem
> 
> 
> 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?

I don't use it for the moment.

> 
> 
> 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
> 
> 
>