@@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
Polling RXM RAWX reports over I2C
|
||||||
|
By: Paul Clark
|
||||||
|
SparkFun Electronics
|
||||||
|
Date: November 25th, 2022
|
||||||
|
License: MIT. See license file for more information but you can
|
||||||
|
basically do whatever you want with this code.
|
||||||
|
|
||||||
|
This example shows how to poll RXM RAWX reports from the u-blox module.
|
||||||
|
|
||||||
|
Feel like supporting open source hardware?
|
||||||
|
Buy a board from SparkFun!
|
||||||
|
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
|
||||||
|
|
||||||
|
Hardware Connections:
|
||||||
|
Plug a Qwiic cable into the GPS and a BlackBoard
|
||||||
|
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
|
||||||
|
Open the serial monitor at 115200 baud to see the output
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Wire.h> //Needed for I2C to GPS
|
||||||
|
|
||||||
|
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
|
||||||
|
SFE_UBLOX_GNSS myGNSS;
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
Serial.begin(115200);
|
||||||
|
while (!Serial); //Wait for user to open terminal
|
||||||
|
Serial.println("SparkFun u-blox Example");
|
||||||
|
|
||||||
|
Wire.begin();
|
||||||
|
|
||||||
|
//myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
|
||||||
|
|
||||||
|
// Because we are polling RAWX, we need to increase the size of packetCfg.payload
|
||||||
|
// RAWX packets can be over 2K bytes so let's allocate 3K bytes
|
||||||
|
if (!myGNSS.setPacketCfgPayloadSize(3000))
|
||||||
|
{
|
||||||
|
Serial.println(F("setPacketCfgPayloadSize failed. You will not be able to poll RAWX data. Freezing."));
|
||||||
|
while (1); // Do nothing more
|
||||||
|
}
|
||||||
|
|
||||||
|
while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
|
||||||
|
{
|
||||||
|
Serial.println(F("u-blox GNSS not detected at default I2C address. Retrying..."));
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println(F("u-blox GNSS detected."));
|
||||||
|
|
||||||
|
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
|
||||||
|
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
|
||||||
|
|
||||||
|
myGNSS.setNavigationFrequency(1); //Produce one solution per second (RAWX produces a _lot_ of data!)
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
if (myGNSS.getRXMRAWX()) // Poll RAWX data
|
||||||
|
{
|
||||||
|
// Print the RAWX data, using a pointer to the RXM RAWX data stored in packetUBXRXMRAWX
|
||||||
|
printRAWX(&myGNSS.packetUBXRXMRAWX->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void printRAWX(UBX_RXM_RAWX_data_t *ubxDataStruct)
|
||||||
|
{
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
|
Serial.print(F("New RAWX data received. It contains "));
|
||||||
|
Serial.print(ubxDataStruct->header.numMeas); // Print numMeas (Number of measurements / blocks)
|
||||||
|
Serial.println(F(" data blocks:"));
|
||||||
|
|
||||||
|
for (uint8_t block = 0; block < ubxDataStruct->header.numMeas; block++) // For each block
|
||||||
|
{
|
||||||
|
Serial.print(F("GNSS ID: "));
|
||||||
|
if (ubxDataStruct->blocks[block].gnssId < 100) Serial.print(F(" ")); // Align the gnssId
|
||||||
|
if (ubxDataStruct->blocks[block].gnssId < 10) Serial.print(F(" ")); // Align the gnssId
|
||||||
|
Serial.print(ubxDataStruct->blocks[block].gnssId);
|
||||||
|
Serial.print(F(" SV ID: "));
|
||||||
|
if (ubxDataStruct->blocks[block].svId < 100) Serial.print(F(" ")); // Align the svId
|
||||||
|
if (ubxDataStruct->blocks[block].svId < 10) Serial.print(F(" ")); // Align the svId
|
||||||
|
Serial.print(ubxDataStruct->blocks[block].svId);
|
||||||
|
|
||||||
|
if (sizeof(double) == 8) // Check if our processor supports 64-bit double
|
||||||
|
{
|
||||||
|
// Convert prMes from uint8_t[8] to 64-bit double
|
||||||
|
// prMes is little-endian
|
||||||
|
double pseudorange;
|
||||||
|
memcpy(&pseudorange, &ubxDataStruct->blocks[block].prMes, 8);
|
||||||
|
Serial.print(F(" PR: "));
|
||||||
|
Serial.print(pseudorange, 3);
|
||||||
|
|
||||||
|
// Convert cpMes from uint8_t[8] to 64-bit double
|
||||||
|
// cpMes is little-endian
|
||||||
|
double carrierPhase;
|
||||||
|
memcpy(&carrierPhase, &ubxDataStruct->blocks[block].cpMes, 8);
|
||||||
|
Serial.print(F(" m CP: "));
|
||||||
|
Serial.print(carrierPhase, 3);
|
||||||
|
Serial.print(F(" cycles"));
|
||||||
|
}
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
name=SparkFun u-blox GNSS Arduino Library
|
name=SparkFun u-blox GNSS Arduino Library
|
||||||
version=2.2.19
|
version=2.2.20
|
||||||
author=SparkFun Electronics <techsupport@sparkfun.com>
|
author=SparkFun Electronics <techsupport@sparkfun.com>
|
||||||
maintainer=SparkFun Electronics <sparkfun.com>
|
maintainer=SparkFun Electronics <sparkfun.com>
|
||||||
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>
|
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>
|
||||||
|
|||||||
@@ -10377,10 +10377,7 @@ bool SFE_UBLOX_GNSS::getNAVEOE(uint16_t maxWait)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if (_printDebug == true)
|
// Note to self: NAV-EOE is "Periodic" (only). Not sure if it can be polled?
|
||||||
// {
|
|
||||||
// _debugSerial->println(F("getEOE: Polling"));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// The GPS is not automatically reporting navigation position so we have to poll explicitly
|
// The GPS is not automatically reporting navigation position so we have to poll explicitly
|
||||||
packetCfg.cls = UBX_CLASS_NAV;
|
packetCfg.cls = UBX_CLASS_NAV;
|
||||||
@@ -10396,18 +10393,9 @@ bool SFE_UBLOX_GNSS::getNAVEOE(uint16_t maxWait)
|
|||||||
|
|
||||||
if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN)
|
if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN)
|
||||||
{
|
{
|
||||||
// if (_printDebug == true)
|
|
||||||
// {
|
|
||||||
// _debugSerial->println(F("getEOE: data in packetCfg was OVERWRITTEN by another message (but that's OK)"));
|
|
||||||
// }
|
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (_printDebug == true)
|
|
||||||
// {
|
|
||||||
// _debugSerial->print(F("getEOE retVal: "));
|
|
||||||
// _debugSerial->println(statusString(retVal));
|
|
||||||
// }
|
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13487,14 +13475,14 @@ bool SFE_UBLOX_GNSS::initPacketUBXRXMCOR()
|
|||||||
bool SFE_UBLOX_GNSS::getRXMSFRBX(uint16_t maxWait)
|
bool SFE_UBLOX_GNSS::getRXMSFRBX(uint16_t maxWait)
|
||||||
{
|
{
|
||||||
if (packetUBXRXMSFRBX == NULL)
|
if (packetUBXRXMSFRBX == NULL)
|
||||||
initPacketUBXRXMSFRBX(); // Check that RAM has been allocated for the TM2 data
|
initPacketUBXRXMSFRBX(); // Check that RAM has been allocated for the SFRBX data
|
||||||
if (packetUBXRXMSFRBX == NULL) // Bail if the RAM allocation failed
|
if (packetUBXRXMSFRBX == NULL) // Bail if the RAM allocation failed
|
||||||
return (false);
|
return (false);
|
||||||
|
|
||||||
if (packetUBXRXMSFRBX->automaticFlags.flags.bits.automatic && packetUBXRXMSFRBX->automaticFlags.flags.bits.implicitUpdate)
|
if (packetUBXRXMSFRBX->automaticFlags.flags.bits.automatic && packetUBXRXMSFRBX->automaticFlags.flags.bits.implicitUpdate)
|
||||||
{
|
{
|
||||||
// The GPS is automatically reporting, we just check whether we got unread data
|
// The GPS is automatically reporting, we just check whether we got unread data
|
||||||
checkUbloxInternal(&packetCfg, UBX_CLASS_TIM, UBX_TIM_TM2);
|
checkUbloxInternal(&packetCfg, UBX_CLASS_RXM, UBX_RXM_SFRBX);
|
||||||
return packetUBXRXMSFRBX->moduleQueried;
|
return packetUBXRXMSFRBX->moduleQueried;
|
||||||
}
|
}
|
||||||
else if (packetUBXRXMSFRBX->automaticFlags.flags.bits.automatic && !packetUBXRXMSFRBX->automaticFlags.flags.bits.implicitUpdate)
|
else if (packetUBXRXMSFRBX->automaticFlags.flags.bits.automatic && !packetUBXRXMSFRBX->automaticFlags.flags.bits.implicitUpdate)
|
||||||
@@ -13504,23 +13492,9 @@ bool SFE_UBLOX_GNSS::getRXMSFRBX(uint16_t maxWait)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The GPS is not automatically reporting navigation position so we have to poll explicitly
|
// SFRBX is output-only. It cannot be polled...
|
||||||
packetCfg.cls = UBX_CLASS_RXM;
|
// Strictly, getRXMSFRBX should be deprecated. But, to keep the library backward compatible, return(false) here.
|
||||||
packetCfg.id = UBX_RXM_SFRBX;
|
// See issue #167 for details
|
||||||
packetCfg.len = 0;
|
|
||||||
packetCfg.startingSpot = 0;
|
|
||||||
|
|
||||||
// The data is parsed as part of processing the response
|
|
||||||
sfe_ublox_status_e retVal = sendCommand(&packetCfg, maxWait);
|
|
||||||
|
|
||||||
if (retVal == SFE_UBLOX_STATUS_DATA_RECEIVED)
|
|
||||||
return (true);
|
|
||||||
|
|
||||||
if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN)
|
|
||||||
{
|
|
||||||
return (true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13679,14 +13653,14 @@ void SFE_UBLOX_GNSS::logRXMSFRBX(bool enabled)
|
|||||||
bool SFE_UBLOX_GNSS::getRXMRAWX(uint16_t maxWait)
|
bool SFE_UBLOX_GNSS::getRXMRAWX(uint16_t maxWait)
|
||||||
{
|
{
|
||||||
if (packetUBXRXMRAWX == NULL)
|
if (packetUBXRXMRAWX == NULL)
|
||||||
initPacketUBXRXMRAWX(); // Check that RAM has been allocated for the TM2 data
|
initPacketUBXRXMRAWX(); // Check that RAM has been allocated for the RAWX data
|
||||||
if (packetUBXRXMRAWX == NULL) // Bail if the RAM allocation failed
|
if (packetUBXRXMRAWX == NULL) // Bail if the RAM allocation failed
|
||||||
return (false);
|
return (false);
|
||||||
|
|
||||||
if (packetUBXRXMRAWX->automaticFlags.flags.bits.automatic && packetUBXRXMRAWX->automaticFlags.flags.bits.implicitUpdate)
|
if (packetUBXRXMRAWX->automaticFlags.flags.bits.automatic && packetUBXRXMRAWX->automaticFlags.flags.bits.implicitUpdate)
|
||||||
{
|
{
|
||||||
// The GPS is automatically reporting, we just check whether we got unread data
|
// The GPS is automatically reporting, we just check whether we got unread data
|
||||||
checkUbloxInternal(&packetCfg, UBX_CLASS_TIM, UBX_TIM_TM2);
|
checkUbloxInternal(&packetCfg, UBX_CLASS_RXM, UBX_RXM_RAWX);
|
||||||
return packetUBXRXMRAWX->moduleQueried;
|
return packetUBXRXMRAWX->moduleQueried;
|
||||||
}
|
}
|
||||||
else if (packetUBXRXMRAWX->automaticFlags.flags.bits.automatic && !packetUBXRXMRAWX->automaticFlags.flags.bits.implicitUpdate)
|
else if (packetUBXRXMRAWX->automaticFlags.flags.bits.automatic && !packetUBXRXMRAWX->automaticFlags.flags.bits.implicitUpdate)
|
||||||
|
|||||||
Reference in New Issue
Block a user