Skip to content

Commit e35376f

Browse files
committed
Add support for UBX-RXM-COR
1 parent 35868c7 commit e35376f

4 files changed

+178
-22
lines changed

keywords.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ UBX_NAV_AOPSTATUS_data_t KEYWORD1
4040

4141
UBX_RXM_PMP_data_t KEYWORD1
4242
UBX_RXM_PMP_message_data_t KEYWORD1
43+
UBX_RXM_COR_data_t KEYWORD1
4344
UBX_RXM_SFRBX_data_t KEYWORD1
4445
UBX_RXM_RAWX_data_t KEYWORD1
4546

@@ -393,6 +394,8 @@ logAOPSTATUS KEYWORD2
393394
setRXMPMPcallbackPtr KEYWORD2
394395
setRXMPMPmessageCallbackPtr KEYWORD2
395396

397+
setRXMCORcallbackPtr KEYWORD2
398+
396399
getRXMSFRBX KEYWORD2
397400
setAutoRXMSFRBX KEYWORD2
398401
setAutoRXMSFRBXrate KEYWORD2
@@ -772,6 +775,8 @@ UBX_NAV_TIMELS LITERAL1
772775
UBX_NAV_VELECEF LITERAL1
773776
UBX_NAV_VELNED LITERAL1
774777

778+
UBX_RXM_PMP LITERAL1
779+
UBX_RXM_COR LITERAL1
775780
UBX_RXM_RAWX LITERAL1
776781
UBX_RXM_SFRBX LITERAL1
777782
UBX_RXM_SPARTN LITERAL1

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,16 @@ void SFE_UBLOX_GNSS::end(void)
294294
packetUBXRXMPMPmessage = NULL; // Redundant?
295295
}
296296

297+
if (packetUBXRXMCOR != NULL)
298+
{
299+
if (packetUBXRXMCOR->callbackData != NULL)
300+
{
301+
delete packetUBXRXMCOR->callbackData;
302+
}
303+
delete packetUBXRXMCOR;
304+
packetUBXRXMCOR = NULL; // Redundant?
305+
}
306+
297307
if (packetUBXRXMSFRBX != NULL)
298308
{
299309
if (packetUBXRXMSFRBX->callbackData != NULL)
@@ -1333,6 +1343,10 @@ bool SFE_UBLOX_GNSS::checkAutomatic(uint8_t Class, uint8_t ID)
13331343
if ((packetUBXRXMPMP != NULL) || (packetUBXRXMPMPmessage != NULL))
13341344
result = true;
13351345
break;
1346+
case UBX_RXM_COR:
1347+
if (packetUBXRXMCOR != NULL)
1348+
result = true;
1349+
break;
13361350
}
13371351
}
13381352
break;
@@ -1504,6 +1518,9 @@ uint16_t SFE_UBLOX_GNSS::getMaxPayloadSize(uint8_t Class, uint8_t ID)
15041518
case UBX_RXM_PMP:
15051519
maxSize = UBX_RXM_PMP_MAX_LEN;
15061520
break;
1521+
case UBX_RXM_COR:
1522+
maxSize = UBX_RXM_COR_LEN;
1523+
break;
15071524
}
15081525
}
15091526
break;
@@ -3772,6 +3789,22 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg)
37723789
packetUBXRXMPMPmessage->automaticFlags.flags.bits.callbackCopyValid = true; // Mark the data as valid
37733790
}
37743791
}
3792+
else if (msg->id == UBX_RXM_COR)
3793+
{
3794+
// Parse various byte fields into storage - but only if we have memory allocated for it
3795+
if ((packetUBXRXMCOR != NULL) && (packetUBXRXMCOR->callbackData != NULL)
3796+
//&& (packetUBXRXMCOR->automaticFlags.flags.bits.callbackCopyValid == false) // <=== Uncomment this line to prevent new data from overwriting 'old'
3797+
)
3798+
{
3799+
packetUBXRXMCOR->callbackData->version = extractByte(msg, 0);
3800+
packetUBXRXMCOR->callbackData->ebno = extractByte(msg, 1);
3801+
packetUBXRXMCOR->callbackData->statusInfo.all = extractLong(msg, 4);
3802+
packetUBXRXMCOR->callbackData->msgType = extractInt(msg, 8);
3803+
packetUBXRXMCOR->callbackData->msgSubType = extractInt(msg, 10);
3804+
3805+
packetUBXRXMCOR->automaticFlags.flags.bits.callbackCopyValid = true; // Mark the data as valid
3806+
}
3807+
}
37753808
else if (msg->id == UBX_RXM_SFRBX)
37763809
// Note: length is variable
37773810
// Note: on protocol version 17: numWords is (0..16)
@@ -5359,6 +5392,17 @@ void SFE_UBLOX_GNSS::checkCallbacks(void)
53595392
packetUBXRXMPMPmessage->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale
53605393
}
53615394

