Read in drivers/tty/keyboard.c - Minix

This is a discussion on Read in drivers/tty/keyboard.c - Minix ; I'm facing two problem for which i tried to work around but no success. 1. I'm trying to print a statement using "printf" from with "keyboard.c" of the minix. Inside the "kb_read" funtion i registered a funtion called "test" for ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Read in drivers/tty/keyboard.c

  1. Read in drivers/tty/keyboard.c

    I'm facing two problem for which i tried to work around but no
    success.

    1. I'm trying to print a statement using "printf" from with
    "keyboard.c" of the minix. Inside the "kb_read" funtion i registered a
    funtion called "test" for switch case at the end as follows

    ....
    case CF9: sigchar(&tty_table[CONSOLE], SIGKILL); break;
    case CF10: printf("Hello world !");
    ....


    After that i did a "make".

    Then in the parent "drivers" folder did a "make image", "make install"
    The inside the "usr/src/tools" did a "make hdboot" and "make install"
    and rebooted.

    when i pressed ctrl+F10 i expected the result "Hello world" displayed
    on the screen. But it didnt happen. It working on my friends laptop.
    Could any1 suggest what can be the problem.

    2. We are trying to do a scanf inside the keyboard.c but we have heard
    that it not possible as scanf is to be executed from the user space.
    Then i suppose there are two ways.

    either use kb_read() inside the keyboard.c or read the buffer directly
    used by the keyboard driver.




  2. Re: Read in drivers/tty/keyboard.c

    Hello Sandeep,

    SaM wrote:
    > I'm facing two problem for which i tried to work around but no
    > success.


    > 1. I'm trying to print a statement using "printf" from with
    > "keyboard.c" of the minix. Inside the "kb_read" funtion i registered a
    > funtion called "test" for switch case at the end as follows


    > ...
    > case CF9: sigchar(&tty_table[CONSOLE], SIGKILL); break;
    > case CF10: printf("Hello world !");
    > ...




    > when i pressed ctrl+F10 i expected the result "Hello world" displayed
    > on the screen. But it didnt happen. It working on my friends laptop.
    > Could any1 suggest what can be the problem.


    Are you using the first terminal (tty0) for your testing? The keyboard
    driver is a seperate process with its own file descriptors. It does not
    print to the standard output of the process that's calling the driver, it
    prints to the console (which is tty0 in most cases).

    > 2. We are trying to do a scanf inside the keyboard.c but we have heard
    > that it not possible as scanf is to be executed from the user space.
    > Then i suppose there are two ways.


    I assume you're using Minix 3? If so, the driver _is_ running in user
    space, but it still is a seperate process, which means you have no direct
    access to the file descriptor of the standard input you want to scan.
    Additionally, it's unwise for a driver to issue requests to another driver
    through system calls designed to be used from 'normal' (non-driver,
    non-server) processes unless you're _really really_ sure no loops (and
    therefore deadlocks) will occur.

    Regards,

    Jens

    --
    Jens de Smit
    Student Computer Science | Vrije Universiteit Amsterdam
    jfdsmit@few.vu.nl | http://www.few.vu.nl/~jfdsmit
    "[In the end, people] get furious at IT that the goddamn magic isn't working"
    -- Stewart Dean

  3. Re: Read in drivers/tty/keyboard.c

    On Apr 24, 2:50 am, "J.F. de Smit" wrote:
    > Hello Sandeep,
    >
    > SaM wrote:
    > > I'm facing two problem for which i tried to work around but no
    > > success.
    > > 1. I'm trying to print a statement using "printf" from with
    > > "keyboard.c" of the minix. Inside the "kb_read" funtion i registered a
    > > funtion called "test" for switch case at the end as follows
    > > ...
    > > case CF9: sigchar(&tty_table[CONSOLE], SIGKILL); break;
    > > case CF10: printf("Hello world !");
    > > ...

    >
    >
    >
    > > when i pressed ctrl+F10 i expected the result "Hello world" displayed
    > > on the screen. But it didnt happen. It working on my friends laptop.
    > > Could any1 suggest what can be the problem.

    >
    > Are you using the first terminal (tty0) for your testing? The keyboard
    > driver is a seperate process with its own file descriptors. It does not
    > print to the standard output of the process that's calling the driver, it
    > prints to the console (which is tty0 in most cases).
    >
    > > 2. We are trying to do a scanf inside the keyboard.c but we have heard
    > > that it not possible as scanf is to be executed from the user space.
    > > Then i suppose there are two ways.

    >
    > I assume you're using Minix 3? If so, the driver _is_ running in user
    > space, but it still is a seperate process, which means you have no direct
    > access to the file descriptor of the standard input you want to scan.
    > Additionally, it's unwise for a driver to issue requests to another driver
    > through system calls designed to be used from 'normal' (non-driver,
    > non-server) processes unless you're _really really_ sure no loops (and
    > therefore deadlocks) will occur.
    >
    > Regards,
    >
    > Jens
    >
    > --
    > Jens de Smit
    > Student Computer Science | Vrije Universiteit Amsterdam
    > jfds...@few.vu.nl |http://www.few.vu.nl/~jfdsmit
    > "[In the end, people] get furious at IT that the goddamn magic isn't working"
    > -- Stewart Dean


    Thanks much I was able to print from inside the keyboard.c

    inside the function kb_read(), i did the following

    PRIVATE int kb_read()(tp, try){
    ....
    tp = &tty_table[ccurrent]; /* always use the current console*/
    ....

    CASE CF10: test(tp); break;

    .....
    }

    PRIVATE void test(){
    printf("Inside printf"); /* this NEVER got printed when i pressed ctrl
    +F10*/
    in_process(tp, "inside in_process", 17); /* this got PRINTED*/
    }

    =================================================

    So I'm able to to print on the console using my special key
    combination. Now I want to scan from the keyboard. I'm wondering what
    function I can use to scan inputs that the user types...

    Thanks in anticipation....


  4. Re: Read in drivers/tty/keyboard.c

    Sorry for the late reply... I'm able to read of the keyboard.c driver
    long back.. So I think its the time to share how i did it...

    If you people observe inside the function "kb_read", there is a buffer
    defined buf[3]. This buffer contains the the scan code of every key
    pressed. After the key is pressed its stored in this buffer and sent
    immediately for the processing. When the next key from the keyboard is
    pressed the scan code of the new key replaces the old value.

    So we can create a buffer[100] of our own and read the scan-codes from
    the buf[3] and keep on filling the buffer we just defined till the
    time we want. In this way we can read data using the keyboard driver
    of minix directly.

    On Apr 24, 2:07 pm, SaM wrote:
    > On Apr 24, 2:50 am, "J.F. de Smit" wrote:
    >
    >
    >
    > > Hello Sandeep,

    >
    > > SaM wrote:
    > > > I'm facing two problem for which i tried to work around but no
    > > > success.
    > > > 1. I'm trying to print a statement using "printf" from with
    > > > "keyboard.c" of the minix. Inside the "kb_read" funtion i registered a
    > > > funtion called "test" for switch case at the end as follows
    > > > ...
    > > > case CF9: sigchar(&tty_table[CONSOLE], SIGKILL); break;
    > > > case CF10: printf("Hello world !");
    > > > ...

    >
    > >

    >
    > > > when i pressed ctrl+F10 i expected the result "Hello world" displayed
    > > > on the screen. But it didnt happen. It working on my friends laptop.
    > > > Could any1 suggest what can be the problem.

    >
    > > Are you using the first terminal (tty0) for your testing? The keyboard
    > > driver is a seperate process with its own file descriptors. It does not
    > > print to the standard output of the process that's calling the driver, it
    > > prints to the console (which is tty0 in most cases).

    >
    > > > 2. We are trying to do a scanf inside the keyboard.c but we have heard
    > > > that it not possible as scanf is to be executed from the user space.
    > > > Then i suppose there are two ways.

    >
    > > I assume you're using Minix 3? If so, the driver _is_ running in user
    > > space, but it still is a seperate process, which means you have no direct
    > > access to the file descriptor of the standard input you want to scan.
    > > Additionally, it's unwise for a driver to issue requests to another driver
    > > through system calls designed to be used from 'normal' (non-driver,
    > > non-server) processes unless you're _really really_ sure no loops (and
    > > therefore deadlocks) will occur.

    >
    > > Regards,

    >
    > > Jens

    >
    > > --
    > > Jens de Smit
    > > Student Computer Science | Vrije Universiteit Amsterdam
    > > jfds...@few.vu.nl |http://www.few.vu.nl/~jfdsmit
    > > "[In the end, people] get furious at IT that the goddamn magic isn't working"
    > > -- Stewart Dean

    >
    > Thanks much I was able to print from inside the keyboard.c
    >
    > inside the function kb_read(), i did the following
    >
    > PRIVATE int kb_read()(tp, try){
    > ...
    > tp = &tty_table[ccurrent]; /* always use the current console*/
    > ...
    >
    > CASE CF10: test(tp); break;
    >
    > ....
    >
    > }
    >
    > PRIVATE void test(){
    > printf("Inside printf"); /* this NEVER got printed when i pressed ctrl
    > +F10*/
    > in_process(tp, "inside in_process", 17); /* this got PRINTED*/
    >
    > }
    >
    > =================================================
    >
    > So I'm able to to print on the console using my special key
    > combination. Now I want to scan from the keyboard. I'm wondering what
    > function I can use to scan inputs that the user types...
    >
    > Thanks in anticipation....


    mizinack

+ Reply to Thread