How enable Uart2 serial port RS232?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How enable Uart2 serial port RS232?

2,195件の閲覧回数
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 返答(返信)

949件の閲覧回数
enaud
Contributor III

nothing?

0 件の賞賛
返信

949件の閲覧回数
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 件の賞賛
返信