Unbuffered IO

Discussion in 'Ruby' started by Bertram Scharpf, Dec 22, 2006.

  1. Hi,

    this used to work in an older version/environment:

    I read from a usb joystick:

    irb(main):001:0> f = File.new "/dev/input/event0"
    => #<File:/dev/input/event0>
    irb(main):002:0> i=0
    => 0
    irb(main):003:0> loop { a = f.read 8 ; puts [i,a.inspect].join( "--") ; i += 1 }
    0--"\342\252\213E\315\363\000\000"
    ...
    7--"\000\000\000\000\000\000\000\000"
    [wait]

    When I press the buttons on the device I get the output
    8-line-wise, that is 64 bytes at a time. So I try:

    irb(main):001:0> f = File.new "/dev/input/event0"
    => #<File:/dev/input/event0>
    irb(main):002:0> f.sysread 8
    Errno::EINVAL: Invalid argument - /dev/input/event0
    from (irb):2:in `sysread'
    from (irb):2
    from :0

    What does this mean and how could I get around it?

    Thanks in advance.

    Bertram


    --
    Bertram Scharpf
    Stuttgart, Deutschland/Germany
    http://www.bertram-scharpf.de
     
    Bertram Scharpf, Dec 22, 2006
    #1
    1. Advertising

  2. Stop! (was: Unbuffered IO)

    Hi,

    Am Freitag, 22. Dez 2006, 19:41:00 +0900 schrieb Bertram Scharpf:
    > I read from a usb joystick:
    >
    > irb(main):001:0> f = File.new "/dev/input/event0"
    > => #<File:/dev/input/event0>


    I confused event interface and joystick interface.

    Please don't answer on this stupid question.

    Bertram


    --
    Bertram Scharpf
    Stuttgart, Deutschland/Germany
    http://www.bertram-scharpf.de
     
    Bertram Scharpf, Dec 22, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Starbase Commander

    Unbuffered keyboard input???

    Starbase Commander, Sep 10, 2004, in forum: Perl
    Replies:
    1
    Views:
    700
    J├╝rgen Exner
    Sep 11, 2004
  2. Rich

    unbuffered output file

    Rich, Apr 15, 2004, in forum: C++
    Replies:
    5
    Views:
    2,639
    David Harmon
    Apr 16, 2004
  3. Guest
    Replies:
    0
    Views:
    394
    Guest
    Aug 28, 2004
  4. Guest
    Replies:
    1
    Views:
    558
    Jonathan Turkanis
    Aug 29, 2004
  5. michael young

    unbuffered input

    michael young, Feb 5, 2004, in forum: Python
    Replies:
    1
    Views:
    398
    Diez B. Roggisch
    Feb 5, 2004
Loading...

Share This Page