USB Programming

M

Martin Lui

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
 
C

carl mcguire

Martin said:
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?
 
F

Fao, Sean

Martin Lui said:
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.
 
G

Gordon Burditt

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top