Serial Port Notifications

This is a discussion on Serial Port Notifications within the Linux Programming forums, part of the Platform Specific Boards category; I'm accessing serial ports in linux from user space using ioctl, read and write .Now i need to get notifications ...

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    7

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,590
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    7
    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
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,246
    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: http://ajaxxx.livejournal.com/62378.html
    Code:
    //try
    //{
    	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, 07: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 Cprogramming.com
    Replies: 0
    Last Post: 01-08-2003, 03:59 PM

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