Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

Can't open ttyS0 !!!

Hi All !

I used 2s60ES and build uclinux for my board . I wrote simple example relate with UART this is my code :

struct termios options;

fd=open("/dev/ttyS0",O_RDWR );

if(fd==-1)

{

printf("Cannot open ttyS0!!\n");

exit(0);

}

fcntl(fd,F_SETFL,0);

tcgetattr(fd,&options);

options.c_cflag |=(CLOCAL | CREAD);

......

........

then I ran my example it CANNOT OPEN TTYS0 !!!!

thanks for help !

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Did you enable nios uart driver in kernel config?

    If you already run console or shell on the uart, you can't open it again. use stdin/out instead.

    Otherwise, try "cp /etc/motd /dev/ttyS0" .