Thread: Key hit interupt?

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    11

    Key hit interupt?

    I'm programing this little user interface. I would like it to be able to receive and display data received on the serial port, and I would also like to have the user hit keys to various different things when ever he wants to.

    I've got the program execution waiting for user input using the mygetch() function from the FAQ. (by the way, I'm on a unix terminal... well, unix command line on OSX to be specific)

    Anyway I want to read the data off the serial port when ever it is there to read.

    In micro controller world, I wold simply catch the interups... data is waiting on the serial port, and user hit a key. But I don't know how to do this in the unix command line world.

    I think that I can pole the serial port for data, can I pole stdin as well? Or can I use interups for both... or is there an entirely different solution I should consider.

    thanks.

    B

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    If this is x86-based the keyboard handler is interrupt 09h. Write your own handler for it.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    On a unix or unix-like platform, use select() with whatever file descriptors you're interested in watching.

    It will tell you when there's anything available to be read on a number of fd's, then you can go and read them.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM