Rtems_termios_ioctl problem
Arquer Stephane
stephane.arquer at stage.cnes.fr
Thu May 3 08:53:11 UTC 2007
Hi,
If my understanding is correct, in the case of using the flow ctrl mode XON/XOFF or RTS we need to send these controls to indicate that the input buffer has enough space for further reception.
So , I've added the corresponding code when flushing input buffer like following.
/*
* helper subroutine which checks if XON must be sent
* it takes also care of the HW flow control
*/
static rtems_status_code InputFlowCheckResume (struct rtems_termios_tty *tty)
{
/* if tx stopped and XON should be sent... */
if (((tty->flow_ctrl & (FL_MDXON | FL_ISNTXOF))
== (FL_MDXON | FL_ISNTXOF))
&& ((tty->rawOutBufState == rob_idle)
|| (tty->flow_ctrl & FL_OSTOP))) {
/* XON should be sent now... */
(*tty->device.write)(tty->minor, &(tty->termios.c_cc[VSTART]), 1);
}
else if (tty->flow_ctrl & FL_MDRTS) {
tty->flow_ctrl &= ~FL_IRTSOFF;
/* activate RTS line */
if (tty->device.startRemoteTx != NULL) {
tty->device.startRemoteTx(tty->minor);
}
}
return RTEMS_SUCCESSFUL;
} // InputFlowCheckResume()
rtems_status_code rtems_termios_ioctl (void *arg){
...
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);
sc = InputFlowCheckResume(tty);
}
}
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);
sc = InputFlowCheckResume(tty);
}
if ( tty->rawOutBuf.Tail != tty->rawOutBuf.Head ) {
rtems_interrupt_disable (level);
tty->rawOutBuf.Head = tty->rawOutBuf.Tail;
rtems_interrupt_enable (level);
}
}
break;
...
Kind regards.
Stéphane.
> -----Message d'origine-----
> De : Thomas Doerfler [mailto:Thomas.Doerfler at imd-systems.de]
> Envoyé : mercredi 2 mai 2007 22:30
> À : Joel Sherrill
> Cc : Eric Norum; rtems-users at rtems.org; Arquer Stephane
> Objet : Re: RE : Rtems_termios_ioctl problem
>
>
> Joel,
>
> Joel Sherrill schrieb:
> > Thomas Doerfler wrote:
> >
> >
> Should this code be moved to a helper subroutine that is
> invoked from both places?
>
> Yes Joel, this would be nice, especially since it only
> requires "tty" as an argument. The name of this function
> could be "inputFlowCheckResume" or something like this...
>
> Stephane, can you try to implement this?
>
> wkr,
> Thomas.
>
> --
> --------------------------------------------
> IMD Ingenieurbuero fuer Microcomputertechnik
> Thomas Doerfler Herbststrasse 8
> D-82178 Puchheim Germany
> email: Thomas.Doerfler at imd-systems.de
> PGP public key available at:
> http://www.imd-systems.de/pgpkey_en.html
>
More information about the users
mailing list