Thread: How to read from usb?

  1. #1
    Registered User
    Join Date
    Apr 2009
    Location
    ISTANBUL
    Posts
    8

    Exclamation How to read from usb?

    Hi,

    I use this code to read from serial device:

    fd = open("/dev/ttyS2", O_RDWR | O_NOCTTY | O_NDELAY);

    Could you help me about how this is when reading USB devices?

    Thanks...

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What is the device installed as (perhaps /dev/usb/xxx?) - once you know that, you should be able to read it. Obviously, the NEXT problem is to make sense out of what you read, which may or may not be easy. What USB device is it?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Apr 2009
    Location
    ISTANBUL
    Posts
    8

    Question

    Firstly, I have these problems:

    1.I have a USB mouse and want to read data on it.

    2.I have a USB keyboard and want it to connect to my computer, although I connect but automatically, data which I sent to PC is seen on screen as keyboard actions, so ASCII characters. What I mean that, when I want to connect USB keyboard on an embedded computer how can I use it? Thanks...

    And I will use Linux 2.6.21 and higher.
    Last edited by yildiz.a; 04-28-2009 at 06:45 AM. Reason: syntax error

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I'm pretty sure that if you enable USB in your Linux Kernel, it will work with your USB mouse and USB keyboard.

    Note the keyboard output from the USB is NOT straightforward ASCII codes. The USB mouse will probably send packets that resemble what you'd get from a serial mouse - but not necessarily THE SAME as a serial mouse.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can I know the actual bytes read in a file read
    By pliang in forum C++ Programming
    Replies: 1
    Last Post: 06-08-2005, 04:23 PM
  2. What Would You Use To Read User Input?
    By djwicks in forum C Programming
    Replies: 11
    Last Post: 04-05-2005, 03:32 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Read Array pro!!Plz help!!
    By Supra in forum C Programming
    Replies: 2
    Last Post: 03-04-2002, 03:49 PM
  5. Help! Can't read decimal number
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-07-2001, 02:09 AM

Tags for this Thread