Key hit interupt?

This is a discussion on Key hit interupt? within the C Programming forums, part of the General Programming Boards category; I'm programing this little user interface. I would like it to be able to receive and display data received on ...

  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
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    If this is x86-based the keyboard handler is interrupt 09h. Write your own handler for it.

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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 12:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 09: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

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