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

add func getModuleInfo and example #103

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions examples/Example8_GetProtocolVersion/Example8_1_GetModuleInfo.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Reading the Information texts of a Ublox module
By: mayopan
https://github.com/mayopan
Date: May 4th, 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 get Ublox module information in text.
It's for UART connection to GPS.
If you want to connect GPS through i2c, include Wire.h


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_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS

SFE_UBLOX_GPS myGPS;

long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox module.

void setup()
{
Serial.begin(115200);
while (!Serial)
; //Wait for user to open terminal
Serial.println("SparkFun Ublox Example");

Serial2.begin(115200);
delay(50);
if (myGPS.begin(Serial2) == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("115200 baud connection is failed. Trying at 9600 baud."));
Serial2.begin(9600);
delay(50);
}

if (myGPS.begin(Serial2) == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected. Please check wiring. Freezing."));
while (1)
;
}

myGPS.getModuleInfo();
Serial.println("Module Info : ");
Serial.print("Soft version: ");
Serial.println(myGPS.minfo.swVersion);
Serial.print("Hard version: ");
Serial.println(myGPS.minfo.hwVersion);
Serial.println("Extensions:");
for (int i = 0; i < myGPS.minfo.extensionNo; i++)
{
Serial.print(" ");
Serial.println(myGPS.minfo.extension[i]);
}
Serial.println();
Serial.println("Done!");
}

void loop()
{
//Do nothing
}
38 changes: 38 additions & 0 deletions src/SparkFun_Ublox_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3081,6 +3081,44 @@ boolean SFE_UBLOX_GPS::getProtocolVersion(uint16_t maxWait)
return (false); //We failed
}

//Get the information of the Ublox module we're communicating with
//They are strings, so easy to read. Parsing is up to you!
boolean SFE_UBLOX_GPS::getModuleInfo(uint16_t maxWait)
{
//Send packet with only CLS and ID, length of zero. This will cause the module to respond with the contents of that CLS/ID.
packetCfg.cls = UBX_CLASS_MON;
packetCfg.id = UBX_MON_VER;
packetCfg.len = 0;
packetCfg.startingSpot = 0;

if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
return (false); //If command send fails then bail

int position = 0;
for (int i = 0; i < 30; i++)
{
minfo.swVersion[i] = payloadCfg[position];
position++;
}
for (int i = 0; i < 10; i++)
{
minfo.hwVersion[i] = payloadCfg[position];
position++;
}

while (packetCfg.len >= position + 30)
{
for (int i = 0; i < 30; i++)
{
minfo.extension[minfo.extensionNo][i] = payloadCfg[position];
position++;
}
minfo.extensionNo++;
}

return (true); //We failed
}

//Mark all the PVT data as read/stale. This is handy to get data alignment after CRC failure
void SFE_UBLOX_GPS::flushPVT()
{
Expand Down
10 changes: 10 additions & 0 deletions src/SparkFun_Ublox_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ class SFE_UBLOX_GPS
uint8_t getProtocolVersionHigh(uint16_t maxWait = 500); //Returns the PROTVER XX.00 from UBX-MON-VER register
uint8_t getProtocolVersionLow(uint16_t maxWait = 500); //Returns the PROTVER 00.XX from UBX-MON-VER register
boolean getProtocolVersion(uint16_t maxWait = 500); //Queries module, loads low/high bytes
boolean getModuleInfo(uint16_t maxWait = 500); //Queries module, texts

boolean getRELPOSNED(uint16_t maxWait = 1100); //Get Relative Positioning Information of the NED frame

Expand Down Expand Up @@ -678,6 +679,15 @@ class SFE_UBLOX_GPS
bool refObsMiss;
} relPosInfo;

//Module infomation
struct minfoStructure
{
char swVersion[30];
char hwVersion[10];
uint8_t extensionNo;
char extension[10][30];
} minfo;

//The major datums we want to globally store
uint16_t gpsYear;
uint8_t gpsMonth;
Expand Down