Giter Club home page Giter Club logo

libgps's Introduction

GPS library

The GPS library

Build it

In order to obtain libgps.a

$ make
$ sudo make install

Use it

This project is mainly created for Raspberry ARM boards. After you have compiled the source code on the target or cross-compiling you can include it in your application

#include <gps.h>

The library mainly exposes few methods

  • gps_init - Initialize the communication
  • gps_on - Activate the GPS device
  • gps_location - Expose data from GPS (latitude, longitude, speed, course, altitude)
  • gps_off - Turn off the GPS device

This project abstracts all datas and replies in:

  • Decimal Degrees for latitudes and logitudes (46.235325, 7.12521)
    • Not degrees (42° 53' 23.25'' North - 4° 22' 46.3'' West)
  • Knots for speeds
  • Degrees for angles (course)
  • Meters for altitude

Example - Position logging

Create a simple position_logger.c file (you can find all in the examples folder)

#include <stdio.h>
#include <stdlib.h>
#include <gps.h>

int main(void) {
    // Open
    gps_init();

    loc_t data;

    while (1) {
        gps_location(&data);

        printf("%lf %lf\n", data.latitude, data.longitude);
    }

    return EXIT_SUCCESS;
}

Compile it

$ gcc -o position_logger position_logger.c -lgps -lm

Run it

$ ./position_logger

You will see your data directly in console:

45.071060 7.646363
45.071082 7.646385
45.071078 7.646387
45.071060 7.646373
45.071048 7.646358
45.071052 7.646372
45.071057 7.646392
45.071062 7.646397
45.071062 7.646383
45.071073 7.646395
45.071082 7.646403
45.071082 7.646403
45.071080 7.646395
45.071083 7.646392
45.071088 7.646393

You can rotate the output to files

$ ./position_logger >> position.log

That's all...

Tested components

This library is tested with:

  • Adafruit Ultimate GPS Breakout - 66 channel w/10 Hz updates - Version 3

libgps's People

Contributors

wdalmut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libgps's Issues

Problem in Raspberry pi 3

Hi!
I have try your code in raspberry pi 3 but the function gps_location() not work, you must change the PORTNAME in "serial.h" file with "/dev/ttyS0" for raspberry 3.
Many thanks for the great work!!

/libgps-master/examples + make fail

Hello, I am trying to build the example for the repository but it fails.

~/libgps-master/examples $ make
/usr/bin/gcc -g -Wall -O3 -o ../build/position_logger position_logger.c -lgps -lm
position_logger.c:3:17: fatal error: gps.h: No such file or directory
#include <gps.h>
^
compilation terminated.
Makefile:10: recipe for target 'position_logger' failed
make: *** [position_logger] Error 1

Seg Faults with checksum

If buffer(message in nmea.c) is empty or("1E\r") throws a seg fault because its looking for a "*" for an end. Make if statement in gps.c(line 30), before case statement, that make buffer be more than 4 chars before passing it.

parsing errors with invalid data

In home, no valid inputs

$GPGGA,080919.091,,,,,0,0,,,M,,M,,*49
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,080919.091,V,,,,,0.00,0.00,231113,,,N*4F
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32

Cannot link the library in other dir.

Hey all,

I've got a problem with linking the libgps.a in another Makefile.
By trying to use the functions of gps.h i always get undefined references.

foo.cpp:(.text+0x1a4): undefined reference to 'gps_init()

I thought about compiling them again in the project folder. But I guess it isnt necessary?

My Makefile looks like:

LIBS = -lbcm2835
------Compiling all my .cpp files---------
--------and getting their .o files----------

foo: $(OBJECTS)
$(CC) $^ $(LIBS) -lgps - o foo

clean:
rm -rf *.o foo

Could someone help?

Would be awesome :)

the compiled gps18x code doesn't run for the first time!

Hey,

Thanks for this awesome library for gps18x. It has greatly helped with my project development. However there is one issue. With the provided position_logger example or my own gps code, the compiled 'C' program terminates itself almost immediately while running from linux terminal. when it runs the second or third or subsequent times, it is running well and getting the gps co-ordinates. I am not able to isolate the behavior causing the error. Can you please help me with this as I need to run my project at startup and everytime my code terminates because of this issue.
Thanks!!

Robert

~/build/example/position_logger.c doesn't work

Hi wdalmut,

I have a UBLOX GPS NEO 6M device and i try get data using your libgps but without success.
When i compile and execute the position_logger.c example, the program do nothing. Only stays in loop on console.
Before use that, i install the gpsd software to test my device and see the data on console screen and it's work fine.

Can you helpe me?

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.