If you just want to save the NMEA data and process it later then you should probably use this: https://garage.maemo.org/projects/gps-saver/ I seem to remember seeing an example of its use somewhere. In any case if you look at the source you'll see how it links into the GPS framework, but you may not even need to do that, just install it and run from the command line and see what options it has, it may do exactly what you want (i.e. log to file)