Handling RTS

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

 



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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux