How enable Uart2 serial port RS232?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How enable Uart2 serial port RS232?

2,194 次查看
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

标签 (1)
0 项奖励
回复
2 回复数

948 次查看
enaud
Contributor III

nothing?

0 项奖励
回复

948 次查看
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 项奖励
回复