LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Opening ttyS0 (https://www.linuxquestions.org/questions/linux-general-1/opening-ttys0-354768/)

someshss 08-18-2005 11:58 PM

Opening ttyS0
 
Hi All,

I am trying to open the /dev/ttyS0 port and it is not returning from "open" system call.

The program is as follows ...

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main ()
{
int fd;
fd = open("/dev/ttyS0", O_WRONLY|O_NOCTTY); // Never returns from here
if (fd < 0) {
perror ("Error\n");
return -1;
}
printf ("Success");
close(fd);
return 0;
}

In the above program, it never returns from the "open"

What may be the reason? Please help me in this regard.

Thanks
Somesh SS

ankscorek 08-19-2005 04:43 AM

what distro are u using?

Jerre Cope 08-19-2005 08:53 AM

maybe something silly
 
Are the permissions low enough on /dev/ttyS0?

someshss 08-19-2005 09:49 AM

Yes, Permissions are OK.

But I think I got it solved!

I just loaded serial.o driver and it returned success!

Thanks!

someshss 08-19-2005 09:50 AM

Can any one explain me why it was hanging and now when serial,o is loaded, why it works?

Regards

Tinkster 08-19-2005 08:44 PM

Because you need a driver for the serial port
to be able to use it...


Cheers,
Tink


All times are GMT -5. The time now is 11:12 AM.