Rtems_termios_ioctl problem
Arquer Stephane
stephane.arquer at stage.cnes.fr
Fri May 4 09:51:30 UTC 2007
Thomas,
Thanks a lot for your explanations, for the moment the input flush seems to work fine.
I've add interrupts control inside the function InputFlowCheckResume.
Kind regards.
Stéphane.
> -----Message d'origine-----
> De : Thomas Doerfler [mailto:Thomas.Doerfler at embedded-brains.de]
> Envoyé : jeudi 3 mai 2007 11:46
> À : Arquer Stephane
> Cc : rtems-users at rtems.org
> Objet : Re: RE : Rtems_termios_ioctl problem
>
>
> Stephane,
>
> the input direction looks fine for me with one exception: the
> function InputFlowCheckResume should be executed with
> interrupts disabled, otherwise "rawOutBufState" could change
> its state after it has been checked and before the (*write)
> function is executed.
>
> But I am quite unsure about the output direction: in
> interrupt driven mode, termios will present the buffer
> between head and tail (or part of
> it) to the driver's write function, and some time later, the
> driver will call rtems_termios_dequeue_characters(tty,len)
> to indicate, that it has sent out the whole or part of this buffer.
>
> What happens, when you meanwhile modify "head" (and possibly
> add new output characters to the buffer afterwards)? Either
> the driver will send out stale data, new data out of proper
> order, or the head/tail management may totally come out of
> sync in this situation.
>
> I am not sure what will happen, but I think your output Flush
> needs further rethinking.
>
> wkr,
> Thomas.
>
>
> Arquer Stephane schrieb:
> > 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
> >>
> >
> > _______________________________________________
> > 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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: termios.c
Type: application/octet-stream
Size: 42189 bytes
Desc: termios.c
URL: <http://lists.rtems.org/pipermail/users/attachments/20070504/31c21a0c/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tcflush.c
Type: application/octet-stream
Size: 808 bytes
Desc: tcflush.c
URL: <http://lists.rtems.org/pipermail/users/attachments/20070504/31c21a0c/attachment-0003.obj>
More information about the users
mailing list