public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
* Handling RTS
@ 2008-01-09 18:17 JZabalza
  2008-01-09 20:35 ` Chris Doré
  0 siblings, 1 reply; 8+ messages in thread
From: JZabalza @ 2008-01-09 18:17 UTC (permalink / raw)
  To: linux-serial

Hello list

I have a RS485 device connect to a PC serial port.  To handle half duplex 
transmision I must activate/deactivate RTS line. I think this is a very 
common practice.To do this I have these functions

int set_to_write( int _port) 
{ 
int nStatus; 

    if ( ioctl( _port, TIOCMGET, &nStatus ) < 0) 
    { 
        return -1; 
    } 
    else 
    { 
        nStatus |= TIOCM_RTS; 
        if ( ioctl( _port, TIOCMSET, &nStatus ) < 0) 
        { 
            return -2; 
        } 
    } 
 
    return 0; 
} 

int set_to_read( int _port ) 
{ 
int nStatus; 

    if ( ioctl( _port, TIOCMGET, &nStatus ) < 0) 
    { 
        return -1; 
    } 
    else 
    { 

        nStatus &= ~TIOCM_RTS; 
        if ( ioctl( _port, TIOCMSET, &nStatus ) < 0) 
        { 
            return -2; 
        } 
    } 

    return 0; 
}
 

To send bytes I have this code

set_to_write(port);
write(port,"bytes to send",len);
tcdrain(port)
set_to_read(port);

All is running succesfully but when I put oscilloscope I can see 10 mS (or 
more) latency time from set_to_write() to write() begin to send 
characters. I know this is a Linux userland issue but, is there another 
way to do this from driver, similar a cflag CRTSCTS to activate RTS/CTS 
protocol?.

If there is not another way, which shall be the best strategy to implement 
this (activate RTS when uart is transmiting data and deactivate when 
transmision is finish. It would be another protocol different but similar 
to RTS/CTS protocol) on linux driver (modifying serial_core.c  to accept a 
new CFLAG?) ?


thank you very munch for your help.


José Luis Zabalza

-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-01-28  9:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-09 18:17 Handling RTS JZabalza
2008-01-09 20:35 ` Chris Doré
2008-01-10  8:27   ` JZabalza
2008-01-14 15:05     ` Chris Doré
2008-01-21 11:57       ` JZabalza
2008-01-24 13:42         ` Tosoni
2008-01-25  9:37           ` JZabalza
2008-01-28  9:27             ` Tosoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox