Thread: Serial Port Access Denied using open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);

  1. #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

  2. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    3
    Solved!

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

    Thank you anyways!
    Greg

Popular pages Recent additions subscribe to a feed

Similar Threads

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