Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@ Temporary Items
*.swp

# Zephyr build files
examples/Zephyr/*/build/*
examples/Zephyr/*/build/*

# Linux build files
linux/bin/*
linux/lib/*
linux/build/*

53 changes: 53 additions & 0 deletions linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
project (ublox_linux)
cmake_minimum_required(VERSION 2.8)

set(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
${CMAKE_HOME_DIRECTORY}/bin
)

set(
CMAKE_LIBRARY_OUTPUT_DIRECTORY
${CMAKE_HOME_DIRECTORY}/lib
)

add_definitions(
-std=c++11 -Wno-deprecated -fconcepts -Wall -DLINUX_PLATFORM
)

link_directories(
/usr/local/lib
/usr/lib
${CMAKE_HOME_DIRECTORY}/lib
)

include_directories(
${CMAKE_HOME_DIRECTORY}/inc
${CMAKE_HOME_DIRECTORY}/../src
)

set(
ublox_parser_src
../src/SparkFun_Ublox_Arduino_Library.cpp
src/Print.cpp
src/Utils.cpp
)

add_library(
ublox_linux SHARED ${ublox_parser_src}
)

#
# Ublox f9p Test
#

set(
ublox_f9p_test_src
examples/ublox_f9p_test.cpp
)

add_executable(
ublox_f9p_test ${ublox_f9p_test_src}
)

target_link_libraries(ublox_f9p_test ublox_linux util)
11 changes: 11 additions & 0 deletions linux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SparkFun_Ublox_Linux_Library

## How to compile
* mkdir build
* cd build
* cmake ..
* make

## How to execute test
* cd ../bin (Assuming the current directorty is build directory, created above)
* ./ublox_f9p_test (Ublox library calls)
87 changes: 87 additions & 0 deletions linux/examples/ublox_f9p_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
Copyright (c) 2020 Balamurugan Kandan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#include "SparkFun_Ublox_Arduino_Library.h"
SFE_UBLOX_GPS myGPS;

int main(int argc, char** argv)
{
if(argc == 1) {
printf("\nublox_f9p_test <ublox_com> <pseudo_com> (ublox_f9p_test '/dev/ttyACM0')");
return 0;
} else if (argc == 2) {
for(int counter=0;counter<argc;counter++)
printf("\nargv[%d]: %s",counter,argv[counter]);
} else if(argc >= 3) {
printf ("\nMore number of arguments...");
return 0;
}

Stream seriComm(argv[1]);
seriComm.begin(38400);
if (!seriComm.isConnected()) {
printf ("Ublox is not connected. Please connect ublox GNSS module and try again...\n");
return 0;
}

myGPS.begin(seriComm);
myGPS.setNavigationFrequency(8); //Set output to 8 times a second
myGPS.saveConfiguration(); //Save the current settings to flash and BBR

printf ("\n--------------------------------------------------------\n");
while(true) {
if (myGPS.getPVT()) {
printf ("%02d/%02d/%02d %02d:%02d:%02d %d:%d\n", myGPS.getDay(), myGPS.getMonth(), myGPS.getYear(),
myGPS.getHour(), myGPS.getMinute(), myGPS.getSecond(),
myGPS.getMillisecond(), myGPS.getNanosecond());
printf("Latitude : %2.8f (deg)\n", myGPS.getLatitude() * 1e-7);
printf("Longitude : %2.8f (deg)\n", myGPS.getLongitude() * 1e-7);
printf("Altitude : %d (mm)\n", myGPS.getAltitude());
printf("Altitude MSL : %d (mm)\n", myGPS.getAltitudeMSL());
printf("SIV : %d\n", myGPS.getSIV());
printf("PDOP : %f\n", myGPS.getPDOP() * 1e-2);
printf("Fix type : %d\n", myGPS.getFixType());
printf("Ground Speed : %d\n", myGPS.getGroundSpeed());
printf("VelN : %08d (mm/s)\n", myGPS.getNedNorthVel());
printf("VelE : %08d (mm/s)\n", myGPS.getNedEastVel());
printf("VelD : %08d (mm/s)\n", myGPS.getNedDownVel());
printf("VAcc : %08d (mm)\n", myGPS.getVerticalAccEst());
printf("HAcc : %08d (mm)\n", myGPS.getHorizontalAccEst());
printf("SpeedAccEst : %08d (mm/s)\n", myGPS.getSpeedAccEst());
printf("HeadAccEst : %08d (degrees * 10^-5)\n", myGPS.getHeadingAccEst());
printf("HeadVehValid : %s\n", myGPS.getHeadVehValid() ? "true" : "false");
printf("HeadVeh : %08d (degrees * 10^-5)\n", myGPS.getHeadVeh());
printf("MagDec : %08d (degrees * 10^-2)\n", myGPS.getMagDec());
printf("MagAcc : %08d (degrees * 10^-2)\n", myGPS.getMagAcc());
int solnType = myGPS.getCarrierSolutionType();
if (solnType == 0) printf ("### No RTK Fix yet ###\n");
else if (solnType == 1) printf ("&&& DGNSS/Float &&&\n");
else if (solnType == 2) printf ("*** DGNSS/Fix ***\n");
printf ("\n--------------------------------------------------------\n");
usleep(50);
}

usleep(25);
}

return 1;
}
16 changes: 16 additions & 0 deletions linux/inc/Common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef COMMON_H__
#define COMMON_H__

typedef uint8_t byte;
typedef bool boolean;

#define INPUT 0
#define OUTPUT 1
#define LOW 0
#define HIGH 1

#define SHORT_BUFF 256

#define I2C_DEV "/dev/ublox_i2c"

#endif // COMMON_H__
99 changes: 99 additions & 0 deletions linux/inc/Print.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
Print.h - Base class that provides print() and println()
Copyright (c) 2008 David A. Mellis. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef Print_h
#define Print_h

#include <inttypes.h>
#include <stdio.h> // for size_t

#define DEC 10
#define HEX 16
#define OCT 8
#ifdef BIN // Prevent warnings if BIN is previously defined in "iotnx4.h" or similar
#undef BIN
#endif
#define BIN 2

#include <string>
typedef std::string String;

#define PSTR(s) ((const char *)(s))
#define PGM_P const char *

class __FlashStringHelper;
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))

class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printFloat(double, uint8_t);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}

int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }

virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}

// default to zero, meaning "a single write may block"
// should be overriden by subclasses with buffering
virtual int availableForWrite() { return 0; }

size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(double, int = 2);
//size_t print(const Printable&);

size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(double, int = 2);
//size_t println(const Printable&);
size_t println(void);

virtual void flush() { /* Empty implementation for backward compatibility */ }
};

#endif
Loading