From dd86f518ba4a8cddc3b2328a77c3113a16a2798e Mon Sep 17 00:00:00 2001 From: Danila Loginov Date: Sun, 3 Dec 2017 13:16:51 +0300 Subject: [PATCH 1/9] chore: rename Docs directory to extras --- ...Description Including Protocol Specification.pdf | Bin ...ription Including Protocol Specification V14.pdf | Bin ...Description Including Protocol Specification.pdf | Bin 3 files changed, 0 insertions(+), 0 deletions(-) rename {Docs => extras}/u-blox 6 Receiver Description Including Protocol Specification.pdf (100%) rename {Docs => extras}/u-blox 7 Receiver Description Including Protocol Specification V14.pdf (100%) rename {Docs => extras}/u-blox 8 (M8) Receiver Description Including Protocol Specification.pdf (100%) diff --git a/Docs/u-blox 6 Receiver Description Including Protocol Specification.pdf b/extras/u-blox 6 Receiver Description Including Protocol Specification.pdf similarity index 100% rename from Docs/u-blox 6 Receiver Description Including Protocol Specification.pdf rename to extras/u-blox 6 Receiver Description Including Protocol Specification.pdf diff --git a/Docs/u-blox 7 Receiver Description Including Protocol Specification V14.pdf b/extras/u-blox 7 Receiver Description Including Protocol Specification V14.pdf similarity index 100% rename from Docs/u-blox 7 Receiver Description Including Protocol Specification V14.pdf rename to extras/u-blox 7 Receiver Description Including Protocol Specification V14.pdf diff --git a/Docs/u-blox 8 (M8) Receiver Description Including Protocol Specification.pdf b/extras/u-blox 8 (M8) Receiver Description Including Protocol Specification.pdf similarity index 100% rename from Docs/u-blox 8 (M8) Receiver Description Including Protocol Specification.pdf rename to extras/u-blox 8 (M8) Receiver Description Including Protocol Specification.pdf From f3d516199508953fe2aaa3a7c35edcb3dce632e7 Mon Sep 17 00:00:00 2001 From: Danila Loginov Date: Sun, 3 Dec 2017 13:24:04 +0300 Subject: [PATCH 2/9] chore: move examples to a separate directory --- .../NavPvt/NavPvt.ino => examples/UbxGpsNavPvt/UbxGpsNavPvt.ino | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename UbxGps/examples/NavPvt/NavPvt.ino => examples/UbxGpsNavPvt/UbxGpsNavPvt.ino (100%) diff --git a/UbxGps/examples/NavPvt/NavPvt.ino b/examples/UbxGpsNavPvt/UbxGpsNavPvt.ino similarity index 100% rename from UbxGps/examples/NavPvt/NavPvt.ino rename to examples/UbxGpsNavPvt/UbxGpsNavPvt.ino From a9789562e09d761719b1c412ac9a883f1b9fffd5 Mon Sep 17 00:00:00 2001 From: Danila Loginov Date: Sun, 3 Dec 2017 13:24:53 +0300 Subject: [PATCH 3/9] chore: rename UbxGps directory to src --- {UbxGps => src}/UbxGps.cpp | 0 {UbxGps => src}/UbxGps.h | 0 {UbxGps => src}/UbxGpsNavPosecef.h | 0 {UbxGps => src}/UbxGpsNavPosllh.h | 0 {UbxGps => src}/UbxGpsNavPvt.h | 0 {UbxGps => src}/UbxGpsNavSol.h | 0 {UbxGps => src}/keywords.txt | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename {UbxGps => src}/UbxGps.cpp (100%) rename {UbxGps => src}/UbxGps.h (100%) rename {UbxGps => src}/UbxGpsNavPosecef.h (100%) rename {UbxGps => src}/UbxGpsNavPosllh.h (100%) rename {UbxGps => src}/UbxGpsNavPvt.h (100%) rename {UbxGps => src}/UbxGpsNavSol.h (100%) rename {UbxGps => src}/keywords.txt (100%) diff --git a/UbxGps/UbxGps.cpp b/src/UbxGps.cpp similarity index 100% rename from UbxGps/UbxGps.cpp rename to src/UbxGps.cpp diff --git a/UbxGps/UbxGps.h b/src/UbxGps.h similarity index 100% rename from UbxGps/UbxGps.h rename to src/UbxGps.h diff --git a/UbxGps/UbxGpsNavPosecef.h b/src/UbxGpsNavPosecef.h similarity index 100% rename from UbxGps/UbxGpsNavPosecef.h rename to src/UbxGpsNavPosecef.h diff --git a/UbxGps/UbxGpsNavPosllh.h b/src/UbxGpsNavPosllh.h similarity index 100% rename from UbxGps/UbxGpsNavPosllh.h rename to src/UbxGpsNavPosllh.h diff --git a/UbxGps/UbxGpsNavPvt.h b/src/UbxGpsNavPvt.h similarity index 100% rename from UbxGps/UbxGpsNavPvt.h rename to src/UbxGpsNavPvt.h diff --git a/UbxGps/UbxGpsNavSol.h b/src/UbxGpsNavSol.h similarity index 100% rename from UbxGps/UbxGpsNavSol.h rename to src/UbxGpsNavSol.h diff --git a/UbxGps/keywords.txt b/src/keywords.txt similarity index 100% rename from UbxGps/keywords.txt rename to src/keywords.txt From 399381830619b5471f60f9e6a7ebc18cea0da72f Mon Sep 17 00:00:00 2001 From: Danila Loginov Date: Sun, 3 Dec 2017 13:36:40 +0300 Subject: [PATCH 4/9] chore: move configuration related files to extras directory --- .../Auto-configuration-Mega.ino | 0 .../Configuration}/Auto-configuration.jpg | Bin .../Serial-Bridge-Mega/Serial-Bridge-Mega.ino | 0 .../Serial-Bridge-Uno/Serial-Bridge-Uno.ino | 0 .../Configuration}/Step 1. Wiring.jpg | Bin .../Configuration}/Step 2. Serial bridge.jpg | Bin .../Configuration}/Step 3. Meet u-center.jpg | Bin .../Configuration}/Step 4. Change baudrate.jpg | Bin .../Configuration}/Step 5. Change frequency.jpg | Bin .../Step 6. Disable unnecessary channels.jpg | Bin .../Configuration}/Step 7. Choose packet.gif | Bin .../Configuration}/Step 8. Save configuration.jpg | Bin .../Configuration}/Step 9. Checks.jpg | Bin ...Description Including Protocol Specification.pdf | Bin ...ription Including Protocol Specification V14.pdf | Bin ...Description Including Protocol Specification.pdf | Bin 16 files changed, 0 insertions(+), 0 deletions(-) rename {Configuration => extras/Configuration}/Auto-configuration-Mega/Auto-configuration-Mega.ino (100%) rename {Configuration => extras/Configuration}/Auto-configuration.jpg (100%) rename {Configuration => extras/Configuration}/Serial-Bridge-Mega/Serial-Bridge-Mega.ino (100%) rename {Configuration => extras/Configuration}/Serial-Bridge-Uno/Serial-Bridge-Uno.ino (100%) rename {Configuration => extras/Configuration}/Step 1. Wiring.jpg (100%) rename {Configuration => extras/Configuration}/Step 2. Serial bridge.jpg (100%) rename {Configuration => extras/Configuration}/Step 3. Meet u-center.jpg (100%) rename {Configuration => extras/Configuration}/Step 4. Change baudrate.jpg (100%) rename {Configuration => extras/Configuration}/Step 5. Change frequency.jpg (100%) rename {Configuration => extras/Configuration}/Step 6. Disable unnecessary channels.jpg (100%) rename {Configuration => extras/Configuration}/Step 7. Choose packet.gif (100%) rename {Configuration => extras/Configuration}/Step 8. Save configuration.jpg (100%) rename {Configuration => extras/Configuration}/Step 9. Checks.jpg (100%) rename extras/{ => Docs}/u-blox 6 Receiver Description Including Protocol Specification.pdf (100%) rename extras/{ => Docs}/u-blox 7 Receiver Description Including Protocol Specification V14.pdf (100%) rename extras/{ => Docs}/u-blox 8 (M8) Receiver Description Including Protocol Specification.pdf (100%) diff --git a/Configuration/Auto-configuration-Mega/Auto-configuration-Mega.ino b/extras/Configuration/Auto-configuration-Mega/Auto-configuration-Mega.ino similarity index 100% rename from Configuration/Auto-configuration-Mega/Auto-configuration-Mega.ino rename to extras/Configuration/Auto-configuration-Mega/Auto-configuration-Mega.ino diff --git a/Configuration/Auto-configuration.jpg b/extras/Configuration/Auto-configuration.jpg similarity index 100% rename from Configuration/Auto-configuration.jpg rename to extras/Configuration/Auto-configuration.jpg diff --git a/Configuration/Serial-Bridge-Mega/Serial-Bridge-Mega.ino b/extras/Configuration/Serial-Bridge-Mega/Serial-Bridge-Mega.ino similarity index 100% rename from Configuration/Serial-Bridge-Mega/Serial-Bridge-Mega.ino rename to extras/Configuration/Serial-Bridge-Mega/Serial-Bridge-Mega.ino diff --git a/Configuration/Serial-Bridge-Uno/Serial-Bridge-Uno.ino b/extras/Configuration/Serial-Bridge-Uno/Serial-Bridge-Uno.ino similarity index 100% rename from Configuration/Serial-Bridge-Uno/Serial-Bridge-Uno.ino rename to extras/Configuration/Serial-Bridge-Uno/Serial-Bridge-Uno.ino diff --git a/Configuration/Step 1. Wiring.jpg b/extras/Configuration/Step 1. Wiring.jpg similarity index 100% rename from Configuration/Step 1. Wiring.jpg rename to extras/Configuration/Step 1. Wiring.jpg diff --git a/Configuration/Step 2. Serial bridge.jpg b/extras/Configuration/Step 2. Serial bridge.jpg similarity index 100% rename from Configuration/Step 2. Serial bridge.jpg rename to extras/Configuration/Step 2. Serial bridge.jpg diff --git a/Configuration/Step 3. Meet u-center.jpg b/extras/Configuration/Step 3. Meet u-center.jpg similarity index 100% rename from Configuration/Step 3. Meet u-center.jpg rename to extras/Configuration/Step 3. Meet u-center.jpg diff --git a/Configuration/Step 4. Change baudrate.jpg b/extras/Configuration/Step 4. Change baudrate.jpg similarity index 100% rename from Configuration/Step 4. Change baudrate.jpg rename to extras/Configuration/Step 4. Change baudrate.jpg diff --git a/Configuration/Step 5. Change frequency.jpg b/extras/Configuration/Step 5. Change frequency.jpg similarity index 100% rename from Configuration/Step 5. Change frequency.jpg rename to extras/Configuration/Step 5. Change frequency.jpg diff --git a/Configuration/Step 6. Disable unnecessary channels.jpg b/extras/Configuration/Step 6. Disable unnecessary channels.jpg similarity index 100% rename from Configuration/Step 6. Disable unnecessary channels.jpg rename to extras/Configuration/Step 6. Disable unnecessary channels.jpg diff --git a/Configuration/Step 7. Choose packet.gif b/extras/Configuration/Step 7. Choose packet.gif similarity index 100% rename from Configuration/Step 7. Choose packet.gif rename to extras/Configuration/Step 7. Choose packet.gif diff --git a/Configuration/Step 8. Save configuration.jpg b/extras/Configuration/Step 8. Save configuration.jpg similarity index 100% rename from Configuration/Step 8. Save configuration.jpg rename to extras/Configuration/Step 8. Save configuration.jpg diff --git a/Configuration/Step 9. Checks.jpg b/extras/Configuration/Step 9. Checks.jpg similarity index 100% rename from Configuration/Step 9. Checks.jpg rename to extras/Configuration/Step 9. Checks.jpg diff --git a/extras/u-blox 6 Receiver Description Including Protocol Specification.pdf b/extras/Docs/u-blox 6 Receiver Description Including Protocol Specification.pdf similarity index 100% rename from extras/u-blox 6 Receiver Description Including Protocol Specification.pdf rename to extras/Docs/u-blox 6 Receiver Description Including Protocol Specification.pdf diff --git a/extras/u-blox 7 Receiver Description Including Protocol Specification V14.pdf b/extras/Docs/u-blox 7 Receiver Description Including Protocol Specification V14.pdf similarity index 100% rename from extras/u-blox 7 Receiver Description Including Protocol Specification V14.pdf rename to extras/Docs/u-blox 7 Receiver Description Including Protocol Specification V14.pdf diff --git a/extras/u-blox 8 (M8) Receiver Description Including Protocol Specification.pdf b/extras/Docs/u-blox 8 (M8) Receiver Description Including Protocol Specification.pdf similarity index 100% rename from extras/u-blox 8 (M8) Receiver Description Including Protocol Specification.pdf rename to extras/Docs/u-blox 8 (M8) Receiver Description Including Protocol Specification.pdf From 4e4144a060421d28c97aafe50794d1d926be8271 Mon Sep 17 00:00:00 2001 From: Danila Loginov Date: Sun, 3 Dec 2017 13:42:03 +0300 Subject: [PATCH 5/9] chore: move keywords.txt to the root --- src/keywords.txt => keywords.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/keywords.txt => keywords.txt (100%) diff --git a/src/keywords.txt b/keywords.txt similarity index 100% rename from src/keywords.txt rename to keywords.txt From 992dc7a726d46980ba8c4ab2923ffba4436aaed3 Mon Sep 17 00:00:00 2001 From: Danila Loginov Date: Sun, 3 Dec 2017 13:44:08 +0300 Subject: [PATCH 6/9] chore: update keywords.txt --- keywords.txt | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/keywords.txt b/keywords.txt index ea0c5db..99f2a55 100644 --- a/keywords.txt +++ b/keywords.txt @@ -1,8 +1,30 @@ -UbxGps KEYWORD1 +####################################### +# Syntax Coloring Map For UbxGps +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +UbxGps KEYWORD1 UbxGpsNavPosecef KEYWORD1 UbxGpsNavPosllh KEYWORD1 UbxGpsNavPvt KEYWORD1 UbxGpsNavSol KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + begin KEYWORD2 ready KEYWORD2 + +####################################### +# Instances (KEYWORD2) +####################################### + +####################################### +# Constants (LITERAL1) +####################################### + UBXGPS_HEADER LITERAL1 From d21ffe602a9af4b89a94abe83947e570e0fbcd53 Mon Sep 17 00:00:00 2001 From: Danila Loginov Date: Sun, 3 Dec 2017 15:03:26 +0300 Subject: [PATCH 7/9] style: update sources code style --- examples/UbxGpsNavPvt/UbxGpsNavPvt.ino | 39 +++-- .../Auto-configuration-Mega.ino | 163 ++++++++---------- .../Serial-Bridge-Mega/Serial-Bridge-Mega.ino | 32 ++-- .../Serial-Bridge-Uno/Serial-Bridge-Uno.ino | 50 ++---- keywords.txt | 2 +- src/UbxGps.cpp | 90 +++++----- src/UbxGps.h | 21 +-- src/UbxGpsNavPosecef.h | 28 ++- src/UbxGpsNavPosllh.h | 32 ++-- src/UbxGpsNavPvt.h | 78 ++++----- src/UbxGpsNavSol.h | 53 +++--- 11 files changed, 275 insertions(+), 313 deletions(-) diff --git a/examples/UbxGpsNavPvt/UbxGpsNavPvt.ino b/examples/UbxGpsNavPvt/UbxGpsNavPvt.ino index 541c874..f31645d 100644 --- a/examples/UbxGpsNavPvt/UbxGpsNavPvt.ino +++ b/examples/UbxGpsNavPvt/UbxGpsNavPvt.ino @@ -1,12 +1,7 @@ /** - * UBX GPS Library — NAV PVT Example - * Created by Danila Loginov, July 23, 2016 - * https://github.com/1oginov/UBX-GPS-Library + * The sketch parses UBX messages from u-blox NEO-7M and outputs ready GPS data to a serial port in a CSV format. * - * Sketch parses UBX messages from U-blox NEO-7M and outputs ready GPS data to the serial port in the CSV format. - * Скетч обрабатывает UBX сообщения от U-box NEO-7M и выводит готовые GPS данные в последовательный порт в CSV формате. - * - * U-blox NEO-7M - Arduino Mega + * u-blox NEO-7M - Arduino Mega * VCC - 5V * RX - TX3 * TX - RX3 @@ -24,20 +19,32 @@ UbxGpsNavPvt gps(Serial3); char datetime[DATETIME_LENGTH]; -void setup() { +void setup() +{ Serial.begin(PC_BAUDRATE); gps.begin(GPS_BAUDRATE); } -void loop() { - if (gps.ready()) { +void loop() +{ + if (gps.ready()) + { snprintf(datetime, DATETIME_LENGTH, DATETIME_FORMAT, gps.year, gps.month, gps.day, gps.hour, gps.min, gps.sec); - Serial.print(datetime); Serial.print(','); - Serial.print(gps.lon / 10000000.0, 7); Serial.print(','); - Serial.print(gps.lat / 10000000.0, 7); Serial.print(','); - Serial.print(gps.height / 1000.0, 3); Serial.print(','); - Serial.print(gps.gSpeed * 0.0036, 5); Serial.print(','); - Serial.print(gps.heading / 100000.0, 5); Serial.print(','); Serial.print(gps.fixType); Serial.print(','); + + Serial.print(datetime); + Serial.print(','); + Serial.print(gps.lon / 10000000.0, 7); + Serial.print(','); + Serial.print(gps.lat / 10000000.0, 7); + Serial.print(','); + Serial.print(gps.height / 1000.0, 3); + Serial.print(','); + Serial.print(gps.gSpeed * 0.0036, 5); + Serial.print(','); + Serial.print(gps.heading / 100000.0, 5); + Serial.print(','); + Serial.print(gps.fixType); + Serial.print(','); Serial.println(gps.numSV); } } diff --git a/extras/Configuration/Auto-configuration-Mega/Auto-configuration-Mega.ino b/extras/Configuration/Auto-configuration-Mega/Auto-configuration-Mega.ino index 1993b99..9a77530 100644 --- a/extras/Configuration/Auto-configuration-Mega/Auto-configuration-Mega.ino +++ b/extras/Configuration/Auto-configuration-Mega/Auto-configuration-Mega.ino @@ -1,17 +1,9 @@ /** - * UBX GPS Library - * Created by Danila Loginov, July 2, 2016 - * https://github.com/1oginov/UBX-GPS-Library + * The sketch restores the receiver default configuration and configure it to get NAV-PVT messages with 100 ms + * frequency and 115200 baudrate. After the auto-configuration, it transmits the data from the receiver to the PC and + * vice versa. * - * Sketch, restoring the receiver's default configuration and configure it to get - * NAV-PVT messages with 100 ms frequency and 115200 baudrate. After the auto- - * configuration transmits the data from the receiver to the PC and vice versa. - * - * Скетч, сбрасывающий приёмник к конфигурации по умолчанию и настраивающий его для - * получения NAV-PVT сообщений с частотой 100 ms на скорости 115200. После - * выполнения самонастройки передает данные от приёмника компьютеру и наоборот. - * - * U-blox NEO-7M - Arduino Mega + * u-blox NEO-7M - Arduino Mega * VCC - 5V * RX - TX3 * TX - RX3 @@ -22,29 +14,15 @@ #define PC_BAUDRATE 115200L #define GPS_SERIAL Serial3 -// Default baudrate is determined by the receiver's manufacturer -// Скорость обмена по умолчанию определена производителем приёмника - +// Default baudrate is determined by the receiver manufacturer. #define GPS_DEFAULT_BAUDRATE 9600L -// Wanted buadrate can be 9600L (not changed after defaults) or 115200L (changed -// by the changeBaudrate() function with prepared message) at the moment -// -// Желаемая скорость обмена в настоящий момент может быть либо 9600L (не меняется -// после возврата к настройкам по умолчанию), либо 115200L (изменяется вызовом -// функции changeBaudrate()) - +// Wanted buadrate at the moment can be 9600L (not changed after defaults) or 115200L (changed by the +// `changeBaudrate()` function with a prepared message). #define GPS_WANTED_BAUDRATE 115200L -// Array of possible baudrates that can be used by receiver, sorted descending -// to prevent excess Serial flush/begin after restoring defaults. You can uncomment -// values that can be used by your receiver before the auto-configuration. -// -// Массив возможных значений скорости обмена, которые могут быть использованы -// приёмником, отсортированы по убыванию, чтобы предотвратить лишние flush/begin -// после возврата к настройкам по умолчанию. Вы можете разкомментировать значения, -// которые могут использоваться приёмником перед самонастройкой. - +// Array of possible baudrates that can be used by the receiver, sorted descending to prevent excess Serial flush/begin +// after restoring defaults. You can uncomment values that can be used by your receiver before the auto-configuration. const long possibleBaudrates[] = { //921600L, //460800L, @@ -57,18 +35,20 @@ const long possibleBaudrates[] = { //4800L, }; -void setup() { +void setup() +{ PC_SERIAL.begin(PC_BAUDRATE); PC_SERIAL.println("Starting auto-configuration..."); - // Restoring receiver's default configuration - // Возврат приёмника к конфигурации по умолчанию - for (byte i = 0; i < sizeof(possibleBaudrates) / sizeof(*possibleBaudrates); i++) { + // Restore the receiver default configuration + for (byte i = 0; i < sizeof(possibleBaudrates) / sizeof(*possibleBaudrates); i++) + { PC_SERIAL.print("Trying to restore defaults at "); PC_SERIAL.print(possibleBaudrates[i]); PC_SERIAL.println(" baudrate..."); - if (i != 0) { + if (i != 0) + { delay(100); // Little delay before flushing GPS_SERIAL.flush(); } @@ -77,9 +57,9 @@ void setup() { restoreDefaults(); } - // Switching receiver's serial to the default baudrate - // Перевод последовательного порта для общения с приёмником на скорость по умолчанию - if (possibleBaudrates[sizeof(possibleBaudrates) / sizeof(*possibleBaudrates) - 1] != GPS_DEFAULT_BAUDRATE) { + // Switch the receiver serial to the default baudrate + if (possibleBaudrates[sizeof(possibleBaudrates) / sizeof(*possibleBaudrates) - 1] != GPS_DEFAULT_BAUDRATE) + { PC_SERIAL.print("Switching to the default baudrate which is "); PC_SERIAL.print(GPS_DEFAULT_BAUDRATE); PC_SERIAL.println("..."); @@ -89,14 +69,13 @@ void setup() { GPS_SERIAL.begin(GPS_DEFAULT_BAUDRATE); } - // Disabling NMEA messages by sending appropriate packets - // Отключение NMEA сообщений с помощью соответствующих пакетов + // Disable NMEA messages by sending appropriate packets PC_SERIAL.println("Disabling NMEA messages..."); disableNmea(); - // Switching receiver's serial to the wanted baudrate - // Перевод последовательного порта для общения с приёмником на желаемую скорость - if (GPS_WANTED_BAUDRATE != GPS_DEFAULT_BAUDRATE) { + // Switch the receiver serial to the wanted baudrate + if (GPS_WANTED_BAUDRATE != GPS_DEFAULT_BAUDRATE) + { PC_SERIAL.print("Switching receiver to the wanted baudrate which is "); PC_SERIAL.print(GPS_WANTED_BAUDRATE); PC_SERIAL.println("..."); @@ -108,18 +87,15 @@ void setup() { GPS_SERIAL.begin(GPS_WANTED_BAUDRATE); } - // Increasing frequency to 100 ms - // Увеличение частоты до 100 мс + // Increase frequency to 100 ms PC_SERIAL.println("Changing receiving frequency to 100 ms..."); changeFrequency(); - // Disabling unnecessary channels like SBAS or QZSS - // Отключение ненужных каналов, как SBAS или QZSS + // Disable unnecessary channels like SBAS or QZSS PC_SERIAL.println("Disabling unnecessary channels..."); disableUnnecessaryChannels(); - // Enabling NAV-PVT messages - // Включение NAV-PVT сообщений + // Enable NAV-PVT messages PC_SERIAL.println("Enabling NAV-PVT messages..."); enableNavPvt(); @@ -129,9 +105,9 @@ void setup() { GPS_SERIAL.flush(); } -// Function, sending packet to the receiver to restore default configuration -// Функция, отправляющая приёмнику пакет, восстанавливающий конфигурацию по умолчанию -void restoreDefaults() { +// Send a packet to the receiver to restore default configuration +void restoreDefaults() +{ // CFG-CFG packet byte packet[] = { 0xB5, // sync char 1 @@ -160,9 +136,9 @@ void restoreDefaults() { sendPacket(packet, sizeof(packet)); } -// Function, sending set of packets to the receiver to disable NMEA messages -// Функция, отправляющая приёмнику набор пакетов, выключающих отправку NMEA сообщений -void disableNmea() { +// Send a set of packets to the receiver to disable NMEA messages +void disableNmea() +{ // Array of two bytes for CFG-MSG packets payload byte messages[][2] = { {0xF0, 0x0A}, @@ -207,9 +183,11 @@ void disableNmea() { byte payloadOffset = 6; // Iterate over the messages array - for (byte i = 0; i < sizeof(messages) / sizeof(*messages); i++) { + for (byte i = 0; i < sizeof(messages) / sizeof(*messages); i++) + { // Copy two bytes of payload to the packet buffer - for (byte j = 0; j < sizeof(*messages); j++) { + for (byte j = 0; j < sizeof(*messages); j++) + { packet[payloadOffset + j] = messages[i][j]; } @@ -217,9 +195,9 @@ void disableNmea() { packet[packetSize - 2] = 0x00; packet[packetSize - 1] = 0x00; - // Calculate checksum over the packet buffer excluding sync (first two) - // and checksum chars (last two) - for (byte j = 0; j < packetSize - 4; j++) { + // Calculate checksum over the packet buffer excluding sync (first two) and checksum chars (last two) + for (byte j = 0; j < packetSize - 4; j++) + { packet[packetSize - 2] += packet[2 + j]; packet[packetSize - 1] += packet[packetSize - 2]; } @@ -228,9 +206,9 @@ void disableNmea() { } } -// Function, sending packet to the receiver to change baudrate to 115200 -// Функция, отправляющая приёмнику пакет, устанавливающий скорость обмена на 115200 -void changeBaudrate() { +// Send a packet to the receiver to change baudrate to 115200 +void changeBaudrate() +{ // CFG-PRT packet byte packet[] = { 0xB5, // sync char 1 @@ -266,9 +244,9 @@ void changeBaudrate() { sendPacket(packet, sizeof(packet)); } -// Function, sending packet to the receiver to change frequency to 100 ms -// Функция, отправляющая приёмнику пакет, устанавливающий частоту 100 мс -void changeFrequency() { +// Send a packet to the receiver to change frequency to 100 ms +void changeFrequency() +{ // CFG-RATE packet byte packet[] = { 0xB5, // sync char 1 @@ -290,9 +268,9 @@ void changeFrequency() { sendPacket(packet, sizeof(packet)); } -// Function, sending packet to the receiver to disable unnecessary channels -// Функция, отправляющая приёмнику пакет, отключающий ненужные каналы -void disableUnnecessaryChannels() { +// Send a packet to the receiver to disable unnecessary channels +void disableUnnecessaryChannels() +{ // CFG-GNSS packet byte packet[] = { 0xB5, // sync char 1 @@ -306,7 +284,7 @@ void disableUnnecessaryChannels() { 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x00, // payload 0x00, 0x00, 0x00, 0x01, 0x05, 0x00, 0x03, 0x00, // payload 0x00, 0x00, 0x00, 0x01, 0x06, 0x08, 0xFF, 0x00, // payload - 0x00, 0x00, 0x00, 0x01, // payload + 0x00, 0x00, 0x00, 0x01, // payload 0xA4, // CK_A 0x25, // CK_B @@ -315,9 +293,9 @@ void disableUnnecessaryChannels() { sendPacket(packet, sizeof(packet)); } -// Function, sending packet to the receiver to enable NAV-PVT messages -// Функция, отправляющая приёмнику пакет, включающий отправку NAV-PVT сообщений -void enableNavPvt() { +// Send a packet to the receiver to enable NAV-PVT messages +void enableNavPvt() +{ // CFG-MSG packet byte packet[] = { 0xB5, // sync char 1 @@ -336,25 +314,29 @@ void enableNavPvt() { sendPacket(packet, sizeof(packet)); } -// Function, sending specified packed to the receiver -// Функция, отправляющая приёмнику указанный пакет -void sendPacket(byte *packet, byte len) { - for (byte i = 0; i < len; i++) { +// Send the packet specified to the receiver +void sendPacket(byte *packet, byte len) +{ + for (byte i = 0; i < len; i++) + { GPS_SERIAL.write(packet[i]); } printPacket(packet, len); } -// Function, printing packet to the PC's serial in hexadecimal form -// Функция, выводящая пакет компьютеру в шестнадцатеричном виде -void printPacket(byte *packet, byte len) { +// Print the packet specified to the PC serial in a hexadecimal form +void printPacket(byte *packet, byte len) +{ char temp[3]; - for (byte i = 0; i < len; i++) { + for (byte i = 0; i < len; i++) + { sprintf(temp, "%.2X", packet[i]); PC_SERIAL.print(temp); - if (i != len - 1) { + + if (i != len - 1) + { PC_SERIAL.print(' '); } } @@ -362,17 +344,16 @@ void printPacket(byte *packet, byte len) { PC_SERIAL.println(); } -// If there is data from the receiver, read it and send to the PC or vice versa -// Если есть данные от приёмника, то считать и отправить их компьютеру, и наоборот -void loop() { - - if (GPS_SERIAL.available()) { +// If there is a data from the receiver, read it and send to the PC or vice versa +void loop() +{ + if (GPS_SERIAL.available()) + { PC_SERIAL.write(GPS_SERIAL.read()); } - if (PC_SERIAL.available()) { + if (PC_SERIAL.available()) + { GPS_SERIAL.write(PC_SERIAL.read()); } - } - diff --git a/extras/Configuration/Serial-Bridge-Mega/Serial-Bridge-Mega.ino b/extras/Configuration/Serial-Bridge-Mega/Serial-Bridge-Mega.ino index 353279b..1cf1399 100644 --- a/extras/Configuration/Serial-Bridge-Mega/Serial-Bridge-Mega.ino +++ b/extras/Configuration/Serial-Bridge-Mega/Serial-Bridge-Mega.ino @@ -1,38 +1,32 @@ /** - * UBX GPS Library - * Created by Danila Loginov, July 23, 2016 - * https://github.com/1oginov/UBX-GPS-Library + * The sketch is for communication between PC and any other device using Arduino Mega. With u-blox NEO-7M in the case. * - * Sketch for communication between PC and any other device through Arduino Mega. With U-blox NEO-7M in this case. - * Скетч для общения между компьютером и любым другим устройством через Arduino Mega. В данном примере - с U-blox NEO-7M. - * - * U-blox NEO-7M - Arduino Mega + * u-blox NEO-7M - Arduino Mega * VCC - 5V * RX - TX3 * TX - RX3 * GND - GND */ -#define PC_BAUDRATE 9600 -#define GPS_BAUDRATE 9600 +#define PC_BAUDRATE 9600 +#define GPS_BAUDRATE 9600 -void setup() { +void setup() +{ Serial.begin(PC_BAUDRATE); Serial3.begin(GPS_BAUDRATE); } -/** - * If there is data from the device, read it and send to the PC or vice versa. - * Если есть данные от устройства, то считать и отправить их компьютеру, и наоборот. - */ -void loop() { - - if (Serial3.available()) { +// If there is a data from the receiver, read it and send to the PC or vice versa +void loop() +{ + if (Serial3.available()) + { Serial.write(Serial3.read()); } - if (Serial.available()) { + if (Serial.available()) + { Serial3.write(Serial.read()); } - } diff --git a/extras/Configuration/Serial-Bridge-Uno/Serial-Bridge-Uno.ino b/extras/Configuration/Serial-Bridge-Uno/Serial-Bridge-Uno.ino index 6a8e199..d87198b 100644 --- a/extras/Configuration/Serial-Bridge-Uno/Serial-Bridge-Uno.ino +++ b/extras/Configuration/Serial-Bridge-Uno/Serial-Bridge-Uno.ino @@ -1,54 +1,42 @@ /** - * UBX GPS Library - * Created by Danila Loginov, July 23, 2016 - * https://github.com/1oginov/UBX-GPS-Library + * The sketch is for communication between PC and any other device using Arduino Uno. With u-blox NEO-7M in the case. * - * Sketch for communication between PC and any other device through Arduino Uno. With U-blox NEO-7M in this case. - * Скетч для общения между компьютером и любым другим устройством через Arduino Uno. В данном примере - с U-blox NEO-7M. + * Because the Arduino Uno is used, which has only 1 USART, we have to deal with not quite stable `SoftwareSerial` + * library. If there is one another hardware USART on your board, it's better to use it and replace `ss` with a + * `Serial2`, for example. * - * U-blox NEO-7M - Arduino Uno + * u-blox NEO-7M - Arduino Uno * VCC - 5V * RX - 3 * TX - 2 * GND - GND */ -#define PC_BAUDRATE 9600 -#define GPS_BAUDRATE 9600 -#define GPS_RX 3 -#define GPS_TX 2 +#define PC_BAUDRATE 9600 +#define GPS_BAUDRATE 9600 +#define GPS_RX 3 +#define GPS_TX 2 -/** - * Because the Arduino Uno is used, which has only 1 USART, we have to deal - * with not quite stable SoftwareSerial library. If there is one another - * hardware USART on your board, it's better to use it and replace ss with - * Serial2, for example. - * - * Так как используется Arduino Uno, у которого только 1 USART, приходится - * задействовать не совсем стабильную библиотеку SoftwareSerial. Если - * на плате есть еще один аппаратный USART, то лучше использовать его - * и в коде заменить ss на Serial2, например. - */ #include + SoftwareSerial ss(GPS_TX, GPS_RX); -void setup() { +void setup() +{ Serial.begin(PC_BAUDRATE); ss.begin(GPS_BAUDRATE); } -/** - * If there is data from the device, read it and send to the PC or vice versa. - * Если есть данные от устройства, то считать и отправить их компьютеру, и наоборот. - */ -void loop() { - - if (ss.available()) { +// If there is a data from the receiver, read it and send to the PC or vice versa +void loop() +{ + if (ss.available()) + { Serial.write(ss.read()); } - if (Serial.available()) { + if (Serial.available()) + { ss.write(Serial.read()); } - } diff --git a/keywords.txt b/keywords.txt index 99f2a55..2044c8d 100644 --- a/keywords.txt +++ b/keywords.txt @@ -1,4 +1,4 @@ -####################################### +####################################### # Syntax Coloring Map For UbxGps ####################################### diff --git a/src/UbxGps.cpp b/src/UbxGps.cpp index 8561a52..5e020c4 100644 --- a/src/UbxGps.cpp +++ b/src/UbxGps.cpp @@ -1,94 +1,106 @@ -/** - * UBX GPS Library - * Created by Danila Loginov, July 23, 2016 - * https://github.com/1oginov/UBX-GPS-Library - */ - #include "UbxGps.h" -UbxGps::UbxGps(HardwareSerial& serial) : serial(serial) { +UbxGps::UbxGps(HardwareSerial &serial) : serial(serial) +{ this->carriagePosition = 0; } -void UbxGps::setLength(unsigned char length) { +void UbxGps::setLength(unsigned char length) +{ this->size = length + this->offsetHeaders; } -void UbxGps::begin(long speed) { +void UbxGps::begin(long speed) +{ return this->serial.begin(speed); } -int UbxGps::available() { +int UbxGps::available() +{ return this->serial.available(); } -byte UbxGps::read() { +byte UbxGps::read() +{ return this->serial.read(); } -void UbxGps::calculateChecksum() { +void UbxGps::calculateChecksum() +{ memset(this->checksum, 0, 2); - for (int i = 0; i < this->size; i++) { - this->checksum[0] += ((unsigned char*)(this))[i + this->offsetClassProperties]; + + for (int i = 0; i < this->size; i++) + { + this->checksum[0] += ((unsigned char *)(this))[i + this->offsetClassProperties]; this->checksum[1] += this->checksum[0]; } } -boolean UbxGps::ready() { +boolean UbxGps::ready() +{ unsigned char p = this->carriagePosition; - while (this->available()) { + while (this->available()) + { byte c = this->read(); - // Carriage is at first or second sync byte, should be equals - if (p < 2) { - if (c == UBXGPS_HEADER[p]) { + // Carriage is at the first or the second sync byte, should be equals + if (p < 2) + { + if (c == UBXGPS_HEADER[p]) + { p++; } // Reset if not - else { + else + { p = 0; } } - - // After successful sync with header - else { - - // Put byte read to particular address of this object which depends on carriage position - if (p < (this->size + 2)) { - ((unsigned char*)(this))[p - 2 + this->offsetClassProperties] = c; + // Sync with header after success + else + { + // Put the byte read to a particular address of this object which depends on the carriage position + if (p < (this->size + 2)) + { + ((unsigned char *)(this))[p - 2 + this->offsetClassProperties] = c; } // Move the carriage forward p++; - // Carriage is at the first checksum byte, we can calculate our checksum, but not compare because this byte is not read - if (p == (this->size + 2)) { + // Carriage is at the first checksum byte, we can calculate our checksum, but not compare, because this byte + // is not read + if (p == (this->size + 2)) + { this->calculateChecksum(); } - - // Carriage is at the second checksum byte, but only the first byte of checksum read, check if it equals to ours - else if (p == (this->size + 3)) { + // Carriage is at the second checksum byte, but only the first byte of checksum read, check if it equals to + // ours + else if (p == (this->size + 3)) + { // Reset if not - if (c != this->checksum[0]) { + if (c != this->checksum[0]) + { p = 0; } } - // Carriage is after the second checksum byte, which has been read, check if it equals to ours - else if (p == (this->size + 4)) { + else if (p == (this->size + 4)) + { // Reset the carriage p = 0; // The readings are correct and filled the object, return true - if (c == this->checksum[1]) { + if (c == this->checksum[1]) + { this->carriagePosition = p; return true; } } - - // Reset the carriage if it is out of packet - else if (p > (this->size + 4)) { + // Reset the carriage if it is out of a packet + else if (p > (this->size + 4)) + { p = 0; } } diff --git a/src/UbxGps.h b/src/UbxGps.h index 529dff2..f6bb2c4 100644 --- a/src/UbxGps.h +++ b/src/UbxGps.h @@ -1,32 +1,27 @@ -/** - * UBX GPS Library - * Created by Danila Loginov, July 23, 2016 - * https://github.com/1oginov/UBX-GPS-Library - */ - #ifndef UBXGPS_H_ #define UBXGPS_H_ #include "Arduino.h" -const unsigned char UBXGPS_HEADER[] = { 0xB5, 0x62 }; +const unsigned char UBXGPS_HEADER[] = {0xB5, 0x62}; -class UbxGps { -public: +class UbxGps +{ + public: void begin(long); boolean ready(); -protected: - UbxGps(HardwareSerial&); + protected: + UbxGps(HardwareSerial &); void setLength(unsigned char); -private: + private: int available(); byte read(); void calculateChecksum(); // Class properties - HardwareSerial& serial; + HardwareSerial &serial; unsigned char offsetClassProperties = 8; unsigned char offsetHeaders = 4; unsigned char size; diff --git a/src/UbxGpsNavPosecef.h b/src/UbxGpsNavPosecef.h index fb6b988..15f2a62 100644 --- a/src/UbxGpsNavPosecef.h +++ b/src/UbxGpsNavPosecef.h @@ -1,25 +1,21 @@ -/** - * UBX GPS Library - * Created by Danila Loginov, July 2, 2017 - * https://github.com/1oginov/UBX-GPS-Library - */ - #ifndef UBXGPSNAVPOSECEF_H_ #define UBXGPSNAVPOSECEF_H_ #include "UbxGps.h" -class UbxGpsNavPosecef : public UbxGps { -public: - - // Type Name Unit Description (scaling) - unsigned long iTOW; // ms GPS time of week of the navigation epoch. See the description of iTOW for details. - long ecefX; // cm ECEF X coordinate - long ecefY; // cm ECEF Y coordinate - long ecefZ; // cm ECEF Z coordinate - unsigned long pAcc; // cm Position Accuracy Estimate +class UbxGpsNavPosecef : public UbxGps +{ + public: + // Type Name Unit Description (scaling) + unsigned long iTOW; // ms GPS time of week of the navigation epoch. See the description of iTOW for + // details + long ecefX; // cm ECEF X coordinate + long ecefY; // cm ECEF Y coordinate + long ecefZ; // cm ECEF Z coordinate + unsigned long pAcc; // cm Position Accuracy Estimate - UbxGpsNavPosecef(HardwareSerial& serial) : UbxGps(serial) { + UbxGpsNavPosecef(HardwareSerial &serial) : UbxGps(serial) + { this->setLength(20); } }; diff --git a/src/UbxGpsNavPosllh.h b/src/UbxGpsNavPosllh.h index 3d19071..b39ddd4 100644 --- a/src/UbxGpsNavPosllh.h +++ b/src/UbxGpsNavPosllh.h @@ -1,27 +1,23 @@ -/** - * UBX GPS Library - * Created by Danila Loginov, July 23, 2016 - * https://github.com/1oginov/UBX-GPS-Library - */ - #ifndef UBXGPSNAVPOSLLH_H_ #define UBXGPSNAVPOSLLH_H_ #include "UbxGps.h" -class UbxGpsNavPosllh : public UbxGps { -public: - - // Type Name Unit Description (scaling) - unsigned long iTOW; // ms GPS time of week of the navigation epoch. See the description of iTOW for details. - long lon; // deg Longitude (1e-7) - long lat; // deg Latitude (1e-7) - long height; // mm Height above ellipsoid - long hMSL; // mm Height above mean sea level - unsigned long hAcc; // mm Horizontal accuracy estimate - unsigned long vAcc; // mm Vertical accuracy estimate +class UbxGpsNavPosllh : public UbxGps +{ + public: + // Type Name Unit Description (scaling) + unsigned long iTOW; // ms GPS time of week of the navigation epoch. See the description of iTOW for + // details + long lon; // deg Longitude (1e-7) + long lat; // deg Latitude (1e-7) + long height; // mm Height above ellipsoid + long hMSL; // mm Height above mean sea level + unsigned long hAcc; // mm Horizontal accuracy estimate + unsigned long vAcc; // mm Vertical accuracy estimate - UbxGpsNavPosllh(HardwareSerial& serial) : UbxGps(serial) { + UbxGpsNavPosllh(HardwareSerial &serial) : UbxGps(serial) + { this->setLength(28); } }; diff --git a/src/UbxGpsNavPvt.h b/src/UbxGpsNavPvt.h index 490a3b1..69804be 100644 --- a/src/UbxGpsNavPvt.h +++ b/src/UbxGpsNavPvt.h @@ -1,50 +1,46 @@ -/** - * UBX GPS Library - * Created by Danila Loginov, July 23, 2016 - * https://github.com/1oginov/UBX-GPS-Library - */ - #ifndef UBXGPSNAVPVT_H_ #define UBXGPSNAVPVT_H_ #include "UbxGps.h" -class UbxGpsNavPvt : public UbxGps { -public: - - // Type Name Unit Description (scaling) - unsigned long iTOW; // ms GPS time of week of the navigation epoch. See the description of iTOW for details. - unsigned short year; // y Year UTC - unsigned char month; // month Month, range 1..12 UTC - unsigned char day; // d Day of month, range 1..31 UTC - unsigned char hour; // h Hour of day, range 0..23 UTC - unsigned char min; // min Minute of hour, range 0..59 UTC - unsigned char sec; // s Seconds of minute, range 0..60 UTC - char valid; // - Validity Flags (see graphic below) - unsigned long tAcc; // ns Time accuracy estimate UTC - long nano; // ns Fraction of second, range -1e9..1e9 UTC - unsigned char fixType; // - GNSSfix Type, range 0..5 - char flags; // - Fix Status Flags (see graphic below) - unsigned char reserved1; // - Reserved - unsigned char numSV; // - Number of satellites used in Nav Solution - long lon; // deg Longitude (1e-7) - long lat; // deg Latitude (1e-7) - long height; // mm Height above Ellipsoid - long hMSL; // mm Height above mean sea level - unsigned long hAcc; // mm Horizontal Accuracy Estimate - unsigned long vAcc; // mm Vertical Accuracy Estimate - long velN; // mm/s NED north velocity - long velE; // mm/s NED east velocity - long velD; // mm/s NED down velocity - long gSpeed; // mm/s Ground Speed (2-D) - long heading; // deg Heading of motion 2-D (1e-5) - unsigned long sAcc; // mm/s Speed Accuracy Estimate - unsigned long headingAcc; // deg Heading Accuracy Estimate (1e-5) - unsigned short pDOP; // - Position DOP (0.01) - short reserved2; // - Reserved - unsigned long reserved3; // - Reserved +class UbxGpsNavPvt : public UbxGps +{ + public: + // Type Name Unit Description (scaling) + unsigned long iTOW; // ms GPS time of week of the navigation epoch. See the description of iTOW for + // details + unsigned short year; // y Year UTC + unsigned char month; // month Month, range 1..12 UTC + unsigned char day; // d Day of month, range 1..31 UTC + unsigned char hour; // h Hour of day, range 0..23 UTC + unsigned char min; // min Minute of hour, range 0..59 UTC + unsigned char sec; // s Seconds of minute, range 0..60 UTC + char valid; // - Validity Flags (see graphic below) + unsigned long tAcc; // ns Time accuracy estimate UTC + long nano; // ns Fraction of second, range -1e9..1e9 UTC + unsigned char fixType; // - GNSSfix Type, range 0..5 + char flags; // - Fix Status Flags (see graphic below) + unsigned char reserved1; // - Reserved + unsigned char numSV; // - Number of satellites used in Nav Solution + long lon; // deg Longitude (1e-7) + long lat; // deg Latitude (1e-7) + long height; // mm Height above Ellipsoid + long hMSL; // mm Height above mean sea level + unsigned long hAcc; // mm Horizontal Accuracy Estimate + unsigned long vAcc; // mm Vertical Accuracy Estimate + long velN; // mm/s NED north velocity + long velE; // mm/s NED east velocity + long velD; // mm/s NED down velocity + long gSpeed; // mm/s Ground Speed (2-D) + long heading; // deg Heading of motion 2-D (1e-5) + unsigned long sAcc; // mm/s Speed Accuracy Estimate + unsigned long headingAcc; // deg Heading Accuracy Estimate (1e-5) + unsigned short pDOP; // - Position DOP (0.01) + short reserved2; // - Reserved + unsigned long reserved3; // - Reserved - UbxGpsNavPvt(HardwareSerial& serial) : UbxGps(serial) { + UbxGpsNavPvt(HardwareSerial &serial) : UbxGps(serial) + { this->setLength(84); } }; diff --git a/src/UbxGpsNavSol.h b/src/UbxGpsNavSol.h index c2f6e9e..fd54a39 100644 --- a/src/UbxGpsNavSol.h +++ b/src/UbxGpsNavSol.h @@ -1,37 +1,34 @@ -/** - * UBX GPS Library - * Created by Danila Loginov, July 23, 2016 - * https://github.com/1oginov/UBX-GPS-Library - */ - #ifndef UBXGPSNAVSOL_H_ #define UBXGPSNAVSOL_H_ #include "UbxGps.h" -class UbxGpsNavSol : public UbxGps { -public: - - // Type Name Unit Description (scaling) - unsigned long iTOW; // ms GPS time of week of the navigation epoch. See the description of iTOW for details. - long fTOW; // ns Fractional part of iTOW (range: +/-500000). The precise GPS time of week in seconds is: (iTOW * 1e-3) + (fTOW * 1e-9) - short week; // weeks GPS week number of the navigation epoch - unsigned char gpsFix; // - GPSfix Type, range 0..5 - char flags; // - Fix Status Flags (see graphic below) - long ecefX; // cm ECEF X coordinate - long ecefY; // cm ECEF Y coordinate - long ecefZ; // cm ECEF Z coordinate - unsigned long pAcc; // cm 3D Position Accuracy Estimate - long ecefVX; // cm/s ECEF X velocity - long ecefVY; // cm/s ECEF Y velocity - long ecefVZ; // cm/s ECEF Z velocity - unsigned long sAcc; // cm/s Speed Accuracy Estimate - unsigned short pDOP; // - Position DOP (0.01) - unsigned char reserved1; // - Reserved - unsigned char numSV; // - Number of satellites used in Nav Solution - unsigned long reserved2; // - Reserved +class UbxGpsNavSol : public UbxGps +{ + public: + // Type Name Unit Description (scaling) + unsigned long iTOW; // ms GPS time of week of the navigation epoch. See the description of iTOW for + // details + long fTOW; // ns Fractional part of iTOW (range: +/-500000). The precise GPS time of week in + // seconds is: (iTOW * 1e-3) + (fTOW * 1e-9) + short week; // weeks GPS week number of the navigation epoch + unsigned char gpsFix; // - GPSfix Type, range 0..5 + char flags; // - Fix Status Flags (see graphic below) + long ecefX; // cm ECEF X coordinate + long ecefY; // cm ECEF Y coordinate + long ecefZ; // cm ECEF Z coordinate + unsigned long pAcc; // cm 3D Position Accuracy Estimate + long ecefVX; // cm/s ECEF X velocity + long ecefVY; // cm/s ECEF Y velocity + long ecefVZ; // cm/s ECEF Z velocity + unsigned long sAcc; // cm/s Speed Accuracy Estimate + unsigned short pDOP; // - Position DOP (0.01) + unsigned char reserved1; // - Reserved + unsigned char numSV; // - Number of satellites used in Nav Solution + unsigned long reserved2; // - Reserved - UbxGpsNavSol(HardwareSerial& serial) : UbxGps(serial) { + UbxGpsNavSol(HardwareSerial &serial) : UbxGps(serial) + { this->setLength(52); } }; From 9158c8149ac6f3e54f7e466b9af82eb6f3cab9e8 Mon Sep 17 00:00:00 2001 From: Danila Loginov Date: Sun, 3 Dec 2017 15:37:39 +0300 Subject: [PATCH 8/9] chore: add library.properties --- library.properties | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 library.properties diff --git a/library.properties b/library.properties new file mode 100644 index 0000000..1286995 --- /dev/null +++ b/library.properties @@ -0,0 +1,9 @@ +name=UbxGps +version=1.3.0 +author=Danila Loginov +maintainer=Danila Loginov +sentence=A library for the fastest and simplest communication with u-blox GPS modules. +paragraph=Supports proprietary UBX protocol that is more compact than common NMEA and can be used to achieve real 10 Hz. +category=Communication +url=https://github.com/1oginov/UbxGps +architectures=* From 297b269be763dbe2d16212eb0bf1547030bfdb1d Mon Sep 17 00:00:00 2001 From: Danila Loginov Date: Sun, 3 Dec 2017 16:00:32 +0300 Subject: [PATCH 9/9] chore: update readme --- README.md | 168 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 105 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 2badc3c..5166f1a 100644 --- a/README.md +++ b/README.md @@ -1,157 +1,199 @@ -# UBX GPS Library +# UbxGps -**This Arduino library was developed for the fastest and simplest communication with u-blox GPS modules**, which supports proprietary UBX protocol that is more compact than common NMEA. Main idea was to achieve real 10 Hz from NEO-7M and it was done. Huge thanks to **iforce2d** for [tutorial video](https://www.youtube.com/watch?v=TwhCX0c8Xe0) whose code is laid in the basics of this library. +**This Arduino library was developed for the fastest and simplest communication with u-blox GPS modules**, which +support proprietary UBX protocol that is more compact than common NMEA. Main idea was to achieve real 10 Hz from NEO-7M +and it was done. Huge thanks to **iforce2d** for a [tutorial video](https://www.youtube.com/watch?v=TwhCX0c8Xe0) whose +code is laid in the basics of the library. -This library depends on GPS module configuration and can handle only one type of UBX packet, which you can choose during [GPS module configuration](#gps-module-configuration). UBX GPS Library provides easy-to-use interface to all the available data in accordance with the Protocol Specification that you can find in the `Docs` directory. Also, full description of fields is accessible in the source codes. +This library depends on GPS module configuration and can handle only one type of UBX packet at a time, which you can +choose during [GPS module configuration](#gps-module-configuration). UbxGps provides easy-to-use interface to all the +available data in accordance with the Protocol Specification that you can find in the +[Docs](https://github.com/1oginov/UbxGps/tree/master/extras/Docs) directory. Also, full description of properties is +accessible in the source codes. -#### UbxGpsNavPosecef.h +## Supported UBX packets -_NAV-POSECEF (Position Solution in ECEF):_ iTOW, ecefX, ecefY, ecefZ, pAcc +UBX packets supported by the library are listed below. Feel free to add other packets to the library, since the library +is designed to make new packets as easy as it can be. -#### UbxGpsNavPosllh.h +### UbxGpsNavPosecef.h -_NAV-POSLLH (Geodetic Position Solution):_ iTOW, lon, lat, height, hMSL, hAcc, vAcc +*NAV-POSECEF (Position Solution in ECEF):* iTOW, ecefX, ecefY, ecefZ, pAcc. -#### UbxGpsNavPvt.h +### UbxGpsNavPosllh.h -_NAV-PVT (Navigation Position Velocity Time Solution):_ iTOW, year, month, day, hour, min, sec, valid, tAcc, nano, fixType, flags, reserved1, numSV, lon, lat, height, hMSL, hAcc, vAcc, velN, velE, velD, gSpeed, heading, sAcc, headingAcc, pDOP, reserved2, reserved3 +*NAV-POSLLH (Geodetic Position Solution):* iTOW, lon, lat, height, hMSL, hAcc, vAcc. -#### UbxGpsNavSol.h +### UbxGpsNavPvt.h -_NAV-SOL (Navigation Solution Information):_ iTOW, fTOW, week, gpsFix, flags, ecefX, ecefY, ecefZ, pAcc, ecefVX, ecefVY, ecefVZ, sAcc, pDOP, reserved1, numSV, reserved2 +*NAV-PVT (Navigation Position Velocity Time Solution):* iTOW, year, month, day, hour, min, sec, valid, tAcc, nano, +fixType, flags, reserved1, numSV, lon, lat, height, hMSL, hAcc, vAcc, velN, velE, velD, gSpeed, heading, sAcc, +headingAcc, pDOP, reserved2, reserved3. -### Note for Uno users +### UbxGpsNavSol.h -This library is designed to work with GPS module through the hardware serial ports, but Uno has only one pair. It means that you can configure GPS module, but the library will occupy serial port and you need to do something more to get the data from it. For example: add an SD card to store the data, or transmit it through the Bluetooth or Ethernet. `SoftwareSerial` is not supported because it isn't quite stable for working on high frequency. +*NAV-SOL (Navigation Solution Information):* iTOW, fTOW, week, gpsFix, flags, ecefX, ecefY, ecefZ, pAcc, ecefVX, ecefVY, +ecefVZ, sAcc, pDOP, reserved1, numSV, reserved2. ## Quick Start -Download `UbxGps` and place it to the Arduino libraries directory. Refer to [How to install Libraries](https://www.arduino.cc/en/Guide/Libraries) for details. +Download `UbxGps` and place it to the Arduino libraries directory. Refer to +[How to install Libraries](https://www.arduino.cc/en/Guide/Libraries) for details. -Next step is configuring your GPS module properly, to find out how to do this see section [GPS module configuration](#gps-module-configuration). Also, take a look at the [Auto-configuration](https://github.com/1oginov/UBX-GPS-Library/blob/master/Configuration/Auto-configuration-Mega/Auto-configuration-Mega.ino) sketch for the Arduino Mega boards to configure your GPS module automatically to get NAV-PVT messages with 100 ms frequency and 115200 baudrate. +Next step is configuring your GPS module properly, to find out how to do this check section +[GPS module configuration](#gps-module-configuration). Also, take a look at the +[Auto-configuration](https://github.com/1oginov/UBX-GPS-Library/blob/master/extras/Configuration/Auto-configuration-Mega/Auto-configuration-Mega.ino) +sketch for the Arduino Mega boards to configure your GPS module automatically to get NAV-PVT messages with 100 ms +frequency and 115200 baudrate. -After that you can use included examples or play with following simple sketch: +After that you can use included examples or play with the following simple sketch: ```cpp #include "UbxGpsNavPvt.h" UbxGpsNavPvt gps(Serial3); -void setup() { +void setup() +{ Serial.begin(9600); gps.begin(9600); } -void loop() { - if (gps.ready()) { - Serial.print(gps.lon / 10000000.0, 7); Serial.print(','); - Serial.print(gps.lat / 10000000.0, 7); Serial.print(','); - Serial.print(gps.height / 1000.0, 3); Serial.print(','); +void loop() +{ + if (gps.ready()) + { + Serial.print(gps.lon / 10000000.0, 7); + Serial.print(','); + Serial.print(gps.lat / 10000000.0, 7); + Serial.print(','); + Serial.print(gps.height / 1000.0, 3); + Serial.print(','); Serial.println(gps.gSpeed * 0.0036, 5); } } ``` +### Note for Uno users + +The library is designed to work with GPS module through a hardware serial port, but Uno has only one. It means that you +can configure GPS module, but the library will occupy serial port and you need to do something more to get the data from +it. For example: add an SD card to store the data, or transmit it through the Bluetooth or Ethernet. `SoftwareSerial` +can be used, but I can't guarantee it will work without bugs on a high frequency. + ## GPS module configuration ### Step 1. Wiring -So we have an Arduino board and a GPS module. Wiring is pretty simple: `GND` to `GND`, `VCC` to `5V`, `TX` to `RX` and `RX` to `TX`. -Because of Uno has only one TX/RX pair we should connect GPS module's `TX` to the `2` pin and `RX` to the `3` pin and use `SoftwareSerial` library for communicate with GPS. If you have something with more than one TX/RX pair on the board you can use it, for example for Mega we can connect GPS's `RX` to the `TX3` and `TX` to the `RX3`. +So we have an Arduino board and a GPS module. Wiring is pretty simple: `GND` to `GND`, `VCC` to `5V`, `TX` to `RX` and +`RX` to `TX`. Because of Uno has only one TX/RX pair we should connect GPS module `TX` to the `2` pin and `RX` to the +`3` pin and use `SoftwareSerial` library for communicate with GPS. If you have something with more than one TX/RX pair +on the board you can use it, for example for Mega we can connect GPS `RX` to the `TX3` and `TX` to the `RX3`. -![Wiring](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/Configuration/Step%201.%20Wiring.jpg) +![Wiring](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/extras/Configuration/Step%201.%20Wiring.jpg) ### Auto-configuration -After wiring you can upload the [Auto-configuration](https://github.com/1oginov/UBX-GPS-Library/blob/master/Configuration/Auto-configuration-Mega/Auto-configuration-Mega.ino) sketch for the Arduino Mega boards to configure your GPS module automatically. +After wiring you can upload the +[Auto-configuration](https://github.com/1oginov/UBX-GPS-Library/blob/master/extras/Configuration/Auto-configuration-Mega/Auto-configuration-Mega.ino) +sketch for the Arduino Mega boards to configure your GPS module automatically. -At the moment it configures the receiver to get NAV-PVT messages with 100 ms frequency and 115200 baudrate, but you can change it according your needs. +At the moment it configures the receiver to get NAV-PVT messages with 100 ms frequency and 115200 baudrate, but you can +change it according your needs. -You are not required to follow next steps and [use u-center](#step-3-meet-u-center) after that, you can pass to the [Checks](#step-9-checks) step instead. +You are not required to follow next steps and [use u-center](#step-3-meet-u-center) after that, you can pass to the +[Checks](#step-9-checks) step instead. -![Auto-configuration](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/Configuration/Auto-configuration.jpg) +![Auto-configuration](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/extras/Configuration/Auto-configuration.jpg) ### Step 2. Serial bridge -Let's make a bridge between GPS module and computer: upload `Serial-Bridge-Uno.ino` or `Serial-Bridge-Mega.ino` sketch on the board, it allows us to communicate with GPS module directly from computer. Open _Serial Monitor_, and if your GPS module is new or have default settings you will see something like on the picture below. If everything is OK, GPS will send some data. +Let's make a bridge between GPS module and computer: upload `Serial-Bridge-Uno.ino` or `Serial-Bridge-Mega.ino` sketch +on the board, it allows us to communicate with GPS module directly from computer. Open *Serial Monitor*, and if your GPS +module is new or have default settings you will see something like on the picture below. If everything is OK, GPS will +send some data. -![Serial bridge](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/Configuration/Step%202.%20Serial%20bridge.jpg) +![Serial bridge](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/extras/Configuration/Step%202.%20Serial%20bridge.jpg) ### Step 3. Meet u-center -For u-blox GPS module configuration we will use **u-center** program that you can find [here](https://www.u-blox.com/en/product/u-center-windows). It parses data from GPS module and provides useful tools to work with it. Launch program, choose appropriate COM port and set baudrate, 9600 for default. It will start getting some data. +For u-blox GPS module configuration we will use **u-center** program that you can find +[here](https://www.u-blox.com/en/product/u-center-windows). It parses data from GPS module and provides useful tools to +work with it. Launch program, choose appropriate COM port and set baudrate, 9600 for default. It will start getting some +data. -![Meet u-center](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/Configuration/Step%203.%20Meet%20u-center.jpg) +![Meet u-center](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/extras/Configuration/Step%203.%20Meet%20u-center.jpg) ### Step 4. Change baudrate (if you want) -If you have something with more than one TX/RX pair it will be useful to raise the baudrate of GPS module. It can helps if you gonna work with high frequency like 5 or 10 Hz. Open _View — Messages View_ window and find _UBX — CGF — PRT_ item. Set the baudrate to 115200 for example and click _Send_ button at the bottom left corner. +If you have something with more than one TX/RX pair it will be useful to raise the baudrate of GPS module. It can helps +if you gonna work with high frequency like 5 or 10 Hz. Open *View — Messages View* window and find *UBX — CGF — PRT* +item. Set the baudrate to 115200 for example and click *Send* button at the bottom left corner. Changing baudrate using `SoftwareSerial` library can cause errors! -GPS module will stops getting data, because our sketch works with old baudrate. Disconnect from COM port in u-center, update `GPS_BAUDRATE` and `PC_BAUDRATE` if you want and uploads it to the board. Reconnect u-center and it should works! +GPS module will stops getting data, because our sketch works with old baudrate. Disconnect from COM port in u-center, +update `GPS_BAUDRATE` and `PC_BAUDRATE` if you want and uploads it to the board. Reconnect u-center and it should works! -![Change baudrate](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/Configuration/Step%204.%20Change%20baudrate.jpg) +![Change baudrate](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/extras/Configuration/Step%204.%20Change%20baudrate.jpg) ### Step 5. Change frequency (if you want) -In _Messages View_ in the _UBX — CFG — RATE_ tab you can change _Measurement Period_ to raise frequency of getting data. I want to achieve 10 Hz, so I change _Measurement Period_ to the 100 milliseconds and clicks _Send_ button. +In *Messages View* in the *UBX — CFG — RATE* tab you can change *Measurement Period* to raise frequency of getting +data. I want to achieve 10 Hz, so I change *Measurement Period* to the 100 milliseconds and click *Send* button. -![Change frequency](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/Configuration/Step%205.%20Change%20frequency.jpg) +![Change frequency](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/extras/Configuration/Step%205.%20Change%20frequency.jpg) ### Step 6. Disable unnecessary channels -To make GPS module’s life easier, we can disable unnecessary channels in the _UBX — CFG — GNSS_ tab. We only need GPS, so uncheck other channels at _enable_ column. Again, click _Send_ to save changes. +To make GPS module life easier, we can disable unnecessary channels in the *UBX — CFG — GNSS* tab. We only need GPS, +so uncheck other channels at *enable* column. Again, click *Send* to save changes. -![Serial bridge](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/Configuration/Step%206.%20Disable%20unnecessary%20channels.jpg) +![Serial bridge](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/extras/Configuration/Step%206.%20Disable%20unnecessary%20channels.jpg) ### Step 7. Choose packet -UBX GPS library works with only one type of packet which is UBX, so we need to fully disable NMEA packets and enable one of the UBX group. Open context menu on _Messages View — NMEA_ and click _Disable Child Messages_. u-center will send appropriate command to the GPS module and getting data will stops. If you’re using `SoftwareSerial` it can takes a time to get things right, try to click _Disable Child Messages_ again if it not works. +UBX GPS library works with only one type of packet which is UBX, so we need to fully disable NMEA packets and enable one +of the UBX group. Open context menu on *Messages View — NMEA* and click *Disable Child Messages*. u-center will send +appropriate command to the GPS module and getting data will stops. If you're using `SoftwareSerial` it can takes a time +to get things right, try to click *Disable Child Messages* again if it not works. -Then, choose UBX packet you want to work with, for example _UBX — NAV — PVT_, open context menu on it and click _Enable Message_, GPS module will start getting data again. Open _View — Packet Console_ to see if everything is OK, it should get one type of UBX packet with chosen frequency. +Then, choose UBX packet you want to work with, for example *UBX — NAV — PVT*, open context menu on it and click +*Enable Message*, GPS module will start getting data again. Open *View — Packet Console* to see if everything is OK, it +should get one type of UBX packet with chosen frequency. -![Choose packet](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/Configuration/Step%207.%20Choose%20packet.gif) +![Choose packet](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/extras/Configuration/Step%207.%20Choose%20packet.gif) ### Step 8. Save configuration -Go to _UBX — CFG — CFG_ and click _Send_ to save current configuration. +Go to *UBX — CFG — CFG* and click *Send* to save current configuration. -**Important!** GPS module will remember what we’ve done, but sometimes it is not enough: GPS module can return to factory settings after a long time without power, so check your battery on the GPS module. +**Important!** GPS module will remember what we've done, but sometimes it is not enough: GPS module can return to +factory settings after a long time without power, so check your battery on the GPS module. -![Save configuration](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/Configuration/Step%208.%20Save%20configuration.jpg) +![Save configuration](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/extras/Configuration/Step%208.%20Save%20configuration.jpg) ### Step 9. Checks -Close u-center and open an example `NavPvt` sketch, check baudrate and upload it to the board. If everything is OK you’ll get desired data. **That’s all Folks!** +Close u-center and open an example `NavPvt` sketch, check baudrate and upload it to the board. If everything is OK +you'll get desired data. **That's all Folks!** -![Checks](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/Configuration/Step%209.%20Checks.jpg) +![Checks](https://raw.githubusercontent.com/1oginov/UBX-GPS-Library/master/extras/Configuration/Step%209.%20Checks.jpg) -More details about u-blox GPS module configuration you can find in _**Receiver Description** — Receiver Configuration_ in the `Docs` directory. +More details about u-blox GPS module configuration you can find in ***Receiver Description** — Receiver Configuration* +in the [Docs](https://github.com/1oginov/UbxGps/tree/master/extras/Docs) directory. ## Compatible GPS modules * NEO-7M — tested * Other u-blox GPS modules, which supports UBX protocol -* _Please, notice me if it works with your GPS module_ +* *Please, notice me if it works with your GPS module* ## Contribution Feel free to add something useful to this library :relaxed: For example new classes for UBX packets! -## History - -### July 3, 2017 - -Auto-configuration sketch for the Arduino Mega boards added - -### July 2, 2017 - -UbxGpsNavPosecef.h added - -### July 23, 2016 - -First release +Please, use the [dev](https://github.com/1oginov/UbxGps/tree/dev) branch for contribution. ## Links