C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 02-10-2009, 10:43 AM   #1
Registered User
 
Join Date: Feb 2009
Posts: 3
Exclamation Serial Port Access Denied using open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);

I am creating a program that opens a serial port for communication but it gets denied when I open it
I have installed a board that has two ports and have verified they are working by using the terminal:
dmesg | grep tty
console [tty0] enabled
0000:02:00.0: ttyS0 at I/O 0xdf00 (irq = 21) is a 16550A
0000:02:00.0: ttyS1 at I/O 0xde00 (irq = 21) is a 16550A

Code:
Code:
 int open_port(void)
    {
      int fd; /* File descriptor for the port */


      fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
      if (fd == -1)
      {
       /*
	* Could not open the port.
	*/
	perror("open_port: Unable to open /dev/ttyS0 - ");
      }
      else
	fcntl(fd, F_SETFL, 0);

      return (fd);
    }


open_port: Unable to open /dev/ttyS0 -: Permission denied
return code -1


Thank you
Greg
morty346 is offline   Reply With Quote
Old 02-10-2009, 11:02 AM   #2
Registered User
 
Join Date: Feb 2009
Posts: 3
Solved!

chmod o+rw /dev/ttyS0
chmod o+rw /dev/ttyS1

Thank you anyways!
Greg
morty346 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
serial port to poll on request infineonintern C++ Programming 2 06-11-2009 06:52 AM
Access is denied when listen on a port George2 C# Programming 1 05-29-2008 09:01 AM
Can't Read From Serial Port HalNineThousand Linux Programming 14 03-20-2008 05:56 PM
DOS, Serial, and Touch Screen jon_nc17 A Brief History of Cprogramming.com 0 01-08-2003 04:59 PM
VC++/NT serial port access danhar707 Windows Programming 1 11-21-2002 12:28 PM


All times are GMT -6. The time now is 03:58 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22