5395+
if ((packetUBXRXMCOR != NULL) // If RAM has been allocated for message storage
5396+
&& (packetUBXRXMCOR->callbackData != NULL) // If RAM has been allocated for the copy of the data
5397+
&& (packetUBXRXMCOR->callbackPointerPtr != NULL) // If the pointer to the callback has been defined
5398+
&& (packetUBXRXMCOR->automaticFlags.flags.bits.callbackCopyValid == true)) // If the copy of the data is valid
5399+
{
5400+
// if (_printDebug == true)
5401+
// _debugSerial->println(F("checkCallbacks: calling callbackPtr for RXM COR"));
5402+
packetUBXRXMCOR->callbackPointerPtr(packetUBXRXMCOR->callbackData); // Call the callback
5403+
packetUBXRXMCOR->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale
5404+
}
5405+
53625406
if ((packetUBXRXMSFRBX != NULL) // If RAM has been allocated for message storage
53635407
&& (packetUBXRXMSFRBX->callbackData != NULL) // If RAM has been allocated for the copy of the data
53645408
&& (packetUBXRXMSFRBX->automaticFlags.flags.bits.callbackCopyValid == true)) // If the copy of the data is valid
@@ -12316,6 +12360,49 @@ bool SFE_UBLOX_GNSS::initPacketUBXRXMPMPmessage()
1231612360
return (true);
1231712361
}
1231812362

12363+
bool SFE_UBLOX_GNSS::setRXMCORcallbackPtr(void (*callbackPointer)(UBX_RXM_COR_data_t *))
12364+
{
12365+
if (packetUBXRXMCOR == NULL)
12366+
initPacketUBXRXMCOR(); // Check that RAM has been allocated for the data
12367+
if (packetUBXRXMCOR == NULL) // Only attempt this if RAM allocation was successful
12368+
return false;
12369+
12370+
if (packetUBXRXMCOR->callbackData == NULL) // Check if RAM has been allocated for the callback copy
12371+
{
12372+
packetUBXRXMCOR->callbackData = new UBX_RXM_COR_data_t; // Allocate RAM for the main struct
12373+
}
12374+
12375+
if (packetUBXRXMCOR->callbackData == NULL)
12376+
{
12377+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
12378+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
12379+
_debugSerial->println(F("setAutoRXMCORcallbackPtr: RAM alloc failed!"));
12380+
#endif
12381+
return (false);
12382+
}
12383+
12384+
packetUBXRXMCOR->callbackPointerPtr = callbackPointer;
12385+
return (true);
12386+
}
12387+
12388+
// PRIVATE: Allocate RAM for packetUBXRXMCOR and initialize it
12389+
bool SFE_UBLOX_GNSS::initPacketUBXRXMCOR()
12390+
{
12391+
packetUBXRXMCOR = new UBX_RXM_COR_t; // Allocate RAM for the main struct
12392+
if (packetUBXRXMCOR == NULL)
12393+
{
12394+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
12395+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
12396+
_debugSerial->println(F("initPacketUBXRXMCOR: RAM alloc failed!"));
12397+
#endif
12398+
return (false);
12399+
}
12400+
packetUBXRXMCOR->automaticFlags.flags.all = 0;
12401+
packetUBXRXMCOR->callbackPointerPtr = NULL;
12402+
packetUBXRXMCOR->callbackData = NULL;
12403+
return (true);
12404+
}
12405+
1231912406
// ***** RXM SFRBX automatic support
1232012407

