Thread: Serial Port Notifications

  1. #1
    Registered User
    Join Date
    Jan 2010

    Serial Port Notifications

    I'm accessing serial ports in linux from user space using ioctl, read and write.Now i need to get notifications from the kernel if there is new data available or if the port's buffer is empty.How do i get this done without polling? There is something called inotify but i guess that is for 'regular' files (as opposed to device files)

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    If you're using a regular file descriptor, how about select()
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2010
    I looked into select() and poll(). But again these (either blocking or non blocking) are over once the call to these functions is completed. I was thinking more an interrupt based notification so that once it is triggered, i can do my processing in the interrupt service routine. (This is how a normally do when there is no Operating System involved, just bare metal C.But i'm kinda new to OS programming and hence the doubt)

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Portland, OR
    Look into the F_SETOWN subcommand of the fcntl() function. It allows you to request that a certain process receive a SIGIO signal whenever the given file descriptor becomes ready for reading/writing.

    However, also see this:
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Comodo Firewall Vulnerability (Port 0)
    By Mario F. in forum Tech Board
    Replies: 0
    Last Post: 11-11-2009, 08:56 AM
  2. serial port to poll on request
    By infineonintern in forum C++ Programming
    Replies: 2
    Last Post: 06-11-2009, 06:52 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. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  5. DOS, Serial, and Touch Screen
    By jon_nc17 in forum A Brief History of
    Replies: 0
    Last Post: 01-08-2003, 04:59 PM