How enable Uart2 serial port RS232?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How enable Uart2 serial port RS232?

1,914 Views
enaud
Contributor III

Hi,
I am using UART1 RS232 port to communicate how Linux console and it works properly.
How to enable the UART2 232 for exchanging data? (Open, read, write and close).
What I have to modify the kernel and in which file?
There are commands that I can give directly from the console to test the port, read and write? (Type cat / dev/ttymxc2 or echo> / dev/ttymxc2?)?
thanks

Labels (1)
0 Kudos
2 Replies

668 Views
enaud
Contributor III

nothing?

0 Kudos

668 Views
rasobrevilla
Contributor II

Hi Giuseppe

On C I use it

int fd,n;

    fd = open("/dev/ttymxc2", O_RDWR | O_NOCTTY | O_NONBLOCK);

    struct termios tty;    // ttymxc2

   

    if (fd == -1)

    {         

            perror("open_port: Unable to open /dev/ttymxc2 \n");

        return -1;

    }

        else

    {

        tcgetattr(fd, &tty);

        tty.c_iflag=IGNBRK;  

          tty.c_cflag = CREAD | CS8 | CLOCAL | B115200 ;       

        tty.c_lflag=0;

          tty.c_cc[VMIN]=1;         

        tty.c_cc[VTIME]=100;       

        cfsetospeed(&tty, B115200);

        cfsetispeed(&tty, B115200);

        tcsetattr(fd, TCSANOW, &tty);

        fcntl(fd, F_SETFL, 0);

    }

    n = write(fd, &chain, s * sizeof(unsigned char));

    printf("2: %s\n",chain);

    if (n <0)

        fputs("write() Port failed!\n", stderr);

    close(fd);


0 Kudos