SparkFun Forums 

Where electronics enthusiasts find answers.

Hardware or product specific questions are best asked here.
By stumax
#227986
Hi all,

I'm trying to send a UBX_UPD_SOS command to a NEO-M9N GPS board to back up the GPS data, as my battery backup just doesn't seem to work, even though the battery is charged. I took an example in the library which sends a rate update and have tried to modify it to send the command but it's just not working. I'm guessing there's something I'm missing but the UBlox Interface Description doc doesn't spell it out all that clearly to someone who's not 100% familiar with UBlox commands. Here's a snippet of code which is trying to do this:
Code: Select all
  //trying to get UBX_UPD_SOS to work
  //const uint8_t UBX_UPD_SOS = 0x14 as per UBlox interface description and is declared in SparkFun_u-blox_GNSS_Arduino_Library.h
  //const uint8_t UBX_CLASS_UPD = 0x09 as per UBlox interface description and is declared in SparkFun_u-blox_GNSS_Arduino_Library.h
   uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes
  // The next line creates and initialises the packet information which wraps around the payload
  ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
  customCfg.cls = 0x09;//UBX_CLASS_UPD This is the message Class
  customCfg.id = 0x14;//UBX_UPD_SOS This is the message ID
  customCfg.len = 4; // Setting the len (length) to 4 as per UBlox interface description
  customCfg.startingSpot = 0; // Always set the startingSpot to zero (unless you really know what you are doing)

  // 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)
  customPayload[0] = 0;// command = 0 as per UBlox interface description
  customPayload[1] = 0;// reserved, set to 0 as per UBlox interface description

  if (myGPS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
  {
    Serial.println(F("sendCommand failed! Freezing..."));
    while (1)
      ;
  }
It's taken from the library example "Example20_SendCustomCommand.ino" which I was able to get to work, albeit with a bit of fiddling as I'm using an Artemis Openlog board.

Has anyone had any success in sending other custom commands? I'm not 100% sure exactly what I'm meant to be putting in the data payload, I think it's two bytes of 0: first byte being the command, the second byte being reserved but it does indicate that a reserved byte should be given the value of 0.

Thanks!

Stu.
User avatar
By PaulZC
#227988
Hi Stu,
Interesting idea. Please let us know if it works!
Some suggestions:
It would be a good idea to set payload bytes two and three to zero also:
customPayload[2] = 0;// reserved, set to 0 as per UBlox interface description
customPayload[3] = 0;// reserved, set to 0 as per UBlox interface description
There's a note hidden somewhere in the protocol specification which says all reserved bytes should be set to zero. The U1[3] in the documentation indicates that the reserved field is three bytes wide.
You are sending a command to the u-blox module. It will probably only respond with an ACK, not data and an ACK. If you change:
if (myGPS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
to
if (myGPS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_SENT)
it may work.
Best wishes,
Paul
 Topic permissions

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]