1232112408
bool SFE_UBLOX_GNSS::getRXMSFRBX(uint16_t maxWait)

src/SparkFun_u-blox_GNSS_Arduino_Library.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,8 @@ class SFE_UBLOX_GNSS
11591159
bool setRXMPMPcallbackPtr(void (*callbackPointerPtr)(UBX_RXM_PMP_data_t *)); // Callback receives a pointer to the data, instead of _all_ the data. Much kinder on the stack!
11601160
bool setRXMPMPmessageCallbackPtr(void (*callbackPointerPtr)(UBX_RXM_PMP_message_data_t *)); // Use this if you want all of the PMP message (including sync chars, checksum, etc.) to push to a GNSS
11611161

1162+
bool setRXMCORcallbackPtr(void (*callbackPointerPtr)(UBX_RXM_COR_data_t *)); // RXM COR
1163+
11621164
bool getRXMSFRBX(uint16_t maxWait = defaultMaxWait); // RXM SFRBX
11631165
bool setAutoRXMSFRBX(bool enabled, uint16_t maxWait = defaultMaxWait); // Enable/disable automatic RXM SFRBX reports at the navigation frequency
11641166
bool setAutoRXMSFRBX(bool enabled, bool implicitUpdate, uint16_t maxWait = defaultMaxWait); // Enable/disable automatic RXM SFRBX reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update
@@ -1512,6 +1514,7 @@ class SFE_UBLOX_GNSS
15121514

15131515
UBX_RXM_PMP_t *packetUBXRXMPMP = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
15141516
UBX_RXM_PMP_message_t *packetUBXRXMPMPmessage = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
1517+
UBX_RXM_COR_t *packetUBXRXMCOR = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
15151518
UBX_RXM_SFRBX_t *packetUBXRXMSFRBX = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
15161519
UBX_RXM_RAWX_t *packetUBXRXMRAWX = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
15171520

@@ -1610,6 +1613,7 @@ class SFE_UBLOX_GNSS
16101613
bool initPacketUBXNAVAOPSTATUS(); // Allocate RAM for packetUBXNAVAOPSTATUS and initialize it
16111614
bool initPacketUBXRXMPMP(); // Allocate RAM for packetUBXRXMPMP and initialize it
16121615
bool initPacketUBXRXMPMPmessage(); // Allocate RAM for packetUBXRXMPMPRaw and initialize it
1616+
bool initPacketUBXRXMCOR(); // Allocate RAM for packetUBXRXMCOR and initialize it
16131617
bool initPacketUBXRXMSFRBX(); // Allocate RAM for packetUBXRXMSFRBX and initialize it
16141618
bool initPacketUBXRXMRAWX(); // Allocate RAM for packetUBXRXMRAWX and initialize it
16151619
bool initPacketUBXCFGPRT(); // Allocate RAM for packetUBXCFGPRT and initialize it

src/u-blox_structs.h

Lines changed: 82 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,66 @@ typedef struct
14841484
UBX_RXM_RAWX_data_t *callbackData;
14851485
} UBX_RXM_RAWX_t;
14861486

