TR : Tcflush function

Arquer Stephane stephane.arquer at stage.cnes.fr
Wed Apr 18 15:17:01 UTC 2007


M. Sherril,

Thanks for your quick answer.
I'm trying to install the rtems 4.7 release, but for some reasons that I don't understand for the moment I can't compile my sources.
Anyway, My rtems 4.6.6 installation works fine so for the moment I'll continue to work with it if it's possible.


As I wrote in my previous email, I've modified 4 files:
-> 	ioccom.h
->	tcflush.c
->	tcsendbreak.c
->	termios.c

The modifications are:

1)
$HOME/rtems-4.6.6/src/rtems-4.6.6/cpukit/libcsupport/include/sys/ioccom.h

/*  added to implement rtems_termios_ioctl() TCFLSH and TCSBRK */
#define TCSBRK			0x5409
#define TCXONC			0x540A
#define TCFLSH			0x540B
#define TIOCEXCL		0x540C
#define TIOCNXCL		0x540D

Is it correct or not ?


2)
$HOME/rtems-4.6.6/src/rtems-4.6.6/cpukit/libcsupport/src/tcflush.c

int tcflush (int fd, int queue)
{
	return ioctl(fd,TCFLSH,queue);
}




3)
$HOME/rtems-4.6.6/src/rtems-4.6.6/cpukit/libcsupport/src/tcsendbreak.c

int tcsendbreak(int fd, int duration)
{
	if (duration <= 0)
		return ioctl(fd, TCSBRK, 0);
	else return ioctl(fd, TCSBRK, duration);
}



4)
$HOME/rtems-4.6.6/src/rtems-4.6.6/cpukit/libcsupport/src/termios.c

rtems_status_code rtems_termios_ioctl (void *arg)
{
...
	case TCFLSH:
		{
		switch (args->buffer) {
			case TCIFLUSH:	/* flush input buffer */
				{
				
				int rawnc = tty->rawInBuf.Tail - tty->rawInBuf.Head;
				if ( rawnc < 0 )	/* buffer is not empty*/
					sc = rtems_semaphore_obtain (tty->rawInBuf.Semaphore,
									RTEMS_WAIT,
									RTEMS_NO_TIMEOUT);
					/* how can I erase the rawInBuf ? */
				}
				break;
				
			case TCOFLUSH:	/* flush output buffer*/
				{
				/* ? */
				}
				break;
			case TCIOFLUSH:	/* flush input & output buffer*/
				{
				/* ? */
				}
				break;
			}				
		}
		break;
		
	case TCSBRK:
		}
		/* ? */
		}
		break;	
	}
	rtems_semaphore_release (tty->osem);
	args->ioctl_return = sc;
	return sc;
}

I don't know how to manage the handler args to select the arg queue passed by the function ioctl. Where can find the structure definition to understand the type rtems_libio_ioctl_args_t ?


Another question is, when these modifications will be done, is there a way to compile the concerned library only (which one ?) or do I rebuild my i386-rtems bsp ?


Thanks for your help.

I look forward to hearing from you.

Best regards.

Stephane ARQUER
CNES FRANCE


-----Message d'origine-----
De : Joel Sherrill [mailto:joel.sherrill at oarcorp.com] 
Envoyé : lundi 16 avril 2007 21:23
À : Arquer Stephane; Eric Norum
Objet : Re: Tcflush function


Arquer Stephane wrote:
> M. Sherril,
>
> I am a brand new user of rtems, I'm working with the 4.6.6 version of 
> rtems , I use an i386 bsp and I would like to use the following  
> functions :
>
>   
Well you would be better off working with 4.7 or the CVS head to add 
functionality but if
you are using 4.6.6 for some other reason, just be willing to test it 
against the head so
we can merge it when you are done.

I have cc'ed Eric Norum who originally wrote the termios code but you 
would be better
off joining the RTEMS mailing list and moving this discussion there.

Also for a definitive answer on what this function is supposed to do, 
then the answer
is the OpenGroup Single UNIX Specification.

http://www.opengroup.org/onlinepubs/000095399/functions/tcflush.html

Some specifics on the implementation are below.
> Tsflush(filedes, TCIFLUSH);
> Or the same with ioctl(filedes, TCFLSH,0);
>
> I've read in the rtems mailing list some messages of the same problem 
> but there is no answer.
>
> I have add these lines to the file 
> $RTEMS_ROOT/i386-rtems/pc386/lib/include/sys/ioccom.h
>
> #define TCSBRK          0x5409
> #define TCXONC          0x540A
> #define TCFLSH          0x540B
> #define TIOCEXCL  	0x540C
> #define TIOCNXCL     	0x540D
>
> To add the request  TCFLSH, but it doesn't want to work.
>
>
> I am trying to modify also the file 
> src/rtems-4.6.6/cpukit/libcsupport/src/tcflush.c
> But I don't know what to add more after the case TCIFLUSH, TCOFLUSH and TCIOFLUSH
>
>
> int tcflush (int fd;  int queue_selector)
> {
> 	switch (queue_selector) {
> 		case TCIFLUSH: 
> 		case TCOFLUSH: 
> 		case TCIOFLUSH:
--->>>>>>>   ioctl calls goes here
-->>>>>>>>>   it ends up in rtems_termios_ioctl

> break;
> 		default:
> 		 	__set_errno (EINVAL);
> 			return -1;
> 	}
> __set_errno (ENOSYS);
> return -1;
> }
>      
>   
The code to actually perform any of the tcXXX functions is in termios.c 
in the
function rtems_termios_ioctl().  You would have to add these cases to 
that switch.
It looks like you should be to just carefully empty the input, output or 
both ring buffers
and make sure the counting semaphores end up in the right state to 
reflect being empty.

> I don't know how to continue to solve this problem.
> Thanks a lot for your help.
>
> Best regards.
>
> Stéphane ARQUER
> Student at CNES France
>
>
>  
>
>   





More information about the users mailing list