Skip to content

Commit c4cbf1c

Browse files
committed
Create Example23_getRXMRAWX.ino
1 parent 7a0e348 commit c4cbf1c

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
Polling RXM RAWX reports over I2C
3+
By: Paul Clark
4+
SparkFun Electronics
5+
Date: November 25th, 2022
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
This example shows how to poll RXM RAWX reports from the u-blox module.
10+
11+
Feel like supporting open source hardware?
12+
Buy a board from SparkFun!
13+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
14+
15+
Hardware Connections:
16+
Plug a Qwiic cable into the GPS and a BlackBoard
17+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
18+
Open the serial monitor at 115200 baud to see the output
19+
*/
20+
21+
#include <Wire.h> //Needed for I2C to GPS
22+
23+
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
24+
SFE_UBLOX_GNSS myGNSS;
25+
26+
void setup()
27+
{
28+
Serial.begin(115200);
29+
while (!Serial); //Wait for user to open terminal
30+
Serial.println("SparkFun u-blox Example");
31+
32+
Wire.begin();
33+
34+
//myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
35+
36+
// Because we are polling RAWX, we need to increase the size of packetCfg.payload
37+
// RAWX packets can be over 2K bytes so let's allocate 3K bytes
38+
if (!myGNSS.setPacketCfgPayloadSize(3000))
39+
{
40+
Serial.println(F("setPacketCfgPayloadSize failed. You will not be able to poll RAWX data. Freezing."));
41+
while (1); // Do nothing more
42+
}
43+
44+
while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
45+
{
46+
Serial.println(F("u-blox GNSS not detected at default I2C address. Retrying..."));
47+
delay(1000);
48+
}
49+
50+
Serial.println(F("u-blox GNSS detected."));
51+
52+
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
53+
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
54+
55+
myGNSS.setNavigationFrequency(1); //Produce one solution per second (RAWX produces a _lot_ of data!)
56+
}
57+
58+
void loop()
59+
{
60+
if (myGNSS.getRXMRAWX()) // Poll RAWX data
61+
{
62+
// Print the RAWX data, using a pointer to the RXM RAWX data stored in packetUBXRXMRAWX
63+
printRAWX(&myGNSS.packetUBXRXMRAWX->data);
64+
}
65+
}
66+
67+
void printRAWX(UBX_RXM_RAWX_data_t *ubxDataStruct)
68+
{
69+
Serial.println();
70+
71+
Serial.print(F("New RAWX data received. It contains "));
72+
Serial.print(ubxDataStruct->header.numMeas); // Print numMeas (Number of measurements / blocks)
73+
Serial.println(F(" data blocks:"));
74+
75+
for (uint8_t block = 0; block < ubxDataStruct->header.numMeas; block++) // For each block
76+
{
77+
Serial.print(F("GNSS ID: "));
78+
if (ubxDataStruct->blocks[block].gnssId < 100) Serial.print(F(" ")); // Align the gnssId
79+
if (ubxDataStruct->blocks[block].gnssId < 10) Serial.print(F(" ")); // Align the gnssId
80+
Serial.print(ubxDataStruct->blocks[block].gnssId);
81+
Serial.print(F(" SV ID: "));
82+
if (ubxDataStruct->blocks[block].svId < 100) Serial.print(F(" ")); // Align the svId
83+
if (ubxDataStruct->blocks[block].svId < 10) Serial.print(F(" ")); // Align the svId
84+
Serial.print(ubxDataStruct->blocks[block].svId);
85+
86+
if (sizeof(double) == 8) // Check if our processor supports 64-bit double
87+
{
88+
// Convert prMes from uint8_t[8] to 64-bit double
89+
// prMes is little-endian
90+
double pseudorange;
91+
memcpy(&pseudorange, &ubxDataStruct->blocks[block].prMes, 8);
92+
Serial.print(F(" PR: "));
93+
Serial.print(pseudorange, 3);
94+
95+
// Convert cpMes from uint8_t[8] to 64-bit double
96+
// cpMes is little-endian
97+
double carrierPhase;
98+
memcpy(&carrierPhase, &ubxDataStruct->blocks[block].cpMes, 8);
99+
Serial.print(F(" m CP: "));
100+
Serial.print(carrierPhase, 3);
101+
Serial.print(F(" cycles"));
102+
}
103+
Serial.println();
104+
}
105+
}

0 commit comments

Comments
 (0)