Go to previous topic
Go to next topic
Last Post 19 Sep 2007 01:58 PM by  richh@logicpd.com
Uart0 - Hardware flow control pins RTS/CTS problems
 1 Replies
Author Messages
s.bencke@terra.com.br
New Member
New Member
Posts:


--
06 Jul 2007 12:37 PM
    Hi,
    I'm using Kernel 2.6.19.2 and Litekit 1006581 REV2. I'm tring to use the debug port to communicate with a serial device (RS485). Fist I configured my bootloader to use the ttymxc2 as a console port and let the ttymxc0 free for my use (I can acess Linux by Telnet).
    In my Linux program I open the Ttymxc0 and I can write and read the serial port without problems, but I neet to use the hardware control pins RTS/CTS and this pins are not working.

    I try to configure the serial port to use Hardware Flow control and I try to use de "ioctl" function and neither of them works !!!


    Here is a part of my code:

    //********************************************************************************************
    //***************** Here I open the TTYMXC0 *****************************************
    //********************************************************************************************
    TtyUbus = open( "/dev/ttymxc0", O_RDWR | O_NONBLOCK | O_NDELAY | O_NOCTTY);// Open the tty
    if (TtyUbus == -1){
    printf( "Error, unable to open port\n" );
    return -1;
    }
    tcgetattr( TtyUbus, &termOptions );
    cfsetispeed( &termOptions, B19200 );
    cfsetospeed( &termOptions, B19200 );
    termOptions.c_oflag |= (BRKINT | IGNPAR); //( testar IXANY)
    termOptions.c_oflag &= ~(OPOST | OLCUC | ONLCR | OCRNL | ONOCR | ONLRET | OFILL | OFDEL | NLDLY |CRDLY | TABDLY | BSDLY| VTDLY| FFDLY);
    termOptions.c_iflag |= (BRKINT | IGNPAR);
    termOptions.c_iflag &= ~(IGNBRK | INPCK | ISTRIP | INLCR | IGNCR | ICRNL | IUCLC | IXON | IXANY | IXOFF |IMAXBEL);
    termOptions.c_cflag |= ( CLOCAL|CREAD );
    termOptions.c_cflag |= PARENB;
    termOptions.c_cflag &= ~CSTOPB;
    termOptions.c_cflag &= ~CSIZE;
    termOptions.c_cflag |= CS8;
    //termOptions.c_cflag |= CRTSCTS;
    termOptions.c_cflag &= ~CRTSCTS;
    termOptions.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
    // Set the new options for the port
    tcsetattr(TtyUbus, TCSANOW, &termOptions);



    //********************************************************************************************
    //***************** In this other part, I just change the state of RTS *************************
    //********************************************************************************************
    While(1)
    {
    ioctl(TtyUbus, TIOCMGET, &flags );

    flags &= ~TIOCM_RTS;
    flags &= ~TIOCM_DTR;
    ioctl(TtyUbus,TIOCMSET,&flags);
    Lost_some_time();

    flags |= TIOCM_RTS;
    flags |= TIOCM_DTR;
    ioctl(TtyUbus,TIOCMSET,&flags);
    Lost_some_time();
    write(TtyUbus,"Test Uart\r\n",11);
    }

    Somebody knows if there is a hartdware problem with this pins or if I'm making something wrong?

    Thanks,
    SB
    richh@logicpd.com
    New Member
    New Member
    Posts:52


    --
    19 Sep 2007 01:58 PM
    SB,
    Please see my post on Sept. 17th about UART problems.


    ---