1487+
// UBX-RXM-COR (0x02 0x34): Differential correction input status
1488+
const uint16_t UBX_RXM_COR_LEN = 12;
1489+
1490+
typedef struct
1491+
{
1492+
uint8_t version; // Message version (0x01 for this version)
1493+
uint8_t ebno; // Energy per bit to noise power spectral density ratio (Eb/N0): 2^-3 dB
1494+
// 0: unknown. Reported only for protocol UBX-RXM-PMP (SPARTN) to monitor signal quality.
1495+
uint8_t reserved0[2]; // Reserved
1496+
union
1497+
{
1498+
uint32_t all;
1499+
struct
1500+
{
1501+
uint32_t protocol : 5; // Input correction data protocol:
1502+
// 0: Unknown
1503+
// 1: RTCM3
1504+
// 2: SPARTN (Secure Position Augmentation for Real Time Navigation)
1505+
// 29: UBX-RXM-PMP (SPARTN)
1506+
// 30: UBX-RXM-QZSSL6
1507+
uint32_t errStatus : 2; // Error status of the received correction message content based on possibly available error codes or checksums:
1508+
// 0: Unknown
1509+
// 1: Error-free
1510+
// 2: Erroneous
1511+
uint32_t msgUsed : 2; // Status of receiver using the input message:
1512+
// 0: Unknown
1513+
// 1: Not used
1514+
// 2: Used
1515+
uint32_t correctionId : 16; // Identifier for the correction stream:
1516+
// For RTCM 3: Reference station ID (DF003) of the received RTCM input message.
1517+
// Valid range 0-4095.
1518+
// For all other messages, reports 0xFFFF.
1519+
// For other correction protocols 0xFFFF.
1520+
uint32_t msgTypeValid : 1; // Validity of the msgType field. Set to False e.g. if the protocol does not define msgType.
1521+
uint32_t msgSubTypeValid : 1; // Validity of the msgSubType field. Set to False e.g. if the protocol does not define subtype for the msgType.
1522+
uint32_t msgInputHandle : 1; // Input handling support of the input message:
1523+
// 0: Receiver does not have input handling support for this message
1524+
// 1: Receiver has input handling support for this message
1525+
uint32_t msgEncrypted : 2; // Encryption status of the input message:
1526+
// 0: Unknown
1527+
// 1: Not encrypted
1528+
// 2: Encrypted
1529+
uint32_t msgDecrypted : 2; // Decryption status of the input message:
1530+
// 0: Unknown
1531+
// 1: Not decrypted
1532+
// 2: Successfully decrypted
1533+
} bits;
1534+
} statusInfo;
1535+
uint16_t msgType; // Message type
1536+
uint16_t msgSubType; // Message subtype
1537+
} UBX_RXM_COR_data_t;
1538+
1539+
// The COR data can only be accessed via a callback. COR cannot be polled.
1540+
typedef struct
1541+
{
1542+
ubxAutomaticFlags automaticFlags;
1543+
void (*callbackPointerPtr)(UBX_RXM_COR_data_t *);
1544+
UBX_RXM_COR_data_t *callbackData;
1545+
} UBX_RXM_COR_t;
1546+
14871547
// UBX-RXM-PMP (0x02 0x72): PMP raw data (D9 modules)
14881548
// There are two versions of this message but, fortunately, both have a max len of 528
14891549
const uint16_t UBX_RXM_PMP_MAX_USER_DATA = 504;
@@ -1702,52 +1762,52 @@ const uint16_t UBX_MON_HW_LEN = 60;
17021762

