>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