Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all! I'm programming USB mouse api on my embedded linux system. To read mouse event, I typed "mknod /dev/input/event0 c 13 64" and opened it to read. After checking ...
  1. #1
    Just Joined!
    Join Date
    May 2008
    Posts
    2

    After "re"-plugin USB mouse, can't reopen it

    Hi all!
    I'm programming USB mouse api on my embedded linux system.

    To read mouse event, I typed "mknod /dev/input/event0 c 13 64" and
    opened it to read.

    After checking correct ouput from that, plugged out usb mouse.

    And "cat /dev/input/event0", prints "no such device". It's ok.

    But after re-plugin mouse, I can't read() /dev/input/event0 .

    On prompt typping "cat /dev/input/event0", still prints "no such device"
    even though mouse is being connected.

    So I close()ed "dev/input/event0" when unplug mouse, and re-open()ed it when plugin mouse, it is still not possible to open and read..

    (and in "/proc/bus/input/devices", handler "event*" number increases,
    when I open "dev/input/event*" and replugin mouse.)

    What is the problem?

    How can I re-open(or re-read) "/dev/input/event0" successfully
    when replugin-ing mouse?

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by heikifm View Post
    Hi all!
    I'm programming USB mouse api on my embedded linux system.

    To read mouse event, I typed "mknod /dev/input/event0 c 13 64" and
    opened it to read.

    After checking correct ouput from that, plugged out usb mouse.

    And "cat /dev/input/event0", prints "no such device". It's ok.

    But after re-plugin mouse, I can't read() /dev/input/event0 .

    On prompt typping "cat /dev/input/event0", still prints "no such device"
    even though mouse is being connected.
    Right.

    (and in "/proc/bus/input/devices", handler "event*" number increases,
    when I open "dev/input/event*" and replugin mouse.)

    What is the problem?
    As far as I know, this is the way it work. If you want to make sure that a given device is always linked to the same device node, then you have to do some magic yourself. It's much easier if you use udev on that system, because a simple udev rule can do that for you:

    Writing udev rules

    You can match the device using any info that's unique to it.

    I think that that should help.

  3. #3
    Just Joined!
    Join Date
    May 2008
    Posts
    2
    Thanks i92guboj,
    Your advice is very helpful for me
    I'll see udev part. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...