17031763
typedef struct
17041764
{
1705-
uint32_t pinSel; // Mask of pins set as peripheral/PIO
1706-
uint32_t pinBank; // Mask of pins set as bank A/B
1707-
uint32_t pinDir; // Mask of pins set as input/output
1708-
uint32_t pinVal; // Mask of pins value low/high
1765+
uint32_t pinSel; // Mask of pins set as peripheral/PIO
1766+
uint32_t pinBank; // Mask of pins set as bank A/B
1767+
uint32_t pinDir; // Mask of pins set as input/output
1768+
uint32_t pinVal; // Mask of pins value low/high
17091769
uint16_t noisePerMS; // Noise level as measured by the GPS core
1710-
uint16_t agcCnt; // AGC monitor (counts SIGHI xor SIGLO, range 0 to 8191)
1711-
uint8_t aStatus; // Status of the antenna supervisor state machine (0=INIT, 1=DONTKNOW, 2=OK, 3=SHORT, 4=OPEN)
1712-
uint8_t aPower; // Current power status of antenna (0=OFF, 1=ON, 2=DONTKNOW)
1770+
uint16_t agcCnt; // AGC monitor (counts SIGHI xor SIGLO, range 0 to 8191)
1771+
uint8_t aStatus; // Status of the antenna supervisor state machine (0=INIT, 1=DONTKNOW, 2=OK, 3=SHORT, 4=OPEN)
1772+
uint8_t aPower; // Current power status of antenna (0=OFF, 1=ON, 2=DONTKNOW)
17131773
union
17141774
{
17151775
uint8_t all;
17161776
struct
17171777
{
1718-
uint8_t rtcCalib : 1; // RTC is calibrated
1719-
uint8_t safeBoot : 1; // Safeboot mode (0 = inactive, 1 = active)
1778+
uint8_t rtcCalib : 1; // RTC is calibrated
1779+
uint8_t safeBoot : 1; // Safeboot mode (0 = inactive, 1 = active)
17201780
uint8_t jammingState : 2; // Output from jamming/interference monitor (0 = unknown or feature disabled,
17211781
// 1 = ok - no significant jamming,
17221782
// 2 = warning - interference visible but fix OK,
17231783
// 3 = critical - interference visible and no fix)
1724-
uint8_t xtalAbsent : 1; // RTC xtal has been determined to be absent
1784+
uint8_t xtalAbsent : 1; // RTC xtal has been determined to be absent
17251785
} bits;
17261786
} flags;
1727-
uint8_t reserved1; // Reserved
1728-
uint32_t usedMask; // Mask of pins that are used by the virtual pin manager
1729-
uint8_t VP[17]; // Array of pin mappings for each of the 17 physical pins
1730-
uint8_t jamInd; // CW jamming indicator, scaled (0 = no CW jamming, 255 = strong CW jamming)
1787+
uint8_t reserved1; // Reserved
1788+
uint32_t usedMask; // Mask of pins that are used by the virtual pin manager
1789+
uint8_t VP[17]; // Array of pin mappings for each of the 17 physical pins
1790+
uint8_t jamInd; // CW jamming indicator, scaled (0 = no CW jamming, 255 = strong CW jamming)
17311791
uint8_t reserved2[2]; // Reserved
1732-
uint32_t pinIrq; // Mask of pins value using the PIO Irq
1733-
uint32_t pullH; // Mask of pins value using the PIO pull high resistor
1734-
uint8_t pullL; // Mask of pins value using the PIO pull low resistor
1792+
uint32_t pinIrq; // Mask of pins value using the PIO Irq
1793+
uint32_t pullH; // Mask of pins value using the PIO pull high resistor
1794+
uint8_t pullL; // Mask of pins value using the PIO pull low resistor
17351795
} UBX_MON_HW_data_t;
17361796

17371797
// UBX-MON-HW2 (0x0A 0x0B): Extended hardware status
17381798
const uint16_t UBX_MON_HW2_LEN = 28;
17391799

17401800
typedef struct
17411801
{
1742-
int8_t ofsI; // Imbalance of I-part of complex signal, scaled (-128 = max. negative imbalance, 127 = max. positive imbalance)
1743-
uint8_t magI; // Magnitude of I-part of complex signal, scaled (0 = no signal, 255 = max. magnitude)
1744-
int8_t ofsQ; // Imbalance of Q-part of complex signal, scaled (-128 = max. negative imbalance, 127 = max. positive imbalance)
1745-
uint8_t magQ; // Magnitude of Q-part of complex signal, scaled (0 = no signal, 255 = max. magnitude)
1802+
int8_t ofsI; // Imbalance of I-part of complex signal, scaled (-128 = max. negative imbalance, 127 = max. positive imbalance)
1803+
uint8_t magI; // Magnitude of I-part of complex signal, scaled (0 = no signal, 255 = max. magnitude)
1804+
int8_t ofsQ; // Imbalance of Q-part of complex signal, scaled (-128 = max. negative imbalance, 127 = max. positive imbalance)
1805+
uint8_t magQ; // Magnitude of Q-part of complex signal, scaled (0 = no signal, 255 = max. magnitude)
17461806
uint8_t cfgSource; // Source of low-level configuration (114 = ROM, 111 = OTP, 112 = config pins, 102 = flash image)
17471807
uint8_t reserved0[3];
17481808
uint32_t lowLevCfg; // Low-level configuration (obsolete for protocol versions greater than 15.00)
17491809
uint8_t reserved1[8];
1750-
uint32_t postStatus; // POST status word
1810+
uint32_t postStatus; // POST status word
17511811
uint8_t reserved2[4]; // Reserved
17521812
} UBX_MON_HW2_data_t;
17531813

0 commit comments

Comments
 (0)