Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added UBX_CFG_SMGR configuration support #211

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

dizcza
Copy link

@dizcza dizcza commented Mar 5, 2024

Sketch output:

UBX-CFG-SMGR:
 version 0 (0x00)
 minGNSSFix 5 (0x05)
 maxFreqChangeRate 30 (0x1e)
 maxPhaseCorrRate 80 (0x50)
 freqTolerance 250 (0xfa)
 timeTolerance 2000 (0x7d0)
 messageCfg:
   measInternal: 1
   measGNSS: 1
   measEXTINT0: 1
   measEXTINT1: 1
 maxSlewRate 10000 (0x2710)
 flags:
   disableInternal: 0
   disableExternal: 1
   preferenceMode: 0
   enableGNSS: 1
   enableEXTINT0: 0
   enableEXTINT1: 0
   enableHostMeasInt: 1
   enableHostMeasExt: 1
   useAnyFix: 1
   disableMaxSlewRate: 0
   issueFreqWarn: 1
   issueTimeWarn: 1
   TPCoherent: 2
   disableOffset: 0

UBX-CFG-SMGR successfully updated

I don't see any UBX messages from my device (they are set to echo on Serial) even though PPS is flashing and I have a fix (tried setting minGNSSFix to 1). Any clue?

@dizcza
Copy link
Author

dizcza commented Mar 5, 2024

In particular, no UBX-TIM-SMEAS messages - that's why I started figuring out the SMGR protocol.

Copy link
Collaborator

@PaulZC PaulZC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Danylo (@dizcza ),

This is a useful PR, but it needs some changes... Thanks!

Best wishes,
Paul

uint8_t minGNSSFix; /* Minimum number of GNSS fixes before we commit to use it as a source */
uint16_t maxFreqChangeRate; /* Maximum frequency change rate during disciplining. Must not exceed 30ppb/s*/
uint16_t maxPhaseCorrRate; /* Maximum phase correction rate in coherent time pulse mode. */
uint16_t reserved1; /* Reserved. Do not use */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly, this should be uint8_t [2]

src/u-blox_structs.h Outdated Show resolved Hide resolved
src/u-blox_structs.h Outdated Show resolved Hide resolved
@PaulZC
Copy link
Collaborator

PaulZC commented Mar 6, 2024

Hi Danylo (@dizcza ),

UBX-TIM-SMEAS is almost certainly disabled by default. You will need to enable it with CFG-MSG, or via u-center.

I hope this helps,
Paul

@dizcza
Copy link
Author

dizcza commented Mar 6, 2024

UBX-TIM-SMEAS is almost certainly disabled by default. You will need to enable it with CFG-MSG, or via u-center.

How to do this? I guess I need to simply call

myGNSS.setVal8(UBLOX_CFG_MSGOUT_UBX_TIM_SMEAS_I2C, 1);

but I cannot come up with a value for UBLOX_CFG_MSGOUT_UBX_TIM_SMEAS_I2C - I don't find any mention of how this key value is constructed in the specs datasheet.

Screenshot from 2024-03-06 10-56-17

@dizcza
Copy link
Author

dizcza commented Mar 6, 2024

I think I managed to output TIM-SMEA but I get garbage on my Serial:

void enableMSG_TIM_SMEAS() {
  uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes. MAX_PAYLOAD_SIZE defaults to 256. The CFG_RATE payload is only 6 bytes!

  ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};

  customCfg.cls = UBX_CLASS_CFG; // This is the message Class
  customCfg.id = UBX_CFG_MSG; // This is the message ID
  customCfg.len = 3; // Setting the len (length) to zero let's us poll the current settings
  customCfg.startingSpot = 0; // Always set the startingSpot to zero (unless you really know what you are doing)

  customPayload[0] = UBX_CLASS_TIM;
  customPayload[1] = 0x13;
  customPayload[2] = 1;    // rate in Hz (measurements per sec)

  // We also need to tell sendCommand how long it should wait for a reply
  uint16_t maxWait = 250; // Wait for up to 250ms (Serial may need a lot longer e.g. 1100)

  // Now we write the custom packet back again to change the setting
  if (myGNSS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_SENT) // This time we are only expecting an ACK
  {
    Serial.println(F("Could not update TIM-SMEAS MSG rate"));
  }
  else
  {
    Serial.println(F("TIM-SMEAS MSG rate successfully updated"));
  }

}

Is this because I pipe raw bytes to serial?

  myGNSS.setOutputPort(Serial);

@PaulZC
Copy link
Collaborator

PaulZC commented Mar 6, 2024

The LEA-M8F doesn't support the Configuration Interface. You will need to enable the message manually using configureMessage(UBX_CLASS_TIM, 0x13, COM_PORT_I2C, 1);

The message is UBX binary format. It will contain unprintable characters. You could use a logic analyzer to view the bytes as HEX. Or write a very simple binary to HEX converter and run it on another board?

@PaulZC
Copy link
Collaborator

PaulZC commented Mar 6, 2024

Or - even better - close the serial monitor / terminal emulator and open u-center instead. It will be able to decode the UBX messages and display them correctly.

@dizcza
Copy link
Author

dizcza commented Mar 6, 2024

The LEA-M8F doesn't support the Configuration Interface. You will need to enable the message manually using configureMessage(UBX_CLASS_TIM, 0x13, COM_PORT_I2C, 1);

This one-liner looks much simpler.

Or - even better - close the serial monitor / terminal emulator and open u-center instead. It will be able to decode the UBX messages and display them correctly.

I'm on Ubuntu, I doubt the u-center supports Linux. Even if it does, I eventually need to be able to parse these messages on an ESP32 board via I2C.

Looks like I need to extend the case UBX_CLASS_TIM in the sources and add something similar to packetUBXTIMTM2.

@dizcza dizcza requested a review from PaulZC March 6, 2024 19:44
@dizcza
Copy link
Author

dizcza commented Mar 6, 2024

All right, it was quite a change.

Now the example outputs TIM-SMEA messages:

UBX-TIM-SMEAS:
 version: 0
 numMeas: 4
 iTOW: 330285000
 sourceId 0:
   flags:
      freqValid 1
      phaseValid 1
   phaseOffsetFrac -75
   phaseUncFrac 102
   phaseOffset 2
   phaseUnc 8
   freqOffset -77
   freqUnc 93
 sourceId 1:
   flags:
      freqValid 1
      phaseValid 1
   phaseOffsetFrac -17
   phaseUncFrac 237
   phaseOffset 4
   phaseUnc 7
   freqOffset -36
   freqUnc 70
 sourceId 2:
   flags:
      freqValid 0
      phaseValid 0
   phaseOffsetFrac 0
   phaseUncFrac 0
   phaseOffset 0
   phaseUnc 0
   freqOffset 0
   freqUnc 0
 sourceId 3:
   flags:
      freqValid 0
      phaseValid 0
   phaseOffsetFrac 0
   phaseUncFrac 0
   phaseOffset 0
   phaseUnc 0
   freqOffset 0
   freqUnc 0

@dizcza
Copy link
Author

dizcza commented Mar 6, 2024

I added only one way to pass user callbacks, setAutoTIMSMEAcallback, not to overwhelm poor users with otherwise great API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants