This repository was archived by the owner on Jan 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
Expand getVal/setVal method #134
Merged
+790
−122
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6efce21
Change default setVal to RAM+BBR+Flash. Expanding key set.
nseidle 55bb4a2
Move keys to separate file
nseidle 79679f8
Add getVal8/16/32. Add a bunch of keys.
nseidle 583f528
Add getVal8/16/32 support for group/id/size combos.
nseidle 0fb2fcf
Update Example1_GetSetPortSettings.ino
nseidle 30bff51
Merge branch 'release_candidate' into Expand-getVal-setVal
PaulZC d4975d4
Resort and rename get/setVal examples in one chunk.
nseidle 03a91e5
Remove duplicate define
nseidle 5102d9f
Add MSGOUT keys. Update examples to use defined keys.
nseidle 6239fc2
Adding header guard
nseidle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
examples/GetSetVal/Example1_GetSetPortSettings/Example1_GetSetPortSettings.ino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
Configuring port settings using the newer getVal/setVal methods | ||
By: Nathan Seidle | ||
SparkFun Electronics | ||
Date: October 23rd, 2020 | ||
License: MIT. See license file for more information but you can | ||
basically do whatever you want with this code. | ||
|
||
This example shows how to query a Ublox module for its UART1 settings and | ||
then change them if the settings aren't what we want. | ||
|
||
Note: getVal/setVal/delVal are only support in u-blox protocol versions 27 and higher. | ||
|
||
Feel like supporting open source hardware? | ||
Buy a board from SparkFun! | ||
ZED-F9P RTK2: https://www.sparkfun.com/products/15136 | ||
NEO-M8P RTK: https://www.sparkfun.com/products/15005 | ||
SAM-M8Q: https://www.sparkfun.com/products/15106 | ||
|
||
Hardware Connections: | ||
Plug a Qwiic cable into the GPS and a RedBoard | ||
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_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS | ||
SFE_UBLOX_GPS myGPS; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
while (!Serial) | ||
; //Wait for user to open terminal | ||
Serial.println("SparkFun Ublox Example"); | ||
|
||
Wire.begin(); | ||
|
||
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port | ||
{ | ||
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing.")); | ||
while (1) | ||
; | ||
} | ||
|
||
bool response = true; | ||
|
||
//Read the settings from RAM (what the module is running right now, not BBR, Flash, or default) | ||
uint8_t currentUART1Setting_ubx = myGPS.getVal8(UBLOX_CFG_UART1INPROT_UBX); | ||
uint8_t currentUART1Setting_nmea = myGPS.getVal8(UBLOX_CFG_UART1INPROT_NMEA); | ||
uint8_t currentUART1Setting_rtcm3 = myGPS.getVal8(UBLOX_CFG_UART1INPROT_RTCM3X); | ||
|
||
Serial.print("currentUART1Setting_ubx: "); | ||
Serial.println(currentUART1Setting_ubx); | ||
Serial.print("currentUART1Setting_nmea: "); | ||
Serial.println(currentUART1Setting_nmea); | ||
Serial.print("currentUART1Setting_rtcm3: "); | ||
Serial.println(currentUART1Setting_rtcm3); | ||
|
||
//Check if NMEA and RTCM are enabled for UART1 | ||
if (currentUART1Setting_ubx == 0 || currentUART1Setting_nmea == 0) | ||
{ | ||
Serial.println("Updating UART1 configuration"); | ||
|
||
//setVal sets the values for RAM, BBR, and Flash automatically so no .saveConfiguration() is needed | ||
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_UBX, 1); //Enable UBX on UART1 Input | ||
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_NMEA, 1); //Enable NMEA on UART1 Input | ||
response &= myGPS.setVal8(UBLOX_CFG_UART1INPROT_RTCM3X, 0); //Disable RTCM on UART1 Input | ||
|
||
if (response == false) | ||
Serial.println("SetVal failed"); | ||
else | ||
Serial.println("SetVal succeeded"); | ||
} | ||
else | ||
Serial.println("No port change needed"); | ||
|
||
//Change speed of UART2 | ||
uint32_t currentUART2Baud = myGPS.getVal32(UBLOX_CFG_UART2_BAUDRATE); | ||
Serial.print("currentUART2Baud: "); | ||
Serial.println(currentUART2Baud); | ||
|
||
if (currentUART2Baud != 57600) | ||
{ | ||
response &= myGPS.setVal32(UBLOX_CFG_UART2_BAUDRATE, 57600); | ||
if (response == false) | ||
Serial.println("SetVal failed"); | ||
else | ||
Serial.println("SetVal succeeded"); | ||
} | ||
else | ||
Serial.println("No baud change needed"); | ||
|
||
Serial.println("Done"); | ||
} | ||
|
||
void loop() | ||
{ | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
/* | ||
nseidle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This is a library written for the u-blox ZED-F9P and NEO-M8P-2 | ||
SparkFun sells these at its website: www.sparkfun.com | ||
Do you like this library? Help support SparkFun. Buy a board! | ||
https://www.sparkfun.com/products/16481 | ||
https://www.sparkfun.com/products/15136 | ||
https://www.sparkfun.com/products/15005 | ||
https://www.sparkfun.com/products/15733 | ||
https://www.sparkfun.com/products/15193 | ||
https://www.sparkfun.com/products/15210 | ||
Written by Nathan Seidle @ SparkFun Electronics, September 6th, 2018 | ||
This library handles configuring and handling the responses | ||
from a u-blox GPS module. Works with most modules from u-blox including | ||
the Zed-F9P, NEO-M8P-2, NEO-M9N, ZOE-M8Q, SAM-M8Q, and many others. | ||
https://github.com/sparkfun/SparkFun_Ublox_Arduino_Library | ||
Development environment specifics: | ||
Arduino IDE 1.8.5 | ||
SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT). | ||
The MIT License (MIT) | ||
Copyright (c) 2016 SparkFun Electronics | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
associated documentation files (the "Software"), to deal in the Software without restriction, | ||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to | ||
do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial | ||
portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT | ||
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
//The following consts are used to generate KEY values for the advanced protocol functions of VELGET/SET/DEL | ||
const uint8_t VAL_SIZE_1 = 0x01; //One bit | ||
const uint8_t VAL_SIZE_8 = 0x02; //One byte | ||
const uint8_t VAL_SIZE_16 = 0x03; //Two bytes | ||
const uint8_t VAL_SIZE_32 = 0x04; //Four bytes | ||
const uint8_t VAL_SIZE_64 = 0x05; //Eight bytes | ||
|
||
//These are the Bitfield layers definitions for the UBX-CFG-VALSET message (not to be confused with Bitfield deviceMask in UBX-CFG-CFG) | ||
const uint8_t VAL_LAYER_RAM = (1 << 0); | ||
const uint8_t VAL_LAYER_BBR = (1 << 1); | ||
const uint8_t VAL_LAYER_FLASH = (1 << 2); | ||
const uint8_t VAL_LAYER_ALL = VAL_LAYER_RAM | VAL_LAYER_BBR | VAL_LAYER_FLASH; //Not valid with getVal() | ||
|
||
//Below are various Groups, IDs, and sizes for various settings | ||
//These can be used to call getVal/setVal/delVal | ||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
const uint8_t VAL_ID_PROT_UBX = 0x01; | ||
const uint8_t VAL_ID_PROT_NMEA = 0x02; | ||
const uint8_t VAL_ID_PROT_RTCM3 = 0x04; | ||
|
||
const uint8_t VAL_GROUP_I2C = 0x51; | ||
const uint8_t VAL_GROUP_I2COUTPROT = 0x72; | ||
const uint8_t VAL_GROUP_UART1INPROT = 0x73; | ||
const uint8_t VAL_GROUP_UART1OUTPROT = 0x74; | ||
const uint8_t VAL_GROUP_UART2INPROT = 0x75; | ||
const uint8_t VAL_GROUP_UART2OUTPROT = 0x76; | ||
const uint8_t VAL_GROUP_USBINPROT = 0x77; | ||
const uint8_t VAL_GROUP_USBOUTPROT = 0x78; | ||
|
||
const uint8_t VAL_GROUP_UART_SIZE = VAL_SIZE_1; //All fields in UART group are currently 1 bit | ||
const uint8_t VAL_GROUP_I2C_SIZE = VAL_SIZE_8; //All fields in I2C group are currently 1 byte | ||
|
||
const uint8_t VAL_ID_I2C_ADDRESS = 0x01; | ||
|
||
//Below are the key values for a given configuration setting | ||
|
||
//CFG-NMEA | ||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
const uint32_t UBLOX_CFG_NMEA_PROTVER = 0x10930001; | ||
const uint32_t UBLOX_CFG_NMEA_MAXSVS = 0x10930002; | ||
const uint32_t UBLOX_CFG_NMEA_COMPAT = 0x10930003; | ||
const uint32_t UBLOX_CFG_NMEA_CONSIDER = 0x10930004; | ||
const uint32_t UBLOX_CFG_NMEA_LIMIT82 = 0x10930005; | ||
const uint32_t UBLOX_CFG_NMEA_HIGHPREC = 0x10930006; | ||
const uint32_t UBLOX_CFG_NMEA_SVNUMBERING = 0x20930007; | ||
const uint32_t UBLOX_CFG_NMEA_FILT_GPS = 0x10930011; | ||
const uint32_t UBLOX_CFG_NMEA_FILT_SBAS = 0x10930012; | ||
const uint32_t UBLOX_CFG_NMEA_FILT_GAL = 0x10930013; | ||
const uint32_t UBLOX_CFG_NMEA_FILT_QZSS = 0x10930015; | ||
const uint32_t UBLOX_CFG_NMEA_FILT_GLO = 0x10930016; | ||
const uint32_t UBLOX_CFG_NMEA_FILT_BDS = 0x10930017; | ||
const uint32_t UBLOX_CFG_NMEA_OUT_INVFIX = 0x10930021; | ||
const uint32_t UBLOX_CFG_NMEA_OUT_MSKFIX = 0x10930022; | ||
const uint32_t UBLOX_CFG_NMEA_OUT_INVTIME = 0x10930023; | ||
const uint32_t UBLOX_CFG_NMEA_OUT_INVDATE = 0x10930024; | ||
const uint32_t UBLOX_CFG_NMEA_OUT_ONLYGPS = 0x10930025; | ||
const uint32_t UBLOX_CFG_NMEA_OUT_FROZENCOG = 0x10930026; | ||
const uint32_t UBLOX_CFG_NMEA_MAINTALKERID = 0x20930031; | ||
const uint32_t UBLOX_CFG_NMEA_GSVTALKERID = 0x20930032; | ||
const uint32_t UBLOX_CFG_NMEA_BDSTALKERID = 0x30930033; | ||
|
||
//CFG-RATE | ||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
const uint32_t UBLOX_CFG_RATE_MEAS = 0x30210001; | ||
const uint32_t UBLOX_CFG_RATE_NAV = 0x30210002; | ||
const uint32_t UBLOX_CFG_RATE_TIMEREF = 0x20210003; | ||
|
||
//CFG-I2C | ||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
const uint32_t UBLOX_CFG_I2C_ADDRESS = 0x20510001; | ||
const uint32_t UBLOX_CFG_I2C_ENABLED = 0x10510003; | ||
|
||
const uint32_t UBLOX_CFG_I2CINPROT_UBX = 0x10710001; | ||
const uint32_t UBLOX_CFG_I2CINPROT_NMEA = 0x10710002; | ||
const uint32_t UBLOX_CFG_I2CINPROT_RTCM3X = 0x10710004; | ||
|
||
const uint32_t UBLOX_CFG_I2COUTPROT_UBX = 0x10720001; | ||
const uint32_t UBLOX_CFG_I2COUTPROT_NMEA = 0x10720002; | ||
const uint32_t UBLOX_CFG_I2COUTPROT_RTCM3X = 0x10720004; | ||
|
||
//CFG-UART1 | ||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
const uint32_t UBLOX_CFG_UART1_BAUDRATE = 0x40520001; | ||
const uint32_t UBLOX_CFG_UART1_ENABLED = 0x10520005; | ||
|
||
const uint32_t UBLOX_CFG_UART1INPROT_UBX = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_UART1INPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_UBX << (8 * 0)); //0x10730001 | ||
const uint32_t UBLOX_CFG_UART1INPROT_NMEA = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_UART1INPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_NMEA << (8 * 0)); | ||
const uint32_t UBLOX_CFG_UART1INPROT_RTCM3X = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_UART1INPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_RTCM3 << (8 * 0)); | ||
|
||
const uint32_t UBLOX_CFG_UART1OUTPROT_UBX = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_UART1OUTPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_UBX << (8 * 0)); | ||
const uint32_t UBLOX_CFG_UART1OUTPROT_NMEA = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_UART1OUTPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_NMEA << (8 * 0)); | ||
const uint32_t UBLOX_CFG_UART1OUTPROT_RTCM3X = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_UART1OUTPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_RTCM3 << (8 * 0)); | ||
|
||
//CFG-UART2 | ||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
const uint32_t UBLOX_CFG_UART2_BAUDRATE = 0x40530001; | ||
const uint32_t UBLOX_CFG_UART2_ENABLED = 0x10530005; | ||
|
||
const uint32_t UBLOX_CFG_UART2INPROT_UBX = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_UART2INPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_UBX << (8 * 0)); | ||
const uint32_t UBLOX_CFG_UART2INPROT_NMEA = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_UART2INPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_NMEA << (8 * 0)); | ||
const uint32_t UBLOX_CFG_UART2INPROT_RTCM3X = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_UART2INPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_RTCM3 << (8 * 0)); | ||
|
||
const uint32_t UBLOX_CFG_UART2OUTPROT_UBX = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_UART2OUTPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_UBX << (8 * 0)); | ||
const uint32_t UBLOX_CFG_UART2OUTPROT_NMEA = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_UART2OUTPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_NMEA << (8 * 0)); | ||
const uint32_t UBLOX_CFG_UART2OUTPROT_RTCM3X = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_UART2OUTPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_RTCM3 << (8 * 0)); | ||
|
||
//CFG-USB | ||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
const uint32_t UBLOX_CFG_USBINPROT_UBX = 0x10770001; | ||
const uint32_t UBLOX_CFG_USBINPROT_NMEA = 0x10770002; | ||
const uint32_t UBLOX_CFG_USBINPROT_RTCM3X = 0x10770004; | ||
nseidle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const uint32_t UBLOX_CFG_USBOUTPROT_UBX = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_USBOUTPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_UBX << (8 * 0)); | ||
const uint32_t UBLOX_CFG_USBOUTPROT_NMEA = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_USBOUTPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_NMEA << (8 * 0)); | ||
const uint32_t UBLOX_CFG_USBOUTPROT_RTCM3X = ((VAL_GROUP_UART_SIZE << 4) << (8 * 3)) | (VAL_GROUP_USBOUTPROT << (8 * 2)) | (0x00 << (8 * 1)) | (VAL_ID_PROT_RTCM3 << (8 * 0)); | ||
|
||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.