USB Programming

Discussion in 'C Programming' started by Martin Lui, Oct 22, 2003.

  1. Martin Lui

    Martin Lui Guest

    Hi,

    Where would be a good place to go to find resources on programming USB
    device drivers, or programs that just reads data from USB devices.
    (Example: reading signals from USB GPS receiver).

    I just need a starting place to research it.

    Thanks,
    Martin
     
    Martin Lui, Oct 22, 2003
    #1
    1. Advertising

  2. Martin Lui

    carl mcguire Guest

    Martin Lui wrote:
    > Hi,
    >
    > Where would be a good place to go to find resources on programming USB
    > device drivers, or programs that just reads data from USB devices.
    > (Example: reading signals from USB GPS receiver).
    >
    > I just need a starting place to research it.
    >
    > Thanks,
    > Martin


    Google?
     
    carl mcguire, Oct 22, 2003
    #2
    1. Advertising

  3. Martin Lui

    Fao, Sean Guest

    "Martin Lui" <> wrote in message
    news:p...
    > Hi,
    >
    > Where would be a good place to go to find resources on programming USB
    > device drivers, or programs that just reads data from USB devices.
    > (Example: reading signals from USB GPS receiver).


    Seriously, start with Google and then move on to a newsgroup pertaining to
    your intended platform. There is a lot involved with writing USB drivers
    and none of it have anything directly to do with the C language.
     
    Fao, Sean, Oct 22, 2003
    #3
  4. >Where would be a good place to go to find resources on programming USB
    >device drivers, or programs that just reads data from USB devices.
    >(Example: reading signals from USB GPS receiver).
    >
    >I just need a starting place to research it.


    This is largely off-topic for comp.lang.c, but there is some
    relevance in my answer.

    Your system might provide a file name you can use fopen() on to
    read the data stream for the USB device. (On my laptop it's
    "/dev/ugen0.1"). You don't seem to have to ask for the data, it
    just arrives continually. You can then use fgets() to read in NMEA
    sentences. strtok() is generally unsuitable for parsing it (a GPS
    receiver may leave a blank field with two consecutive commas, which
    strtok() considers to be a single field separator. strsep() as
    found in BSD Unix, while not standard, works better for this purpose).

    My GPS daemon could almost be written in ANSI C, with command-line
    supplied system-specific filename, except for the part about stuffing
    the current position information into a shared memory segment where
    other programs can look at it. I suppose I could have kept re-writing
    the data into a file, but I thought that wasn't real-time enough.

    The line *might* end in a \r\n combination even on systems where
    normal files have lines that end in just \n as they are stored, so
    you might want to intentionally ignore a \r character if one shows
    up. Other than this, NMEA sentences are in plain text (ASCII on
    all GPS receivers I have heard of).

    $GPRMC,011518,A,3240.1036,N,09727.3581,W,0.023,324.2,181003,5.6,E*63
    ^^^^^^^^^^^
    32 degrees, 40.1036 minutes north latitude

    $GPRMC,011518,A,3240.1036,N,09727.3581,W,0.023,324.2,181003,5.6,E*63
    ^^^^^^^^^^^^
    97 degrees 27.3581 minutes west longitude

    $GPRMC,011518,A,3240.1036,N,09727.3581,W,0.023,324.2,181003,5.6,E*63
    ^^^^^^ ^^^^^^
    01:15:18 UTC October 18, 2003

    There's also speed in knots, compass direction, magnetic variation
    from true north, and a checksum in there. And there are other
    sentences with other information.

    Gordon L. Burditt
     
    Gordon Burditt, Oct 23, 2003
    #4
    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. Atz

    USB programming

    Atz, Oct 21, 2004, in forum: C++
    Replies:
    2
    Views:
    2,940
    Karl Heinz Buchegger
    Oct 21, 2004
  2. wilson
    Replies:
    3
    Views:
    963
    wilson
    Aug 10, 2004
  3. skill

    HELP with Programming USB needed

    skill, Aug 17, 2004, in forum: C Programming
    Replies:
    3
    Views:
    321
    Neil Kurzman
    Aug 21, 2004
  4. galapogos
    Replies:
    4
    Views:
    391
    Kenny McCormack
    May 11, 2007
  5. LittleAlex
    Replies:
    0
    Views:
    444
    LittleAlex
    Sep 15, 2008
Loading...

Share This Page