Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 3a3ab5c

Browse files
authored
Merge pull request #170 from sparkfun/v1.8.10_begin_and_isConnected_improvements
v1.8.10. u-blox corrections. Improved .begin and .isConnected.
2 parents 1ceae4d + e53424c commit 3a3ab5c

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SparkFun u-blox Arduino Library
2020

2121
U-blox makes some incredible GPS receivers covering everything from low-cost, highly configurable modules such as the SAM-M8Q all the way up to the surveyor grade ZED-F9P with precision of the diameter of a dime. This library focuses on configuration and control of u-blox devices over I2C (called DDC by u-blox) and Serial. The UBX protocol is supported over both I2C and serial, and is a much easier and lighterweight interface to a GPS module. Stop parsing NMEA data! And simply ask for the datums you need.
2222

23-
This library can be installed via the Arduino Library manager. Search for **SparkFun Ublox**.
23+
This library can be installed via the Arduino Library manager. Search for **SparkFun u-blox GNSS**.
2424

2525
Although not an integrated part of the library, you will find an example of how to communicate with the older series 6 and 7 modules in the [examples folder](./examples/Series_6_7).
2626

@@ -58,7 +58,7 @@ Thanks to:
5858

5959
Need a Python version for Raspberry Pi? Checkout the [Qwiic Ublox GPS Py module](https://github.com/sparkfun/Qwiic_Ublox_Gps_Py).
6060

61-
Need a library for the Ublox and Particle? Checkout the [Particle library](https://github.com/aseelye/SparkFun_Ublox_Particle_Library) fork.
61+
Need a library for the u-blox and Particle? Checkout the [Particle library](https://github.com/aseelye/SparkFun_Ublox_Particle_Library) fork.
6262

6363
Contributing
6464
--------------

Theory.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
How I2C (aka DDC) communication works with a uBlox module
1+
How I2C (aka DDC) communication works with a u-blox module
22
===========================================================
33

4-
When the user calls one of the methods the library will poll the Ublox module for new data.
4+
When the user calls one of the methods the library will poll the u-blox module for new data.
55

66
* Wait for a minimum of 25 ms between polls (configured dynamically when update rate is set)
77
* Write 0xFD to module
@@ -17,9 +17,9 @@ How data is processed by this library
1717

1818
A method will call **sendCommand()**. This will begin waiting for a response with either **waitForACKResponse()** or **waitForNoACKResponse()** depending on the command we have sent (CFG commands generate an ACK where others like PVT do not).
1919

20-
Once **waitForACKResponse()** or **waitForNoACKResponse()** is called the library will start checking the ublox module for new bytes. These bytes may be part of a NMEA sentence, an RTCM sentence, or a UBX packet. The library will file each byte into the appropriate container. Once a given sentence or packet is complete, the appropriate processUBX(), processNMEA() will be called. These functions deal with specific processing for each type.
20+
Once **waitForACKResponse()** or **waitForNoACKResponse()** is called the library will start checking the u-blox module for new bytes. These bytes may be part of a NMEA sentence, an RTCM sentence, or a UBX packet. The library will file each byte into the appropriate container. Once a given sentence or packet is complete, the appropriate processUBX(), processNMEA() will be called. These functions deal with specific processing for each type.
2121

22-
Note: When interfacing to a ublox module over I2C **checkUbloxI2C()** will read all bytes currently sitting in the I2C buffer. This may pick up multiple UBX packets. For example, an ACK for a VALSET may be mixed in with an **AutoPVT** response. We cannot tell **checkUbloxI2C()** to stop once a given ACK is found because we run the risk of leaving unprocessed bytes in the I2C buffer and losing them. We don't have this issue with **checkUbloxSerial()**.
22+
Note: When interfacing to a u-blox module over I2C **checkUbloxI2C()** will read all bytes currently sitting in the I2C buffer. This may pick up multiple UBX packets. For example, an ACK for a VALSET may be mixed in with an **AutoPVT** response. We cannot tell **checkUbloxI2C()** to stop once a given ACK is found because we run the risk of leaving unprocessed bytes in the I2C buffer and losing them. We don't have this issue with **checkUbloxSerial()**.
2323

2424
**processUBX()** will check the CRC of the UBX packet. If validated, the packet will be marked as valid. Once a packet is marked as valid then **processUBXpacket()** is called to extract the contents. This is most commonly used to get the position, velocity, and time (PVT) out of the packet but is also used to check the nature of an ACK packet.
2525

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun u-blox Arduino Library
2-
version=1.8.9
2+
version=1.8.10
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for I2C and Serial Communication with u-blox modules

src/SparkFun_Ublox_Arduino_Library.cpp

+28-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,16 @@ boolean SFE_UBLOX_GPS::begin(TwoWire &wirePort, uint8_t deviceAddress)
9292

9393
_gpsI2Caddress = deviceAddress; //Store the I2C address from user
9494

95-
return (isConnected());
95+
// Attempt isConnected up to 3 times if required
96+
boolean success = isConnected();
97+
98+
if (!success)
99+
success = isConnected();
100+
101+
if (!success)
102+
success = isConnected();
103+
104+
return (success);
96105
}
97106

98107
//Initialize the Serial port
@@ -101,7 +110,16 @@ boolean SFE_UBLOX_GPS::begin(Stream &serialPort)
101110
commType = COMM_TYPE_SERIAL;
102111
_serialPort = &serialPort; //Grab which port the user wants us to use
103112

104-
return (isConnected());
113+
// Attempt isConnected up to 3 times if required
114+
boolean success = isConnected();
115+
116+
if (!success)
117+
success = isConnected();
118+
119+
if (!success)
120+
success = isConnected();
121+
122+
return (success);
105123
}
106124

107125
//Sets the global size for I2C transactions
@@ -1401,7 +1419,14 @@ boolean SFE_UBLOX_GPS::isConnected(uint16_t maxWait)
14011419
packetCfg.len = 0;
14021420
packetCfg.startingSpot = 0;
14031421

1404-
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_RECEIVED); // We are polling the RATE so we expect data and an ACK
1422+
sfe_ublox_status_e result = sendCommand(&packetCfg, maxWait); // Poll the navigation rate
1423+
1424+
// In this case, we don't acutally care what the navigation rate is, we're just polling it to indicate a connection.
1425+
// So we return true if result is DATA_RECEIVED or DATA_OVERWRITTEN (just in case the RATE was overwritten by an auto packet).
1426+
if ((result == SFE_UBLOX_STATUS_DATA_RECEIVED) || (result == SFE_UBLOX_STATUS_DATA_OVERWRITTEN))
1427+
return (true);
1428+
else
1429+
return (false);
14051430
}
14061431

14071432
//Given a message, calc and store the two byte "8-Bit Fletcher" checksum over the entirety of the message

0 commit comments

Comments
 (0)